Skip to content

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Oct 10, 2025

Since 4feae05, most of the handling of warning options was rewritten to add such options based on hardcoded knowledge about what compilers support which options, and since which versions. This avoids a number of configure time checks, speeding up the cmake configuration.

This avoids erroneously adding this option with GCC, which doesn't really support it.

If testing for a warning option like -Wno- with GCC, GCC won't print any diagnostic at all, leading to the options being accepted incorrectly. However later, if compiling a file that actually prints another warning, GCC will also print warnings about these -Wno- options being unrecognized.

This avoids extra warning spam like this, for every source file that does produce warnings with GCC:

At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-pass-failed’ may have been intended to silence earlier diagnostics

@mstorsjo mstorsjo requested a review from nikic October 10, 2025 12:13
@llvmbot llvmbot added the cmake Build system in general and CMake in particular label Oct 10, 2025
@nikic
Copy link
Contributor

nikic commented Oct 10, 2025

This used to be how most warning options were detected in HandleLLVMOptions.cmake. However, in
4feae05, many of these checks were rewritten to avoid trying compilation and just relying on hardcoded knowledge about which compilers and versions thereof support which warnings, to speed up the cmake configuration.

Let's just do that instead. It looks like -Wpass-failed exists since Clang 3.5: https://clang.godbolt.org/z/1b879PTr8 And out minimum toolchain requirement is Clang 5.0. So I think we should just guard this by if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") and skip the compiler invocation.

@mstorsjo
Copy link
Member Author

This used to be how most warning options were detected in HandleLLVMOptions.cmake. However, in
4feae05, many of these checks were rewritten to avoid trying compilation and just relying on hardcoded knowledge about which compilers and versions thereof support which warnings, to speed up the cmake configuration.

Let's just do that instead. It looks like -Wpass-failed exists since Clang 3.5: https://clang.godbolt.org/z/1b879PTr8 And out minimum toolchain requirement is Clang 5.0. So I think we should just guard this by if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") and skip the compiler invocation.

That sounds good to me as well - I'll update this PR with that change instead.

Since 4feae05, most of the handling
of warning options was rewritten to add such options based on
hardcoded knowledge about what compilers support which options,
and since which versions. This avoids a number of configure time
checks, speeding up the cmake configuration.

This avoids erroneously adding this option with GCC, which doesn't
really support it.

If testing for a warning option like -Wno-<foo> with GCC, GCC won't
print any diagnostic at all, leading to the options being accepted
incorrectly. However later, if compiling a file that actually prints
another warning, GCC will also print warnings about these -Wno-<foo>
options being unrecognized.

This avoids extra warning spam like this, for every source file that
does produce warnings with GCC:

    At global scope:
    cc1plus: note: unrecognized command-line option ‘-Wno-pass-failed’ may have been intended to silence earlier diagnostics
@mstorsjo mstorsjo changed the title [cmake] Fix detecting -Wno-pass-failed [cmake] Unconditionally use -Wno-pass-failed with Clang Oct 10, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

@mstorsjo mstorsjo merged commit 13784f7 into llvm:main Oct 10, 2025
10 checks passed
@mstorsjo mstorsjo deleted the cmake-wno-options branch October 10, 2025 15:17
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 10, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 7 "test-build-stage1-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/16577

Here is the relevant piece of the build log for the reference
Step 7 (test-build-stage1-unified-tree-check-all) failure: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
...
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using ld.lld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/ld.lld
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using lld-link: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/lld-link
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using ld64.lld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/ld64.lld
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using wasm-ld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/wasm-ld
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/utils/lit/tests/lit.cfg:111: warning: Setting a timeout per test not supported. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.
 Some tests will be skipped and the --timeout command line argument will not work.
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using ld.lld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/ld.lld
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using lld-link: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/lld-link
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using ld64.lld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/ld64.lld
llvm-lit: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/utils/lit/lit/llvm/config.py:530: note: using wasm-ld: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/wasm-ld
command timed out: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1825.178204
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Step 12 (build-stage2-unified-tree) failure: build (failure) (timed out)
...
1295.379 [56/10/6674] Creating library symlink lib/libLTO.so
1295.484 [56/9/6675] Linking CXX executable unittests/CodeGen/CGPluginTest/CGPluginTest
1295.536 [56/8/6676] Linking CXX executable bin/clang-linker-wrapper
1295.651 [56/7/6677] Linking CXX executable bin/clang-sycl-linker
1295.746 [56/6/6678] Linking CXX executable bin/llvm-reduce
1295.876 [56/5/6679] Linking CXX executable bin/llvm-split
1296.149 [56/4/6680] Linking CXX executable unittests/CodeGen/CodeGenTests
1297.130 [56/3/6681] Linking CXX executable bin/llvm-lto
1314.469 [56/2/6682] Building CXX object tools/bugpoint-passes/CMakeFiles/BugpointPasses.dir/TestPasses.cpp.o
1314.790 [55/2/6683] Linking CXX shared module lib/BugpointPasses.so
command timed out: 1200 seconds without output running [b'ninja'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2515.701342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Build system in general and CMake in particular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants