Skip to content

Commit 13784f7

Browse files
authored
[cmake] Unconditionally use -Wno-pass-failed with Clang (#162835)
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
1 parent 31d2602 commit 13784f7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,15 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
948948
# Enable -Wstring-conversion to catch misuse of string literals.
949949
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
950950
append("-Wstring-conversion" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
951+
952+
# Disable -Wno-pass-failed flag, which reports failure to perform
953+
# optimizations suggested by pragmas. This warning is not relevant for LLVM
954+
# projects and may be injected by pragmas in libstdc++.
955+
# FIXME: Reconsider this choice if warnings from STL headers can be reliably
956+
# avoided (https://github.com/llvm/llvm-project/issues/157666).
957+
# This option has been available since Clang 3.5, and we do require a newer
958+
# version.
959+
append("-Wno-pass-failed" CMAKE_CXX_FLAGS)
951960
endif()
952961

953962
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -962,13 +971,6 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
962971

963972
# Enable -Wctad-maybe-unsupported to catch unintended use of CTAD.
964973
add_flag_if_supported("-Wctad-maybe-unsupported" CTAD_MAYBE_UNSPPORTED_FLAG)
965-
966-
# Disable -Wno-pass-failed flag, which reports failure to perform
967-
# optimizations suggested by pragmas. This warning is not relevant for LLVM
968-
# projects and may be injected by pragmas in libstdc++.
969-
# FIXME: Reconsider this choice if warnings from STL headers can be reliably
970-
# avoided (https://github.com/llvm/llvm-project/issues/157666).
971-
add_flag_if_supported("-Wno-pass-failed" NO_PASS_FAILED_FLAG)
972974
endif (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
973975

974976
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT LLVM_ENABLE_WARNINGS)

0 commit comments

Comments
 (0)