Skip to content

compilers: keep MSVC linker flags out of checks - #16094

Closed
tianrking wants to merge 1 commit into
mesonbuild:masterfrom
tianrking:fix/msvc-linker-check-args
Closed

compilers: keep MSVC linker flags out of checks#16094
tianrking wants to merge 1 commit into
mesonbuild:masterfrom
tianrking:fix/msvc-linker-check-args

Conversation

@tianrking

Copy link
Copy Markdown

Compiler.get_compiler_args_for_mode() started including the dynamic linker's always-arguments in 1.11. For MSVC builds, normal targets invoke link.exe separately, but compiler checks link through cl.exe. This placed linker-only options such as /release before /link, where cl.exe rejects them with D8043.

Keep link-mode compiler-check arguments limited to the MSVC compiler's own always-arguments. The regular link step still receives the dynamic linker's always-arguments through the backend.

The regression test uses the real MSVCDynamicLinker and verifies that link-mode compiler arguments do not contain its /release option.

Fixes #16086

Tests:

  • python run_unittests.py InternalTests.test_compiler_args_class_visualstudio
  • python run_mypy.py mesonbuild/compilers/mixins/visualstudio.py
  • git diff --check

@tristan957

Copy link
Copy Markdown
Member

Is there an integration test we can add for this? We have Windows-based CI already

@bonzini

bonzini commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Touching get_compiler_args_for_mode is scary. The problem is the duplicate flags between super()._sanity_check_compile_args and self._get_basic_compiler_args() - let's just stop calling the former. I'll open a PR for both issues.

@bonzini bonzini closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSVC: /release linker flag leaks into cl.exe command line in has_function() tests (regression in 1.11)

3 participants