Skip to content

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

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

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.

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.

Signed-off-by: Tristan Partin <tristan@partin.io>
Comment on lines +94 to +95
# Force clang to fail in sanity checks if an unknwon warning option is
# user
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

just some trivial typos:

Suggested change
# Force clang to fail in sanity checks if an unknwon warning option is
# user
# Force clang to fail in sanity checks if an unknown warning option is
# used

@bonzini
Copy link
Copy Markdown
Contributor

bonzini commented Apr 17, 2026

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
Copy link
Copy Markdown
Member

dcbaker commented Apr 17, 2026

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"

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.

4 participants