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

Russell Haley via cfe-dev cfe-dev at lists.llvm.org
Sun Jan 19 18:04:26 PST 2020


On Sun, Jan 19, 2020 at 12:27 PM Martin Storsjö <martin at martin.st> wrote:

> 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
>

That sounds exactly like what I'm trying to achieve.

You may have answered a question I've had for some time: "Does mingw
require a redistributable"? It sounds like the answer is "whenever linking
to non-standard Windows API calls". If that's the case, how does one get
that redistributable and/or know when it's required?

Many thanks!
Russell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200119/38e5fbcf/attachment.html>


More information about the cfe-dev mailing list