[PATCH] D77162: libclc: Fix LLVM library linking on Windows

Jan Vesely via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 16:17:50 PDT 2020


jvesely added a comment.

In D77162#1957318 <https://reviews.llvm.org/D77162#1957318>, @daniels wrote:

> > I don't see what the second part is trying to address. Does visual studio not detect the static libraries on the command line? I presume the dynamic versions are not present.
> >  If anything it should check `llvm-config --shared-mode` if available instead of checking for win32. Do all visual studio/clang/mingw use the same flag?
>
> Yes, clang runs as `clang-cl` which accepts MSVC-type arguments, though you can also invoke `clang` to pass UNIX-style arguments. For the linker, however, there is no option; `lld-link` only accepts MSVC-type arguments on Windows and nothing else. I don't know what MinGW does. Is there an easy way to test that? Do you currently build on MinGW?
>
> I could test `llvm-config --shared-mode == static && WIN32` to apply `/MT`, as I tried various other methods of convincing Windows to link statically and not dynamically with no luck. On UNIX this isn't an issue as you can happily mix the two modes.


I'm not sure I fully understand. windows doesn't allow mixing .lib a and .dll libraries?
a superficial search suggests that /MT instructs the linker to use the static-multithreaded version of runtime libs [0]. Other than using the same threaded runtime we should be able to mix static and dynamic libraries, no?

is the `/MT` flag included in LLVM_LINKER_FLAGS?
maybe we just need `set_target_link_options( prepare_builtins ${LLVM_LINKER_FLAGS)` or `set_target_properties( prepare_bultins LINK_FLAGS ${LLVM_LINKER_FLAGS} )`

[0] https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77162/new/

https://reviews.llvm.org/D77162





More information about the llvm-commits mailing list