Skip to content

Commit 8c253e8

Browse files
committed
[cmake] Fix detecting -Wno-pass-failed
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 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. See e546bbf for an earlier fix of similar options (for LLDB).
1 parent 0dff52b commit 8c253e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,8 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
968968
# projects and may be injected by pragmas in libstdc++.
969969
# FIXME: Reconsider this choice if warnings from STL headers can be reliably
970970
# avoided (https://github.com/llvm/llvm-project/issues/157666).
971-
add_flag_if_supported("-Wno-pass-failed" NO_PASS_FAILED_FLAG)
971+
check_cxx_compiler_flag("-Wpass-failed" PASS_FAILED_FLAG)
972+
append_if(PASS_FAILED_FLAG "-Wno-pass-failed" CMAKE_CXX_FLAGS)
972973
endif (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
973974

974975
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT LLVM_ENABLE_WARNINGS)

0 commit comments

Comments
 (0)