Skip to content

Stop passing link arguments to compile-only sanity checks - #16142

Closed
tristan957 wants to merge 1 commit into
mesonbuild:masterfrom
tristan957:unused-arg-warning
Closed

Stop passing link arguments to compile-only sanity checks#16142
tristan957 wants to merge 1 commit into
mesonbuild:masterfrom
tristan957:unused-arg-warning

Conversation

@tristan957

@tristan957 tristan957 commented Aug 24, 2026

Copy link
Copy Markdown
Member

There is no need to pass link-only arguments where we are only compiling. This has led to real world issues:

Clang will emit a warning when unused arguments are passed on the command line:

clang: warning: argument unused during compilation: '-L/tmp/opencode' [-Wunused-command-line-argument]

This is a bit of a hard warning to trigger. The following is required:

  1. Clang or Clang-derived compiler (clang-cl)
  2. A cross build
  3. No exe wrapper configured
  4. c_link_args is non-empty

When (2) and (3) hold, the compile mode becomes CompileCheckMode.COMPILE, which means we pass -c to clang's sanity check command. When -c is passed to clang, it ignores linker arguments like -L.

@tristan957

Copy link
Copy Markdown
Member Author

Blocker for #15714.

@tristan957

Copy link
Copy Markdown
Member Author

FWIW, I think this is kind of hacky. I would like to split this idiom where we return linker and compiler flags in one function call. I'll propose it on Matrix/IRC for a future improvement.

@thesamesam

Copy link
Copy Markdown
Member

Does this help with #16086 / #16094?

There is no need to pass link-only arguments where we are only
compiling. This has led to real world issues:

Clang will emit a warning when unused arguments are passed on the
command line:

	clang: warning: argument unused during compilation: '-L/tmp/opencode' [-Wunused-command-line-argument]

This is a bit of a hard warning to trigger. The following is required:

1. Clang or Clang-derived compiler (clang-cl)
2. A cross build
3. No exe wrapper configured
4. c_link_args is non-empty

When (2) and (3) hold, the compile mode becomes
CompileCheckMode.COMPILE, which means we pass -c to clang's sanity check
command. When -c is passed to clang, it ignores linker arguments like
-L.

Signed-off-by: Tristan Partin <tristan@partin.io>
@tristan957 tristan957 changed the title Silence clang unused-command-line-argument warning Stop passing link arguments to compile-only sanity checks Aug 27, 2026
@tristan957

Copy link
Copy Markdown
Member Author

Does this help with #16086 / #16094?

Did some analysis, and no it doesn't seem to help.

@thesamesam thesamesam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A shame but OK.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants