diff options
author | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2019-08-15 13:11:50 +0000 |
---|---|---|
committer | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2019-08-15 13:11:50 +0000 |
commit | dc23c832f4f7e5ae8204acfe800bdb611525c8bd (patch) | |
tree | 108cbbeddd12c233f75eba243775b6261d9287e8 /openmp/cmake | |
parent | ed804dad1e6849c5760dee451c5ce6459632d552 (diff) | |
download | llvm-dc23c832f4f7e5ae8204acfe800bdb611525c8bd.zip llvm-dc23c832f4f7e5ae8204acfe800bdb611525c8bd.tar.gz llvm-dc23c832f4f7e5ae8204acfe800bdb611525c8bd.tar.bz2 |
[OpenMP] Turn on -Wall compiler warnings by default
Instead, maintain a list of disabled options to still build libomp and
libomptarget without warnings. This includes -Wno-error and -Wno-pedantic
to silence warnings that LLVM enables when building in-tree.
I tested the following compilers:
* Clang 6.0, 7.0, 8.0
* GCC 4.8.5 (CentOS 7), GCC 6, 7, 8, 9
* Intel Compiler 16, 17, 18, 19
RFC thread on openmp-dev mailing list:
http://lists.llvm.org/pipermail/openmp-dev/2019-August/002668.html
Differential Revision: https://reviews.llvm.org/D65867
llvm-svn: 368999
Diffstat (limited to 'openmp/cmake')
-rw-r--r-- | openmp/cmake/HandleOpenMPOptions.cmake | 19 | ||||
-rw-r--r-- | openmp/cmake/config-ix.cmake | 14 |
2 files changed, 29 insertions, 4 deletions
diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake index 97b616e..3ed046c 100644 --- a/openmp/cmake/HandleOpenMPOptions.cmake +++ b/openmp/cmake/HandleOpenMPOptions.cmake @@ -1,4 +1,4 @@ -if (${OPENMP_STANDALONE_BUILD}) +if (OPENMP_STANDALONE_BUILD) # From HandleLLVMOptions.cmake function(append_if condition value) if (${condition}) @@ -9,10 +9,25 @@ if (${OPENMP_STANDALONE_BUILD}) endfunction() endif() -if (${OPENMP_ENABLE_WERROR}) +# MSVC and clang-cl in compatibility mode map -Wall to -Weverything. +# TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes. +if (NOT MSVC) + append_if(OPENMP_HAVE_WALL_FLAG "-Wall" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +endif() +if (OPENMP_ENABLE_WERROR) append_if(OPENMP_HAVE_WERROR_FLAG "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() +# Additional warnings that are not enabled by -Wall. +append_if(OPENMP_HAVE_WCAST_QUAL_FLAG "-Wcast-qual" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +append_if(OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG "-Wformat-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +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_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) + append_if(OPENMP_HAVE_STD_GNUPP11_FLAG "-std=gnu++11" CMAKE_CXX_FLAGS) if (NOT OPENMP_HAVE_STD_GNUPP11_FLAG) append_if(OPENMP_HAVE_STD_CPP11_FLAG "-std=c++11" CMAKE_CXX_FLAGS) diff --git a/openmp/cmake/config-ix.cmake b/openmp/cmake/config-ix.cmake index 13eace9..8858bc6 100644 --- a/openmp/cmake/config-ix.cmake +++ b/openmp/cmake/config-ix.cmake @@ -1,7 +1,17 @@ -include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) -check_c_compiler_flag(-Werror OPENMP_HAVE_WERROR_FLAG) +check_cxx_compiler_flag(-Wall OPENMP_HAVE_WALL_FLAG) +check_cxx_compiler_flag(-Werror OPENMP_HAVE_WERROR_FLAG) + +# Additional warnings that are not enabled by -Wall. +check_cxx_compiler_flag(-Wcast-qual OPENMP_HAVE_WCAST_QUAL_FLAG) +check_cxx_compiler_flag(-Wformat-pedantic OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG) +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-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) check_cxx_compiler_flag(-std=gnu++11 OPENMP_HAVE_STD_GNUPP11_FLAG) check_cxx_compiler_flag(-std=c++11 OPENMP_HAVE_STD_CPP11_FLAG) |