summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-02-11 20:51:38 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-02-11 20:51:38 (GMT)
commit702f719e0c6771c8eb56d63566d20b3cef961f2c (patch)
tree5e879b35c08dcb0f6b50cb1c457cb6fac0083d26 /config
parent84c4ade7146b9a0f43ba22e4263bef7e56700c4d (diff)
downloadhdf5-702f719e0c6771c8eb56d63566d20b3cef961f2c.zip
hdf5-702f719e0c6771c8eb56d63566d20b3cef961f2c.tar.gz
hdf5-702f719e0c6771c8eb56d63566d20b3cef961f2c.tar.bz2
HDFFV-11012, sanitize, warnings and tools ids
Diffstat (limited to 'config')
-rw-r--r--config/cmake/CTestCustom.cmake1
-rw-r--r--config/cmake/HDFCompilerFlags.cmake47
-rw-r--r--config/cmake/hdf5-config.cmake.in3
-rw-r--r--config/gnu-flags30
-rw-r--r--config/gnu-warnings-developer-general8
-rw-r--r--config/gnu-warnings-general32
-rw-r--r--config/gnu-warnings-no-developer-general4
-rw-r--r--config/intel-flags22
-rw-r--r--config/intel-warnings-general10
9 files changed, 137 insertions, 20 deletions
diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake
index b2bf755..142d6a6 100644
--- a/config/cmake/CTestCustom.cmake
+++ b/config/cmake/CTestCustom.cmake
@@ -25,6 +25,7 @@ set (CTEST_CUSTOM_WARNING_EXCEPTION
"H5Tconv.c[0-9 \t:]*warning:[ \t]*comparison is always false due to limited range of data type"
"H5Ztrans.c.[0-9]+.[ \t]*:[ \t]*warning C4244"
"src.ZLIB.*:[ \t]*warning"
+ "warning LNK4197:.*ZLIB-prefix"
"src.SZIP.*:[ \t]*warning"
"POSIX name for this item is deprecated"
"disabling jobserver mode"
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index adace89..100ada3 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -12,6 +12,24 @@
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
+macro (ADD_H5_FLAGS h5_flag_var infile)
+ file (STRINGS ${infile} TEST_FLAG_STREAM)
+ #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}")
+ list (LENGTH TEST_FLAG_STREAM len_flag)
+ if (len_flag GREATER 0)
+ math (EXPR _FP_LEN "${len_flag} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET TEST_FLAG_STREAM ${line} str_flag)
+ string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}")
+ #message (STATUS "str_flag=${str_flag}")
+ if (str_flag)
+ set (${h5_flag_var} "${${h5_flag_var}} ${str_flag}")
+ endif ()
+ endforeach ()
+ endif ()
+ #message (STATUS "h5_flag_var=${${h5_flag_var}}")
+endmacro ()
+
message (STATUS "Warnings Configuration:")
set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}")
#-----------------------------------------------------------------------------
@@ -95,7 +113,9 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
# NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
# warnings that are emitted. If you need it, add it at configure time.
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcheck -Wall")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/intel-warnings-general")
+ message (STATUS "CMAKE_C_FLAGS_GENERAL=${CMAKE_C_FLAGS_GENERAL}")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_GENERAL}")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wreturn-type -Wstrict-prototypes -Wuninitialized")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunknown-pragmas -Wunused-function -Wunused-variable")
@@ -106,16 +126,19 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wsign-compare -Wtrigraphs -Wwrite-strings")
endif()
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wc++-compat -Wcast-align")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-general")
+ message (STATUS "CMAKE_C_FLAGS_GENERAL=${CMAKE_C_FLAGS_GENERAL}")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_GENERAL}")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wcast-align")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wdeclaration-after-statement -Wdisabled-optimization")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-declarations")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunused-macros -Wunsafe-loop-optimizations")
# gcc automatically inlines based on the optimization level
# this is just a failsafe
set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
+ message (STATUS "H5_CFLAGS0=${H5_CFLAGS0}")
endif ()
endif ()
@@ -129,11 +152,13 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Wreorder -Wport -Wstrict-aliasing")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-developer-general")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_DEV_GENERAL}")
endif ()
else ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-no-developer-general")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_NO_DEV_GENERAL}")
endif ()
endif ()
@@ -200,7 +225,7 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
# Append more extra warning flags that only gcc 7.x+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wrestrict")
+ set (H5_CFLAGS4 "${H5_CFLAGS4} -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict")
endif ()
# Append more extra warning flags that only gcc 8.x+ know about
diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in
index 6514fee..beb3b56 100644
--- a/config/cmake/hdf5-config.cmake.in
+++ b/config/cmake/hdf5-config.cmake.in
@@ -37,6 +37,7 @@ set (${HDF5_PACKAGE_NAME}_ENABLE_F2003 @HDF5_ENABLE_F2003@)
set (${HDF5_PACKAGE_NAME}_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@)
set (${HDF5_PACKAGE_NAME}_BUILD_TOOLS @HDF5_BUILD_TOOLS@)
set (${HDF5_PACKAGE_NAME}_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@)
+set (${HDF5_PACKAGE_NAME}_ENABLE_THREADSAFE @HDF5_ENABLE_THREADSAFE@)
set (${HDF5_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT @HDF5_ENABLE_Z_LIB_SUPPORT@)
set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT @HDF5_ENABLE_SZIP_SUPPORT@)
set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_ENCODING @HDF5_ENABLE_SZIP_ENCODING@)
@@ -44,7 +45,9 @@ set (${HDF5_PACKAGE_NAME}_BUILD_SHARED_LIBS @H5_ENABLE_SHARED_LIB@)
set (${HDF5_PACKAGE_NAME}_BUILD_STATIC_LIBS @H5_ENABLE_STATIC_LIB@)
set (${HDF5_PACKAGE_NAME}_PACKAGE_EXTLIBS @HDF5_PACKAGE_EXTLIBS@)
set (${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES @HDF5_LIBRARIES_TO_EXPORT@)
+set (${HDF5_PACKAGE_NAME}_ARCHITECTURE "@CMAKE_GENERATOR_ARCHITECTURE@")
set (${HDF5_PACKAGE_NAME}_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
+set (${HDF5_PACKAGE_NAME}_DEFAULT_API_VERSION "@DEFAULT_API_VERSION@")
#-----------------------------------------------------------------------------
# Dependencies
diff --git a/config/gnu-flags b/config/gnu-flags
index 008e819..c73ec21 100644
--- a/config/gnu-flags
+++ b/config/gnu-flags
@@ -1,4 +1,4 @@
-# -*- shell-script -*-
+# -*- shell-script -*-
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
@@ -14,16 +14,31 @@
# This file should be sourced into configure if the compiler is the
# GNU gcc compiler or a derivative. It is careful not to do anything
-# if the compiler is not GNU; otherwise `cc_flags_set' is set to `yes'
+# if the compiler is not GNU; otherwise 'cc_flags_set' is set to 'yes'
#
+#
+# Prepend `$srcdir/config/gnu-` to the filename suffix(es) given as
+# subroutine argument(s), remove comments starting with # and ending
+# at EOL, replace spans of whitespace (including newlines) with spaces,
+# and re-emit the file(s) thus filtered on the standard output stream.
+#
+load_gcc_arguments()
+{
+ set -- $(for arg; do
+ sed 's,#.*$,,' $srcdir/config/gnu-${arg}
+ done)
+ IFS=' ' echo "$*"
+}
+
+
# Get the compiler version in a way that works for gcc
# unless a compiler version is already known
#
# cc_vendor: The compiler name: gcc
# cc_version: Version number: 2.91.60, 2.7.2.1
#
-if test X = "X$cc_flags_set"; then
+if test "X-" = "X-$cc_flags_set"; then
# PathScale compiler spits out gcc version string too. Need to
# filter it out.
# icc beginning with version 12 includes a "gcc version compatiblilty"
@@ -37,13 +52,13 @@ if test X = "X$cc_flags_set"; then
cc_vendor=`echo $cc_version |sed 's/\([a-z]*\).*/\1/'`
cc_version=`echo $cc_version |sed 's/[-a-z]//g'`
if test X = "X$cc_vendor" -a X != "X$cc_version"; then
- cc_vendor=gcc
+ cc_vendor=gcc
fi
if test "-" != "$cc_vendor-$cc_version"; then
- echo "compiler '$CC' is GNU $cc_vendor-$cc_version"
+ echo "compiler '$CC' is GNU $cc_vendor-$cc_version"
fi
- # Some version numbers
+ # Get the compiler version numbers
cc_vers_major=`echo $cc_version | cut -f1 -d.`
cc_vers_minor=`echo $cc_version | cut -f2 -d.`
cc_vers_patch=`echo $cc_version | cut -f3 -d.`
@@ -92,7 +107,8 @@ case "$cc_vendor-$cc_version" in
esac
# General
- H5_CFLAGS="$H5_CFLAGS $arch -std=c99 -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline"
+ H5_CFLAGS="$H5_CFLAGS $arch -std=c99"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments warnings-general)"
# Production
case "$cc_vendor-$cc_version" in
diff --git a/config/gnu-warnings-developer-general b/config/gnu-warnings-developer-general
new file mode 100644
index 0000000..698f0e0
--- /dev/null
+++ b/config/gnu-warnings-developer-general
@@ -0,0 +1,8 @@
+# (suggestions from gcc, not code problems)
+# NOTE: -Wformat-nonliteral added back in here (from being disabled in
+# H5_CFLAGS)
+-Waggregate-return
+-Wformat-nonliteral
+-Winline
+-Wmissing-format-attribute
+-Wmissing-noreturn
diff --git a/config/gnu-warnings-general b/config/gnu-warnings-general
new file mode 100644
index 0000000..9e67b71
--- /dev/null
+++ b/config/gnu-warnings-general
@@ -0,0 +1,32 @@
+# Note that some of the flags listed here really should be developer
+# flags (listed in separate files, gnu-warnings-developer*) but we put
+# them here because they are not raised by the current code and we'd like to
+# know if they do start showing up.
+#
+# NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
+# warnings that are emitted. If you need it, add it from the
+# environment variable at configure time.
+-Wall
+-Wcast-qual
+-Wconversion
+-Wextra
+-Wfloat-equal
+-Wformat=2
+-Winit-self
+-Winvalid-pch
+-Wmissing-include-dirs
+#
+# 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
+-Wshadow
+-Wundef
+-Wwrite-strings
+-pedantic \ No newline at end of file
diff --git a/config/gnu-warnings-no-developer-general b/config/gnu-warnings-no-developer-general
new file mode 100644
index 0000000..85dc0a3
--- /dev/null
+++ b/config/gnu-warnings-no-developer-general
@@ -0,0 +1,4 @@
+-Wno-aggregate-return
+-Wno-inline
+-Wno-missing-format-attribute
+-Wno-missing-noreturn
diff --git a/config/intel-flags b/config/intel-flags
index af6b955..139ea49 100644
--- a/config/intel-flags
+++ b/config/intel-flags
@@ -1,4 +1,4 @@
-# -*- shell-script -*-
+# -*- shell-script -*-
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
@@ -17,6 +17,20 @@
# if the compiler is not Intel; otherwise `cc_flags_set' is set to `yes'
#
+#
+# Prepend `$srcdir/config/intel-` to the filename suffix(es) given as
+# subroutine argument(s), remove comments starting with # and ending
+# at EOL, replace spans of whitespace (including newlines) with spaces,
+# and re-emit the file(s) thus filtered on the standard output stream.
+#
+load_intel_arguments()
+{
+ set -- $(for arg; do
+ sed 's,#.*$,,' $srcdir/config/intel-${arg}
+ done)
+ IFS=' ' echo "$*"
+}
+
# Get the compiler version in a way that works for icc
# icc unless a compiler version is already known
#
@@ -66,7 +80,8 @@ if test "X-icc" = "X-$cc_vendor"; then
# General
# Default to C99 standard.
- H5_CFLAGS="${H5_CFLAGS:--std=c99 $arch}"
+ H5_CFLAGS="$H5_CFLAGS $arch -std=c99"
+ H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments warnings-general)"
# Production is set to default; see settings for specific version further down
PROD_CFLAGS="-O"
@@ -92,6 +107,9 @@ fi
# the information from the previous version and adding modifications to that.
# The default at the bottom will apply if no earlier version matches.
case "$cc_vendor-$cc_version" in
+ icc-1[5-6]*)
+ H5_CFLAGS="$H5_CFLAGS -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wformat-security -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith -Wreturn-type -Wshadow -Wstrict-prototypes -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-variable -Wwrite-strings"
+ ;;
icc-10*)
PROD_CFLAGS="-O1 -Wl,-s"
;;
diff --git a/config/intel-warnings-general b/config/intel-warnings-general
new file mode 100644
index 0000000..f4ed24c
--- /dev/null
+++ b/config/intel-warnings-general
@@ -0,0 +1,10 @@
+# Note that some of the flags listed here really should be developer
+# flags (listed in separate files, gnu-warnings-developer*) but we put
+# them here because they are not raised by the current code and we'd like to
+# know if they do start showing up.
+#
+# NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
+# warnings that are emitted. If you need it, add it from the
+# environment variable at configure time.
+-Wall
+-Wcheck \ No newline at end of file