diff options
author | Martin Storsjö <martin@martin.st> | 2022-12-13 11:39:27 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2022-12-14 14:19:03 +0200 |
commit | 93c011eebbbb03ea5b7aa18b02870595d079fc8a (patch) | |
tree | 8a3f6aed2746d6a61bec93e6d577d1af2c59be22 /openmp/cmake | |
parent | 10d34f5538e0d231a172608bdb7d08824771c7c7 (diff) | |
download | llvm-93c011eebbbb03ea5b7aa18b02870595d079fc8a.zip llvm-93c011eebbbb03ea5b7aa18b02870595d079fc8a.tar.gz llvm-93c011eebbbb03ea5b7aa18b02870595d079fc8a.tar.bz2 |
[OpenMP] Fix detecting warning options for GCC
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 warning spam like this, for every OpenMP source file that
produces build warnings with GCC:
cc1plus: warning: unrecognized command line option ‘-Wno-int-to-void-pointer-cast’
cc1plus: warning: unrecognized command line option ‘-Wno-return-type-c-linkage’
cc1plus: warning: unrecognized command line option ‘-Wno-covered-switch-default’
cc1plus: warning: unrecognized command line option ‘-Wno-enum-constexpr-conversion’
This matches how such warning options are detected and added in
llvm/cmake/modules/HandleLLVMOptions.cmake, e.g. like this:
check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)
This also matches how LLDB warning options were restructured for
GCC compatibility in e546bbfda0ab91cf78c096d8c035851cc7c3b9f3.
Differential Revision: https://reviews.llvm.org/D139922
Diffstat (limited to 'openmp/cmake')
-rw-r--r-- | openmp/cmake/HandleOpenMPOptions.cmake | 14 | ||||
-rw-r--r-- | openmp/cmake/config-ix.cmake | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake index e0a9e0d..53a2d05 100644 --- a/openmp/cmake/HandleOpenMPOptions.cmake +++ b/openmp/cmake/HandleOpenMPOptions.cmake @@ -25,9 +25,15 @@ append_if(OPENMP_HAVE_WIMPLICIT_FALLTHROUGH_FLAG "-Wimplicit-fallthrough" CMAKE_ append_if(OPENMP_HAVE_WSIGN_COMPARE_FLAG "-Wsign-compare" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) # Warnings that we want to disable because they are too verbose or fragile. -append_if(OPENMP_HAVE_WNO_ENUM_CONSTEXPR_CONVERSION_FLAG "-Wno-enum-constexpr-conversion" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) -append_if(OPENMP_HAVE_WNO_EXTRA_FLAG "-Wno-extra" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) -append_if(OPENMP_HAVE_WNO_PEDANTIC_FLAG "-Wno-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) -append_if(OPENMP_HAVE_WNO_MAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + +# GCC silently accepts any -Wno-<foo> option, but warns about those options +# being unrecognized only if the compilation triggers other warnings to be +# printed. Therefore, check for whether the compiler supports options in the +# form -W<foo>, and if supported, add the corresponding -Wno-<foo> option. + +append_if(OPENMP_HAVE_WENUM_CONSTEXPR_CONVERSION_FLAG "-Wno-enum-constexpr-conversion" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +append_if(OPENMP_HAVE_WEXTRA_FLAG "-Wno-extra" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +append_if(OPENMP_HAVE_WPEDANTIC_FLAG "-Wno-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +append_if(OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) append_if(OPENMP_HAVE_STD_CPP17_FLAG "-std=c++17" CMAKE_CXX_FLAGS) diff --git a/openmp/cmake/config-ix.cmake b/openmp/cmake/config-ix.cmake index d88ea9f..857cfe5 100644 --- a/openmp/cmake/config-ix.cmake +++ b/openmp/cmake/config-ix.cmake @@ -26,9 +26,15 @@ check_cxx_compiler_flag(-Wimplicit-fallthrough OPENMP_HAVE_WIMPLICIT_FALLTHROUGH check_cxx_compiler_flag(-Wsign-compare OPENMP_HAVE_WSIGN_COMPARE_FLAG) # Warnings that we want to disable because they are too verbose or fragile. -check_cxx_compiler_flag(-Wno-enum-constexpr-conversion OPENMP_HAVE_WNO_ENUM_CONSTEXPR_CONVERSION_FLAG) -check_cxx_compiler_flag(-Wno-extra OPENMP_HAVE_WNO_EXTRA_FLAG) -check_cxx_compiler_flag(-Wno-pedantic OPENMP_HAVE_WNO_PEDANTIC_FLAG) -check_cxx_compiler_flag(-Wno-maybe-uninitialized OPENMP_HAVE_WNO_MAYBE_UNINITIALIZED_FLAG) + +# GCC silently accepts any -Wno-<foo> option, but warns about those options +# being unrecognized only if the compilation triggers other warnings to be +# printed. Therefore, check for whether the compiler supports options in the +# form -W<foo>, and if supported, add the corresponding -Wno-<foo> option. + +check_cxx_compiler_flag(-Wenum-constexpr-conversion OPENMP_HAVE_WENUM_CONSTEXPR_CONVERSION_FLAG) +check_cxx_compiler_flag(-Wextra OPENMP_HAVE_WEXTRA_FLAG) +check_cxx_compiler_flag(-Wpedantic OPENMP_HAVE_WPEDANTIC_FLAG) +check_cxx_compiler_flag(-Wmaybe-uninitialized OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG) check_cxx_compiler_flag(-std=c++17 OPENMP_HAVE_STD_CPP17_FLAG) |