Replies: 1 comment
-
After having poked around with the code to get answers for myself -
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been trying to clarify the status of meson + lto functionality, using clang, specifically the msvc-style clang (i.e. 'clang-cl') and from this comment from @dcbaker -
it seems like you might be able to confirm or correct my understanding of the current state of things, which is not obvious from simply trying to set a meson project up with
default_options: ['b_lto=true', ...]
-On windows, when using the msvc-style clang compiler/linker tools ('clang-cl.exe' and 'lld-link.exe'), this gives a meson compiler id of 'clang-cl'. The 'allplatformtest.py', 'test_static_library_lto' test is doing a check to skip this test, using only
if detect_c_compiler(env, MachineChoice.HOST).get_id() == 'clang' and is_windows():
... which is checking for use of the gnu-style clang.exe compiler (ID = 'clang'); it doesn't catch the msvc-style 'clang-cl.exe' (ID = 'clang-cl'). However, when the test proceeds to perform themeson setup -Db_lto=true ...
, all settings related to use of lto (i.e.-flto
compile options) are quietly ignored/avoided and the project compiles and links without any LTO and the test succeeds. Is all of this expected?If, again on windows, I explicitly point to the gnu-style clang compiler ('clang.exe'), and attempt to 'meson setup and compile' this same '5 linkstatic' test (doing the following in the 'x64 Native tools command prompt for VS 2022') -
then I get the following successful steps (I'm trimming a little of the output for compactness) -
Similarly, if I point the compiler to the msvc-style 'clang-cl' (
set CC=clang-cl
,set CXX=clang-cl
) and repeat the meson setup and compile steps, it all builds successfully ... only this time, I can see that it doesn't use any-flto
options anywhereIs this expected behaviour, for the clang-cl compiler to quietly ignore the user's request to use 'b_lto=true'?
-flto
switch (it only seems to be needed for the compile steps) and run run the compile (clang-cl.exe -flto ...
), lib (llvm-ar ...
), and link (lld-link ...
) steps, using the msvc-style clang compiler windows tools... it all works fine.Is that expected?
What is the windows-related problem you're referring to in the quote above, and is there an open issue for it and any progress on resolving it?
I do notice that it's critical to also set the linker environment variable (CC_LD=lld-link, CXX_LD=lld-link), without which, we get a link error (routed through
clang.exe ...
instead oflld-link.exe ...
), complaining of corruption in 'main.c.obj', so I wonder if that was what was giving you problems. Is there a way for meson to identify the scenario where the user specifies the clang compiler ... but NOT the 'lld-link' linker, since that scenario gives us problems and would perhaps better be dealt with as an error message (if not a more specific skip-check) for this test? If feels like this should actually be a check and error in meson's internals, not just a skip-check for this particular test. What do you think?Since gnu-style clang tools on windows correctly configures and runs the '5 linkstatic' test with 'b_lto=true', all without error, what is preventing the 'test_static_library_lto' (and similar tests) from removing that "windows and id=='clang'"-skip check?
The same goes for use of the msvc-style clang-cl compiler windows tools; manually running these compile, lib, and link steps -
all works fine (again, provided 'lld-link' is used), so what is preventing meson's full support of 'b_lto=true', when using 'clang-cl' on windows?
Beta Was this translation helpful? Give feedback.
All reactions