[PATCH] D69760: [Clang][Driver] Don't pun -fuse-ld=lld as -fuse-ld=lld-link with msvc

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 06:37:51 PST 2019


mstorsjo added a comment.

I'm not familiar with where/how the CrossWindows toolchain is used, but you say (and the code seems to agree) that it's intended to be able to use ld.bfd for linking code built for the MSVC ABI with MSVC/WinSDK libs? I'm surprised that even works at all (or does it, or is it just set up and tested for minimal cases and then unused?), as ld.bfd lacks support for a lot of COFF specific features that MSVC ABI uses (which probably can be worked around with `--allow-multiple-definitions` for some bits at least, but I'm not confident that it generally would work even with that).

I presume all of this is about how to call the linker, as compiling with `clang -target <arch>-windows-msvc`, using the MSVC toolchain, should work just fine?

I think a better distinguisher would be whether clang was invoked as `clang[++]` or `clang-cl` (i.e. driver mode). Normally when linking MSVC style, the build system would call `link` (or the link-like tool) with the linker flags directly. Occasionally one could be linking via the cl frontend, as `cl obj1.obj obj2.obj -Feout.exe somelib.lib -link -linkpath:some/path -other_link_style_option`.

Now when doing linking via the clang GCC-style driver, `clang obj1.obj obj2.obj -o out.exe -lsomelib -Lsome/path -Wl,--other-unix-linker-option`, one expects to use unix linking style flags. Hypothesis: There's no predecent for actually using an MSVC link-style linker via this syntax. Or is there?

If there isn't, we could make that the distinguishing factor instead.

The same issue has come up for build systems (meson tried to tackle this recently, don't remember how/if they did yet), when just invoking "clang" on a windows platform (instead of intentionally e.g. "clang-cl"), not knowing whether the implicit default triple is an msvc or mingw triple, which means they don't know in what form to pass linker options. For cross cases where there's an explicit `-target` option, this are slightly clearer (at least from some perspectives), but with the default target, you're really working blindly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69760





More information about the llvm-commits mailing list