summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2023-03-18 04:22:01 (GMT)
committerGitHub <noreply@github.com>2023-03-18 04:22:01 (GMT)
commit6b8249accb398eaeb9036610c214f4c70e542194 (patch)
tree44c1fc9827d61a94c4b050322bf582194718e21a /config
parent7c5d0a3756032a3f5f2cbbdf56b8824177584223 (diff)
downloadhdf5-6b8249accb398eaeb9036610c214f4c70e542194.zip
hdf5-6b8249accb398eaeb9036610c214f4c70e542194.tar.gz
hdf5-6b8249accb398eaeb9036610c214f4c70e542194.tar.bz2
Align compiler flags with develop (#2586)
Brings many compiler flag changes over from develop. Does NOT bring over -Werror changes. Also turns on Fortran silent rules, as in develop.
Diffstat (limited to 'config')
-rw-r--r--config/README.md88
-rw-r--r--config/clang-warnings/developer-general1
-rw-r--r--config/clang-warnings/general16
-rw-r--r--config/cmake/HDFCompilerFlags.cmake10
-rw-r--r--config/cmake/HDFFortranCompilerFlags.cmake16
-rw-r--r--config/conclude_fc.am4
-rw-r--r--config/gnu-fflags7
-rw-r--r--config/gnu-warnings/4.87
-rw-r--r--config/gnu-warnings/cxx-4.87
-rw-r--r--config/gnu-warnings/cxx-developer-4.87
-rw-r--r--config/gnu-warnings/developer-124
-rw-r--r--config/gnu-warnings/developer-4.87
-rw-r--r--config/gnu-warnings/gfort-4.81
-rw-r--r--config/gnu-warnings/gfort-developer-4.83
-rw-r--r--config/gnu-warnings/gfort-developer-5 (renamed from config/gnu-warnings/developer-gfort-5)0
-rw-r--r--config/gnu-warnings/gfort-developer-general3
-rw-r--r--config/gnu-warnings/gfort-no-developer-4.83
-rw-r--r--config/gnu-warnings/gfort-no-developer-general3
-rw-r--r--config/gnu-warnings/no-cxx-developer-4.83
-rw-r--r--config/gnu-warnings/no-developer-4.83
-rw-r--r--config/ibm-aix2
21 files changed, 157 insertions, 38 deletions
diff --git a/config/README.md b/config/README.md
new file mode 100644
index 0000000..8459b77
--- /dev/null
+++ b/config/README.md
@@ -0,0 +1,88 @@
+# The `config` directory
+
+## Intro
+
+HDF5 can be configured using both the GNU Autotools and CMake. We try to keep
+them in sync, but you can expect minor differences to crop up. Please create
+a GitHub issue for any differences noted. Note that with the Autotools, we
+do NOT check generated files into GitHub until release time, so you will
+need to generate `configure`, `Makefile.in`(s), etc. via `autogen.sh` in the
+project root if you want to build with that system.
+
+Configuration information for the HDF5 library and tools is (unfortunately)
+spread across the repository. Basic library configuration will generally
+be found in `configure.ac` (Autotools) and the root's `CMakeLists.txt` (CMake).
+Each subdirectory of the project also has its own `Makefile.am` or CMake build
+and test files.
+
+This directory contains a few important things:
+
+* Autotools OS- and compiler-specific configuration
+* CMake support files (in `cmake`)
+* Warning files shared between the two systems (in `*-warnings` directories)
+* CMake toolchain files (in `toolchain`)
+* CMake sanitizer files (in `sanitizer`)
+
+CMake will be documented elsewhere. This document focuses on the Autotools files
+and the shared warning files.
+
+## Autotools
+
+An Autotools build will first use `$host_cpu`, `$host_os`, etc. to try to find a
+suitable platform file in `config` to source and start checking compilers. The
+code that does this is in `configure.ac` (search for `host_os`). For example,
+MacOS will source the `apple` file and FreeBSD will source the `freebsd` file.
+There are a bunch of Linux files, but they all eventually invoke
+`linux-gnulibc1`.
+
+If you dig into one of these files, the way that they check for compilers is
+rather crude. Each OS script will simply source the various C, C++, and
+Fortran compiler files that are listed inside. Each compiler file checks
+the designated compiler's version output to see if there's a match, and if so,
+the flag processing proceeds, and a variable like `cc_flags_set` will be set
+at the end.
+
+In case it's not obvious, the C files end in `-flags`, C++ in `-cxxflags`, and
+Fortran in `-fflags`.
+
+When a compiler matches, the script will attempt to set the `CFLAGS`, etc.
+variables based on the platform and compiler's properties. There are typically
+a large number of flag categories (e.g., `DEBUG_OPT_CFLAGS`) that are
+conditionally appended to the canonical variables, like `AM_FLAGS`, by the
+remainder of the `configure` script.
+
+For the major compilers, like Clang and gcc, there will be a section at the
+end where we append version-specific flags, mainly for warnings. These are
+imported via a function in the script (`load_gnu_arguments()` for gcc). See
+below for more detail.
+
+## Warnings files
+
+Keeping the Autotools and CMake build files in sync has always been a bit of a
+struggle. One way that we help to ensure that the same flags are used in each
+build system is to import the warnings settings from text files that are
+maintained separately from the Autotools and CMake build files. We like to
+configure the compiler to be as crabby as possible so as to catch subtle bugs,
+so there are a LOT of warning flags for popular compilers like Clang and gcc.
+
+We've located these files in `config/*-warnings` directories. Each file
+represents a compiler version and contains the warning flags we set, one to a
+line. Lines that start with `#` are considered comment lines. You'll also see
+`developer` and `no-developer` flavors of compiler version files. The former
+corresponds to "developer flags" that are usually either only semi-useful and/or
+generate a lot of (usually unfixable) noise. The latter corresponds to things
+that we want to ensure do NOT appear in non-developer builds of the library.
+These might involve a different level setting (`-Wfoo=x`) or something that
+gets incorporated in a "conglomerate" flag like `-Wextra` so we need to set
+`-Wno-foo` in non-developer builds. Developer warnings can be turned on
+via a configure option. You will also sometimes see `error` files. Those are
+files that include warnings that will be considered errors if you have enabled
+the "warnings as errors" configure option set. Now that the library is largely
+warning-free, these are less useful than in the past as you can now just set
+-Werror directly in many cases (our configure script is smart about not running
+configure checks with -Werror).
+
+For anyone interested, we are always interested in improving both the OS and
+compiler files, so pull requests for those are always welcome, especially for
+platforms we don't have routine access to. If you are a compiler or platform
+expert/aficionado, please help us out!
diff --git a/config/clang-warnings/developer-general b/config/clang-warnings/developer-general
index 74d8404..b80552f 100644
--- a/config/clang-warnings/developer-general
+++ b/config/clang-warnings/developer-general
@@ -1,4 +1,3 @@
--Wformat-nonliteral
-Wmissing-noreturn
-Wsometimes-uninitialized
-Wswitch-enum
diff --git a/config/clang-warnings/general b/config/clang-warnings/general
index f0c9b93..433dff9 100644
--- a/config/clang-warnings/general
+++ b/config/clang-warnings/general
@@ -8,19 +8,13 @@
-Wformat=2
-Wframe-larger-than=16384
-Wimplicit-fallthrough
-#
-# NOTE: Due to the divergence in the C and C++, we're dropping support for
-# compiling the C library with a C++ compiler and dropping the -Wc++-compat
-# warning.
-#
--Wno-c++-compat
-#
-# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add
-# it to the developer flags.
-#
--Wno-format-nonliteral
-Wnull-dereference
-Wunused-const-variable
-Wwrite-strings
-Wpedantic
-Wvolatile-register-var
+# NOTE: Due to the divergence in the C and C++, we're dropping support for
+# compiling the C library with a C++ compiler and dropping the -Wc++-compat
+# warning.
+#
+-Wno-c++-compat
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index 15b158d..a9b1a42 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -267,6 +267,16 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-10")
endif ()
endif ()
+
+ # Append more extra warning flags that only gcc 12.x+ knows about
+ # or which should only be enabled for gcc 12.x+
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0)
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-12")
+ #else ()
+ # ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-12")
+ endif ()
+ endif ()
endif ()
#-----------------------------------------------------------------------------
diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake
index 599ec30..838211f 100644
--- a/config/cmake/HDFFortranCompilerFlags.cmake
+++ b/config/cmake/HDFFortranCompilerFlags.cmake
@@ -54,10 +54,6 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERS
endif ()
endif ()
-#-----------------------------------------------------------------------------
-# CDash is configured to only allow 3000 warnings, so
-# break into groups (from the config/gnu-flags file)
-#-----------------------------------------------------------------------------
if (NOT MSVC AND NOT MINGW)
# General flags
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
@@ -65,6 +61,11 @@ if (NOT MSVC AND NOT MINGW)
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f03" "-free")
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-developer-general")
+ else ()
+ ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-no-developer-general")
+ endif ()
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-fimplicit-none")
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0 AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6)
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-std=f2008ts")
@@ -82,6 +83,11 @@ if (NOT MSVC AND NOT MINGW)
# Append more extra warning flags that only gcc 4.8+ knows about
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8)
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-developer-4.8")
+ else ()
+ ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-no-developer-4.8")
+ endif ()
endif ()
# Append more extra warning flags that only gcc 4.9+ knows about
@@ -92,7 +98,7 @@ if (NOT MSVC AND NOT MINGW)
# Append more extra warning flags that only gcc 5.x+ knows about
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0)
if (HDF5_ENABLE_DEV_WARNINGS)
- ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-gfort-5")
+ ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-developer-5")
endif ()
endif ()
diff --git a/config/conclude_fc.am b/config/conclude_fc.am
index 77403cb..d26016a 100644
--- a/config/conclude_fc.am
+++ b/config/conclude_fc.am
@@ -19,12 +19,14 @@
# AM_FCCPPFLAGS, FCCPPFLAGS are currently not used.
PPFCCOMPILE = $(FC) $(FCDEFS) $(DEFAULT_INCLUDES) $(FCINCLUDES) $(AM_FCCPPFLAGS) $(FCCPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)
-LTPPFCCOMPILE = $(LIBTOOL) --tag=FC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(PPFCCOMPILE)
+LTPPFCCOMPILE = $(LIBTOOL) --silent --tag=FC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(PPFCCOMPILE)
# Treat all .f90 and .F90 files as preprocessed Fortran.
.f90.o:
+ @if $(AM_V_P); then set -x; else echo " PPFC $@"; fi; \
$(PPFCCOMPILE) -c -o $@ $<
.F90.o:
+ @if $(AM_V_P); then set -x; else echo " PPFC $@"; fi; \
$(PPFCCOMPILE) -c -o $@ $<
include $(top_srcdir)/config/conclude.am
diff --git a/config/gnu-fflags b/config/gnu-fflags
index 3096cee..b3385ec 100644
--- a/config/gnu-fflags
+++ b/config/gnu-fflags
@@ -149,6 +149,9 @@ if test "X-gfortran" = "X-$f9x_vendor"; then
H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-general)"
+ NO_DEVELOPER_WARNING_FCFLAGS="$NO_DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-no-developer-general)"
+ DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-developer-general)"
+
#############################
# Version-specific warnings #
#############################
@@ -156,13 +159,15 @@ if test "X-gfortran" = "X-$f9x_vendor"; then
# gfortran >= 4.8
if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 8; then
H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.8)"
+ DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-developer-4.8)"
+ NO_DEVELOPER_WARNING_FCFLAGS="$NO_DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-no-developer-4.8)"
fi
# gfortran 4.9 (nothing new)
# gfortran >= 5
if test $f9x_vers_major -ge 5; then
- DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments developer-gfort-5)"
+ DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments gfort-developer-5)"
fi
# gfortran >= 6
diff --git a/config/gnu-warnings/4.8 b/config/gnu-warnings/4.8
index fa678ff..8a19289 100644
--- a/config/gnu-warnings/4.8
+++ b/config/gnu-warnings/4.8
@@ -7,9 +7,6 @@
-Wpacked-bitfield-compat
-Wsync-nand
-# warning flag added for GCC >= 4.5
--Wstrict-overflow=5
-
# This warning can only be truly addressed using the gcc extension of
# using D to indicate doubles (e.g., 1.23D).
-Wno-unsuffixed-float-constants
@@ -19,10 +16,6 @@
-Wtrampolines
# warning flag added for GCC >= 4.7
-#
-# -Wstack-usage=8192 warnings need to be swept up on a branch so
-# that we can stop burdening the whole development team.
-#
-Wstack-usage=8192
# warning flag added for GCC >= 4.8
diff --git a/config/gnu-warnings/cxx-4.8 b/config/gnu-warnings/cxx-4.8
index 744ebdc..387c41e 100644
--- a/config/gnu-warnings/cxx-4.8
+++ b/config/gnu-warnings/cxx-4.8
@@ -7,18 +7,11 @@
-Wpacked-bitfield-compat
-Wsync-nand
-# warning flag added for GCC >= 4.5
--Wstrict-overflow=5
-
# warning flags added for GCC >= 4.6
-Wdouble-promotion
-Wtrampolines
# warning flag added for GCC >= 4.7
-#
-# -Wstack-usage=8192 warnings need to be swept up on a branch so
-# that we can stop burdening the whole development team.
-#
-Wstack-usage=8192
# warning flag added for GCC >= 4.8
diff --git a/config/gnu-warnings/cxx-developer-4.8 b/config/gnu-warnings/cxx-developer-4.8
index e0d975f..f5fbdad 100644
--- a/config/gnu-warnings/cxx-developer-4.8
+++ b/config/gnu-warnings/cxx-developer-4.8
@@ -1,5 +1,10 @@
-# developer warning flags added for GCC >= 4.5
+# developer warning flag added for GCC >= 4.5
#
+# strict-overflow level 5 catches a LOT of false positives, but is useful
+# for detecting overflow conditions.
+#
+-Wstrict-overflow=5
+
# developer warning flag added for GCC >= 4.6
-Wsuggest-attribute=const
diff --git a/config/gnu-warnings/developer-12 b/config/gnu-warnings/developer-12
new file mode 100644
index 0000000..0835d96
--- /dev/null
+++ b/config/gnu-warnings/developer-12
@@ -0,0 +1,4 @@
+# Enable GCC's static analyzer for GCC 12+
+# (Temporarily disabled as the analyzer currently adds significant
+# compile time overhead for a few test files like cache.c)
+# -fanalyzer
diff --git a/config/gnu-warnings/developer-4.8 b/config/gnu-warnings/developer-4.8
index bfd15a1..be7720c 100644
--- a/config/gnu-warnings/developer-4.8
+++ b/config/gnu-warnings/developer-4.8
@@ -6,6 +6,13 @@
#
-Wjump-misses-init
+# developer warning flag added for GCC >= 4.5
+#
+# strict-overflow level 5 catches a LOT of false positives, but is useful
+# for detecting overflow conditions.
+#
+-Wstrict-overflow=5
+
# developer warning flag added for GCC >= 4.6
-Wsuggest-attribute=const
diff --git a/config/gnu-warnings/gfort-4.8 b/config/gnu-warnings/gfort-4.8
index 9d880de..f986072 100644
--- a/config/gnu-warnings/gfort-4.8
+++ b/config/gnu-warnings/gfort-4.8
@@ -1,5 +1,4 @@
# warning flags added for gfortran >= 4.4
--Warray-temporaries
-Wintrinsics-std
# warning flag added for gfortran >= 4.5
diff --git a/config/gnu-warnings/gfort-developer-4.8 b/config/gnu-warnings/gfort-developer-4.8
new file mode 100644
index 0000000..20effdc
--- /dev/null
+++ b/config/gnu-warnings/gfort-developer-4.8
@@ -0,0 +1,3 @@
+# warning flags added for gfortran >= 4.4
+-Warray-temporaries
+
diff --git a/config/gnu-warnings/developer-gfort-5 b/config/gnu-warnings/gfort-developer-5
index c5d3850..c5d3850 100644
--- a/config/gnu-warnings/developer-gfort-5
+++ b/config/gnu-warnings/gfort-developer-5
diff --git a/config/gnu-warnings/gfort-developer-general b/config/gnu-warnings/gfort-developer-general
new file mode 100644
index 0000000..dde15fe
--- /dev/null
+++ b/config/gnu-warnings/gfort-developer-general
@@ -0,0 +1,3 @@
+# There is no easy way in Fortran to indicate parameters are intentionally
+# unused and many callbacks will have these, generating a lot of noise.
+-Wunused-dummy-argument
diff --git a/config/gnu-warnings/gfort-no-developer-4.8 b/config/gnu-warnings/gfort-no-developer-4.8
new file mode 100644
index 0000000..82274ef
--- /dev/null
+++ b/config/gnu-warnings/gfort-no-developer-4.8
@@ -0,0 +1,3 @@
+# warning flags added for gfortran >= 4.4
+-Wno-array-temporaries
+
diff --git a/config/gnu-warnings/gfort-no-developer-general b/config/gnu-warnings/gfort-no-developer-general
new file mode 100644
index 0000000..bfcba22
--- /dev/null
+++ b/config/gnu-warnings/gfort-no-developer-general
@@ -0,0 +1,3 @@
+# There is no easy way in Fortran to indicate parameters are intentionally
+# unused and many callbacks will have these, generating a lot of noise.
+-Wno-unused-dummy-argument
diff --git a/config/gnu-warnings/no-cxx-developer-4.8 b/config/gnu-warnings/no-cxx-developer-4.8
index 3c3de93..d4d00e3 100644
--- a/config/gnu-warnings/no-cxx-developer-4.8
+++ b/config/gnu-warnings/no-cxx-developer-4.8
@@ -1,3 +1,6 @@
+# no-developer warning flag added for GCC >= 4.5
+-Wstrict-overflow=2
+
# no-developer warning flag added for GCC >= 4.6
-Wno-suggest-attribute=const
diff --git a/config/gnu-warnings/no-developer-4.8 b/config/gnu-warnings/no-developer-4.8
index 09a9a96..412b907 100644
--- a/config/gnu-warnings/no-developer-4.8
+++ b/config/gnu-warnings/no-developer-4.8
@@ -1,5 +1,6 @@
-# no-developer warning flag added for GCC >= 4.5
+# no-developer warning flags added for GCC >= 4.5
-Wno-jump-misses-init
+-Wstrict-overflow=2
# no-developer warning flag added for GCC >= 4.6
-Wno-suggest-attribute=const
diff --git a/config/ibm-aix b/config/ibm-aix
index fb7e1df..b2f5d05 100644
--- a/config/ibm-aix
+++ b/config/ibm-aix
@@ -148,8 +148,6 @@ ac_cv_sizeof_char=${ac_cv_sizeof_char=1}
ac_cv_sizeof_short=${ac_cv_sizeof_short=2}
ac_cv_sizeof_int=${ac_cv_sizeof_int=4}
ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long=8}
-# Do not cache __int64 since it is not a standard C type and some compilers
-# (e.g., gcc) does not support it.
ac_cv_sizeof_float=${ac_cv_sizeof_float=4}
ac_cv_sizeof_double=${ac_cv_sizeof_double=8}
ac_cv_sizeof_long_double=${ac_cv_sizeof_long_double=8}