Skip to content

compilers: force clang to error on unknown warning options - #15714

Closed
tristan957 wants to merge 1 commit into
mesonbuild:masterfrom
tristan957:clang-unknown
Closed

compilers: force clang to error on unknown warning options#15714
tristan957 wants to merge 1 commit into
mesonbuild:masterfrom
tristan957:clang-unknown

Conversation

@tristan957

Copy link
Copy Markdown
Member

gcc seems to error by default if an unknown warning option is passed to it:

CC=gcc meson setup build -Dc_args=-Wbad

gcc will fail in the project() call during the sanity check. clang does not currently doing that:

CC=clang meson setup build -Dc_args=-Wbad
...will continue until an actual compilation like cc.compiles()

from meson-log.txt...
Sanity check compile stderr:
warning: unknown warning option '-Wbad' [-Wunknown-warning-option]

We should error in the sanity check to notify the user as soon as possible that they have errors in their environment.

Comment thread mesonbuild/compilers/mixins/clang.py Outdated
@bonzini

bonzini commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

always_args is a pretty heavy hammer. A better choice is to call get_compiler_check_args from _sanity_check_compile_args.

Also it's probably best to take the occasion and synchronize the handling of clang (which adds the arguments in get_compiler_check_args) and clang-cl (which does it in has_arguments).

@dcbaker

dcbaker commented Apr 17, 2026

Copy link
Copy Markdown
Member

I agree with bonzini, using the sanity check args makes more sense. I'm also concerned putting it in always args is going to break builds of projects that blinding add arguments on "is linux" or "is clang"

@tristan957

Copy link
Copy Markdown
Member Author

Great suggestions! Here is an update...4 months later 😆.

@tristan957

tristan957 commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

This is blocked by #16142.

@thesamesam

Copy link
Copy Markdown
Member

['Failed to import test module: unittests.internaltests\nTraceback (most recent call last):\n File "/usr/lib/python3.14/unittest/loader.py", line 433, in _find_test_path\n module = self._get_module_from_name(name)\n File "/usr/lib/python3.14/unittest/loader.py", line 374, in _get_module_from_name\n import(name)\n ~~~~~~~~~~^^^^^^\n File "/__w/meson/meson/unittests/internaltests.py", line 32\n <<<<<<< HEAD\n ^^\nSyntaxError: invalid syntax\n']

Whoops ;)

@tristan957

Copy link
Copy Markdown
Member Author

Silly...

@tristan957
tristan957 force-pushed the clang-unknown branch 2 times, most recently from 1abc513 to 290ace5 Compare August 28, 2026 16:50
gcc will error by default if an unknown warning option is passed to it:

    CC=gcc meson setup build -Dc_args=-Wbad

gcc will fail in the project() call during the sanity check. clang does
not currently doing that:

    CC=clang meson setup build -Dc_args=-Wbad
    ...will continue until an actual compilation like cc.compiles()

    from meson-log.txt...
    Sanity check compile stderr:
    warning: unknown warning option '-Wbad' [-Wunknown-warning-option]

We should error in the sanity check to notify the user as soon as
possible that they have errors in their environment.

Signed-off-by: Tristan Partin <tristan@partin.io>
@bonzini

bonzini commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Do not do change-detector tests

I agree with @thesamesam that the change is good, but can you please remove the internaltests change? Having test_sanity_check_fails_on_bad_c_args is enough, which command line arguments are needed on clang/clang-cl to achieve it is not worth being covered by a specific tests.

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.

5 participants