Cleanup and fix sanitycheck linker args - 1.12 version - #16169
Open
bonzini wants to merge 8 commits into
Open
Conversation
Commit 300d7c3 ("compilers: add link always args if CompileCheckMode.LINK") made has_function() and friends pass the linker's always args, so that e.g. -Zomf is not missing on OS/2 when a dependency is used. Before changing where those arguments are added, add a test. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Commit c9bb03c ("Stop passing link arguments to compile-only sanity checks", 2026-08-28) dropped link arguments from compile-only checks for CLikeCompiler. Introduce Compiler._sanity_check_mode() to move this logic up to Compiler and so that it applies also to the super() call of CLikeCompiler._sanity_check_compile_args(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Commit 797decc ("compilers: pass external args to sanity check") made Compiler._sanity_check_compile_args() add {c,cpp}_args and {c,cpp}_link_args, assuming the extra copies on the CLike path were harmless because "arglist deduplicates them", but the sanity check builds a plain list so nothing is deduplicated. Furthermore, the copy of linker arguments in s_largs would end up in front of the /link that linker_to_compiler_args() inserts for MSVC-style compilers. For example, with c_link_args=['/SUBSYSTEM:CONSOLE'] the probe became cl ... /c /SUBSYSTEM:CONSOLE /link /SUBSYSTEM:CONSOLE (the first from super()._sanity_check_compile_args, the second from self._get_basic_compiler_args) instead of cl ... /c /link /SUBSYSTEM:CONSOLE Stop using super()._sanity_check_compile_args() to remove the duplication while keeping control of the position of the linker arguments. Note that get_always_args() was also duplicated because _get_basic_compiler_args() returns it via get_compiler_args_for_mode(), so drop it as well. The effect is to remove the copy of get_always_args() that was previously in front of the output argument, and only keep the one after the source file, but this is harmless. Fixes: mesonbuild#16111 Fixes: 797decc ("compilers: pass external args to sanity check") Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Right now they are passed twice, but this will be fixed. Add a partial test for now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Commit 300d7c3 ("compilers: add link always args if CompileCheckMode.LINK", 2026-01-07) added get_linker_always_args() to get_compiler_args_for_mode(), but that function returns *compiler* arguments, and it is applied twice to a compile check: once by CLikeCompiler._get_basic_compiler_args() and once by Compiler.compile(). For MSVC this puts linker-only flags on the compiler command line twice *and* in the wrong place: cl ... /release /nologo ... /release /nologo ... /link foo.lib Add them to the linker argument list that is passed through linker_to_compiler_args() instead of going through get_compiler_args_for_mode(). While that appears twice (in build_wrapper_args() and in the sanity check), it is not necessary anymore to add linker always args in find_library() now that build_wrapper_args() adds them. Note that this does not include the Ninja backend which has a call to get_linker_always_args() of its own. Fixes: mesonbuild#16086 Fixes: 300d7c3 ("compilers: add link always args if CompileCheckMode.LINK", 2026-01-07) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Commit decc3e assumed the sanity check goes through CompilerArgs, but it does not. Add to _sanity_check_compile_args() the missing call to DCompiler.unix_args_to_native(). Fixes: mesonbuild#16115 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Avoid a repeated get_value_for() idiom. Rust wraps the linker arguments with -Clink-arg as usual; this is a bug fix for cc.links(), cc.has_function() and friends which previously received the raw arguments. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rustc's sanity check passes no external args at all. Fix it for consistency with other languages and to ensure that failures are detected early. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Contributor
Author
|
Failures are due to CI updates, I added the corresponding 1.13 fixes to the milestone. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual backport of #16166 to avoid conflicts with commits 19bcaef and e6bb7f2.