[cfe-dev] Compile Compact C Compiler from Clang on Windows 10. For Use with Lua

Martin Storsjö via cfe-dev cfe-dev at lists.llvm.org
Sun Jan 19 12:27:52 PST 2020


On Sun, 19 Jan 2020, Russell Haley via cfe-dev wrote:

>       I think there is a separate aspect to what you are asking, which
>       is, even if you take all of clang as it is, it is still not
>       quite enough to compile and link C code into a DLL. You
>       typically need SDK headers (windows.h) and a standard C library
>       (MSVCRT or mingw). LLVM doesn't provide this, and you have to
>       get it from Microsoft or mingw.
> 
> Yes, I'm aware of the need for a standard library. I'm researching if I can
> re-distribute the header and lib files from the MSVC Build Tools download. A
> brief reading of their license indicates that I cannot redistribute the
> *debug* binaries but doesn't say anything about the headers or lib files. A
> second possible approach as suggested by Zachary Turner would be to compile
> the mingw library with clang and include it but I don't necessarily want
> posix support compared to the MS libc (also noted by Mr. Turner). 

As far as I know, those files aren't redistributable. The fact that they 
aren't is one of the primary reasons for mingw in itself.

Also do note that mingw doesn't provide posix support; mingw primarily 
intends to provide a freely redistributable "sdk" for pure native windows 
code, allowing you to build executables that only rely on the CRT DLLs 
(the windows internal msvcrt.dll, and recently, the UCRT) that ship with 
windows itself (to allow building GPL code and redistributing it).

In addition to the CRT and the windows APIs themselves, mingw does provide 
a few extra posix originated APIs (usleep, getopt and a few other similar 
ones), but this is mostly an exception.

This is contrary to cygwin, which provides a full posix environment (fork 
and all), but requires linking everything to their runtime, and generally 
behaves as an isolated environment from the rest of windows.

If what you want is clang + a redistributable sdk, I just so happen to 
have that prepackaged for you, at https://github.com/mstorsjo/llvm-mingw. 
The packed release is around 150 MB, and the unpacked release weighs in at 
around 500 MB at the moment, but if you remove import libraries for three 
out of four architectures, LLDB and lesser used tools like llvm-objdump, 
llvm-nm etc, you can get it down to slightly above 200 MB.

// Martin


More information about the cfe-dev mailing list