-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compilers: Do not pass -fuse-ld=lld
via -Wl,
#14012
Conversation
I was initially trying to figure out why this was required at all. Then it hit me -- the linker_to_compiler_args function defines how to translate linker flags for microsoft platform linkers, which might expect to be passed to link.exe, such that e.g. clang when acting as the linker driver will forward those flags on to the real linker. That's why we don't expect the flags to automatically come with Can you mention that in the commit message? P.S. When quoting "Command line: XXXX" etc. as snippets from a logfile, the 80-columns convention doesn't apply (actually, the convention itself says that this is an exception), just enclose it in triple-backticks and carry on. :) |
Done now. A second paragraph has been added. This commit doesn't solve all issues in this setup. For example,
Unwrapped now. I don't write commit message as Markdown, as I work with command-line Git which displays plaintext. |
Clang-CL setups do not work with Meson 1.3 but they are already broken, so let's wait. Reference: mesonbuild/meson#13998 Reference: mesonbuild/meson#14012
`-fuse-ld=` is a driver option for selection of a linker; it shall not be passed to a linker with `-Wl,`. For the Microsoft compiler and linker, the options for the compiler and those for the linker are separated by `/LINK`, which looks like `cl /cl-options ... /link /link-options ...`. Formally, they are passed in the same command line. When Clang is invoking the Microsoft linker or a Microsoft-style linker (that is, LLD-LINK), every linker option has to prefixed by `-Wl,` or `-Xlink`. Previously, using Clang-CL and LLD-LINK, given: cc = meson.get_compiler('c') assert(cc.has_link_argument('/LTCG')) This code failed to detect the `/LTCG` option, because `-fuse-ld=lld` was passed to the linker, as an invalid option: Command line: `clang E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221fee\testfile.c -o E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221fee\output.exe -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Wl,-WX -Wl,/LTCG -Wl,-fuse-ld=lld` -> 4044 stdout: LINK : warning LNK4044: unrecognized option '/fuse-ld=lld'; ignored LINK : error LNK1218: warning treated as error; no output file generated However, it should be noted that not all LINK options can be passed with `-Wl,`. The `/subsystem:windows,6.1` option has a comma, which would be converted to a space. Therefore, this option must be passed as `-Xlinker -subsystem:windows,6.1`. This issue is not addressed in this commit. Signed-off-by: LIU Hao <[email protected]>
Do those errors about macos-clang matter? I don't see these options in Meson source, and don't think these are caused by this commit:
|
If you can't see any way for your PR to have produced the error, it's usually worth looking to see whether the same error occurs on git |
OK fair enough. |
-fuse-ld=
is a driver option for selection of a linker; it shall not be passed to a linker with-Wl,
.Previously, using Clang-CL and LLD-LINK, given:
cc = meson.get_compiler('c')
assert(cc.has_link_argument('/LTCG'))
This code failed to detect the
/LTCG
option, because-fuse-ld
was passed to the linker, as an invalid option:Command line:
clang E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221f ee\testfile.c -o E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221fee\o utput.exe -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declarati on -Wl,-WX -Wl,/LTCG -Wl,-fuse-ld=lld
-> 4044stdout:
LINK : warning LNK4044: unrecognized option '/fuse-ld=lld'; ignored
LINK : error LNK1218: warning treated as error; no output file generated