From 9d766c6a90df3f4dc7581ca52e946a7af839f853 Mon Sep 17 00:00:00 2001 From: "Samuel E. Browne" Date: Thu, 2 Jan 2025 11:12:43 -0700 Subject: [PATCH 1/2] Set all currently-clean GCC warnings to promoted I looped over a (theoretically) complete list of warnings that are supported by GCC 10 and checked which of them do not occur anywhere in Trilinos (non-deprecated packages only). Promote all clean warnings to have the cleanest compile output currently possible and prevent introducing any of these warnings in the future. Signed-off-by: Samuel E. Browne --- RELEASE_NOTES | 1 + cmake/ProjectCompilerPostConfig.cmake | 31 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 4dc910bc563f..d3fdf4b3c33c 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -45,6 +45,7 @@ Framework if either of these modes are enabled, all warnings are disabled for any deprecated packages, in the interest of not spending effort cleaning them. By default, no warnings or errors are added. + - Set all currently-clean GCC 10 warnings as 'promoted'. ############################################################################### diff --git a/cmake/ProjectCompilerPostConfig.cmake b/cmake/ProjectCompilerPostConfig.cmake index 1cdedd56a667..4408ccb9221d 100644 --- a/cmake/ProjectCompilerPostConfig.cmake +++ b/cmake/ProjectCompilerPostConfig.cmake @@ -1,5 +1,6 @@ tribits_get_package_enable_status(Kokkos KokkosEnable "") + macro(disable_warnings_for_deprecated_packages) message(STATUS "Disabling all warnings/errors for deprecated packages") foreach(package ${DEPRECATED_PACKAGES}) @@ -43,7 +44,33 @@ IF (KokkosEnable) ENDIF() set(upcoming_warnings shadow ${Trilinos_ADDITIONAL_WARNINGS}) -set(promoted_warnings parentheses sign-compare unused-variable reorder uninitialized) +set(promoted_warnings + address + aggressive-loop-optimizations + builtin-declaration-mismatch + cast-align + deprecated-declarations + div-by-zero + format-extra-args + format + format-zero-length + init-self + int-to-pointer-cast + parentheses + reorder + return-type + sequence-point + sign-compare + strict-aliasing + type-limits + uninitialized + unused-function + unused-label + unused-value + unused-variable + variadic-macros + write-strings +) if("${Trilinos_WARNINGS_MODE}" STREQUAL "WARN") enable_warnings("${upcoming_warnings}") @@ -52,4 +79,4 @@ if("${Trilinos_WARNINGS_MODE}" STREQUAL "WARN") elseif("${Trilinos_WARNINGS_MODE}" STREQUAL "ERROR") enable_errors("${promoted_warnings};${upcoming_warnings}") disable_warnings_for_deprecated_packages() -endif() +endif() \ No newline at end of file From efa60aeb1ace18b595abfa2300fbf0bed68d2958 Mon Sep 17 00:00:00 2001 From: "Samuel E. Browne" Date: Thu, 2 Jan 2025 15:01:10 -0700 Subject: [PATCH 2/2] Remove -W options from config-specs in favor of build system If we're enabling a warning in the PostCompilerConfig.cmake file, it makes no sense to disable it in config-specs.ini. So stop doing that. But some of them are needed, and we likely want them, so do our best to keep them disabled if need be (and do it in the build system so that people not using GenConfig can benefit as well). Signed-off-by: Samuel E. Browne --- cmake/ProjectCompilerPostConfig.cmake | 22 ++++++++++++++++--- packages/framework/ini-files/config-specs.ini | 12 +++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cmake/ProjectCompilerPostConfig.cmake b/cmake/ProjectCompilerPostConfig.cmake index 4408ccb9221d..0b73eba8f904 100644 --- a/cmake/ProjectCompilerPostConfig.cmake +++ b/cmake/ProjectCompilerPostConfig.cmake @@ -17,6 +17,14 @@ macro(enable_warnings warnings) endmacro() +macro(disable_warnings warnings) + message(STATUS "Trilinos warnings disabled: ${warnings}") + foreach(warning ${warnings}) + set(CMAKE_CXX_FLAGS "-Wno-${warning} ${CMAKE_CXX_FLAGS}") + endforeach() +endmacro() + + macro(enable_errors errors) message(STATUS "Trilinos warnings-as-errors enabled: ${errors}") foreach(error ${errors}) @@ -43,13 +51,19 @@ IF (KokkosEnable) # being treated as an internal package. ENDIF() -set(upcoming_warnings shadow ${Trilinos_ADDITIONAL_WARNINGS}) +set(explicitly_disabled_warnings + deprecated-declarations + inline +) +set(upcoming_warnings + shadow + ${Trilinos_ADDITIONAL_WARNINGS} +) set(promoted_warnings address aggressive-loop-optimizations builtin-declaration-mismatch cast-align - deprecated-declarations div-by-zero format-extra-args format @@ -79,4 +93,6 @@ if("${Trilinos_WARNINGS_MODE}" STREQUAL "WARN") elseif("${Trilinos_WARNINGS_MODE}" STREQUAL "ERROR") enable_errors("${promoted_warnings};${upcoming_warnings}") disable_warnings_for_deprecated_packages() -endif() \ No newline at end of file +endif() + +disable_warnings("${explicitly_disabled_warnings}") diff --git a/packages/framework/ini-files/config-specs.ini b/packages/framework/ini-files/config-specs.ini index e6fd483513dc..d7e4d008440a 100644 --- a/packages/framework/ini-files/config-specs.ini +++ b/packages/framework/ini-files/config-specs.ini @@ -1603,7 +1603,7 @@ opt-set-cmake-var TPL_ENABLE_Scotch BOOL FORCE : OFF opt-set-cmake-var TPL_Netcdf_LIBRARIES STRING FORCE : ${NETCDF_C_LIB|ENV}/libnetcdf.so opt-set-cmake-var Trilinos_ENABLE_Fortran OFF BOOL : OFF -opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-nonnull-compare -Wno-address -Wno-inline -Wno-unused-label +opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-nonnull-compare [rhel8_sems-gnu-8.5.0-serial_release-debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] use rhel8_sems-gnu-8.5.0-serial_release-debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables @@ -1636,7 +1636,7 @@ use SPACK_NETLIB_BLAS_LAPACK opt-set-cmake-var MPI_EXEC_PRE_NUMPROCS_FLAGS STRING : --bind-to;none --mca btl vader,self opt-set-cmake-var CMAKE_CXX_EXTENSIONS BOOL : OFF opt-set-cmake-var Teko_DISABLE_LSCSTABALIZED_TPETRA_ALPAH_INV_D BOOL : ON -opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -fno-strict-aliasing -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-inline -Wno-nonnull-compare -Wno-address +opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -fno-strict-aliasing -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-nonnull-compare opt-set-cmake-var TPL_HDF5_LIBRARIES STRING : ${HDF5_LIB|ENV}/libhdf5_hl.so;${HDF5_LIB|ENV}/libhdf5.so;${ZLIB_LIB|ENV}/libz.so;-ldl @@ -1672,7 +1672,7 @@ opt-set-cmake-var ROL_example_PDE-OPT_helmholtz_example_02_MPI_1_DISABLE BOOL opt-set-cmake-var Pliris_vector_random_MPI_3_DISABLE BOOL : ON opt-set-cmake-var Pliris_vector_random_MPI_4_DISABLE BOOL : ON -opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare -Wno-address -Wno-inline +opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare # Test failures as of 11-28-22 opt-set-cmake-var ROL_example_PDE-OPT_navier-stokes_example_01_MPI_4_DISABLE BOOL : ON @@ -1766,7 +1766,7 @@ use PACKAGE-ENABLES|NO-PACKAGE-ENABLES use COMMON_SPACK_TPLS opt-set-cmake-var MPI_EXEC_PRE_NUMPROCS_FLAGS STRING : --bind-to;none --mca btl vader,self -opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare -Wno-address -Wno-inline +opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare opt-set-cmake-var TPL_ENABLE_SuperLUDist BOOL FORCE : ON opt-set-cmake-var TPL_ENABLE_ParMETIS BOOL FORCE : ON @@ -1814,7 +1814,7 @@ use PACKAGE-ENABLES|NO-PACKAGE-ENABLES use COMMON_SPACK_TPLS -opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-nonnull-compare -Wno-address -Wno-inline -Wno-unused-but-set-variable -Wno-unused-label +opt-set-cmake-var CMAKE_CXX_FLAGS STRING : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-nonnull-compare -Wno-unused-but-set-variable opt-set-cmake-var TPL_Netcdf_LIBRARIES STRING FORCE : "" @@ -1853,7 +1853,7 @@ opt-set-cmake-var ROL_example_PDE-OPT_helmholtz_example_02_MPI_1_DISABLE BOO opt-set-cmake-var ROL_example_PDE-OPT_navier-stokes_example_01_MPI_4_DISABLE BOOL : ON opt-set-cmake-var Pliris_vector_random_MPI_3_DISABLE BOOL : ON opt-set-cmake-var Pliris_vector_random_MPI_4_DISABLE BOOL : ON -opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-deprecated-declarations -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare -Wno-address -Wno-inline +opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : -Wall -Wno-clobbered -Wno-vla -Wno-pragmas -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-misleading-indentation -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-nonnull-compare opt-set-cmake-var TPL_ENABLE_SuperLUDist BOOL FORCE: OFF