Windows vs Mac/Linux distribution discrepancy

Hi folks,

I’m trying to port some code built on top of LLVM/Clang to Windows,
however I just discovered that the precompiled versions from releases.llvm.org
are missing all the libLLVM* and libclang* dlls. Also, some tools (e.g. opt) are missing on Windows as well.

I’m curious whether it’s a technical limitation (i.e. certain things don’t work on Windows),
or something else?

For the others out there building cross-platform tools based on LLVM:
how do you deal with this issue? Am I supposed to build LLVM myself there?

Cheers,
Alex.

I’m trying to port some code built on top of LLVM/Clang to Windows,
however I just discovered that the precompiled versions from releases.llvm.org
are missing all the libLLVM* and libclang* dlls.

This is controlled by the following CMake settings (see https://llvm.org/docs/CMake.html#llvm-specific-variables):

LLVM_BUILD_LLVM_DYLIB:BOOL

If enabled, the target for building the libLLVM shared library is added. This library contains all of LLVM’s components in a single shared library. Defaults to OFF. This cannot be used in conjunction with BUILD_SHARED_LIBS. Tools will only be linked to the libLLVM shared library if LLVM_LINK_LLVM_DYLIB is also ON. The components in the library can be customised by setting LLVM_DYLIB_COMPONENTS to a list of the desired components. This option is not available on Windows.

LLVM_LINK_LLVM_DYLIB:BOOL

If enabled, tools will be linked with the libLLVM shared library. Defaults to OFF. Setting LLVM_LINK_LLVM_DYLIB to ON also sets LLVM_BUILD_LLVM_DYLIB to ON. This option is not available on Windows.

E.g. these options are off by default (probably because it saves build time, but I'm just guessing here), and are not available on Windows (for reasons unknown to me).

Also, some tools (e.g. opt) are missing on Windows as well.

I don't know about that, but maybe Hans Wennborg has more information.

I’m curious whether it’s a technical limitation (i.e. certain things don’t work on Windows),
or something else?

For the others out there building cross-platform tools based on LLVM:
how do you deal with this issue? Am I supposed to build LLVM myself there?

Either you can link against distro-provided LLVM dynamic libraries, like those shipped by Debian and Ubuntu, or you can link against the static libraries in the release tarballs.

But obviously, you could always build them yourself, and ship them with your tools. This would give you the most flexibility.

-Dimitry

The Visual Studio installer has an option to install Clang tools for Windows or you can build from source. I believe all the tools are not included in the prebuilt package because of size.

Dylibs (dlls) are not included because of COFF limitations. You can’t export an entire C++ codebase from a DLL because you overflow the number of publicly exportable symbols. Without a clear API boundary this probably won’t happen soon.

Hello,

I can only speak from my own experience - I was relying on llvm.org binaries for our toolchain but that has many drawbacks, missing tools, different configs, not all optimization turned on (LTO+PGO). So I would highly recommend you build your own binaries that are more targeted for what you really need.

It’s a bit of a learning curve but it was very much worth it for us.

Thanks,
Tobias

Hi Alex,

As others have answered already, it's a mix of technical things --
exposing everything as a DLL is problematic, and also we'd like to
keep the size of the binaries down. The current situation is that the
Windows binaries are focused on providing an LLVM toolchain by
shipping Clang, LLD, runtimes, etc. -- but not the internal tools like
opt, llc, and so on.

The recommendation is that those who need to build stuff with LLVM
rather than just use the toolchain should build it themselves.

Thanks,
Hans