summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-01-17 19:13:36 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-01-17 19:14:06 (GMT)
commitcf84882b3c23139f2f9b1edd60f0785d3c522a14 (patch)
treecea1e2b106b6acc5753bd80b8dc85e195b91c4fc /config
parent5fadf221baee915b74918c37c1ab34b24975be87 (diff)
downloadhdf5-cf84882b3c23139f2f9b1edd60f0785d3c522a14.zip
hdf5-cf84882b3c23139f2f9b1edd60f0785d3c522a14.tar.gz
hdf5-cf84882b3c23139f2f9b1edd60f0785d3c522a14.tar.bz2
Create common build system files for warnings
Diffstat (limited to 'config')
-rw-r--r--config/cmake/HDFCompilerFlags.cmake45
-rw-r--r--config/gnu-flags46
-rw-r--r--config/gnu-warnings-developer-general14
-rw-r--r--config/gnu-warnings-general32
-rw-r--r--config/gnu-warnings-no-developer-general4
-rw-r--r--config/intel-flags19
-rw-r--r--config/intel-warnings-general10
7 files changed, 143 insertions, 27 deletions
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index c803384..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 -Wno-c++-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 ()
diff --git a/config/gnu-flags b/config/gnu-flags
index a5f3258..f23ad68 100644
--- a/config/gnu-flags
+++ b/config/gnu-flags
@@ -17,6 +17,21 @@
# 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
#
@@ -138,7 +153,7 @@ if test "X-gcc" = "X-$cc_vendor"; then
################
# Optimization #
################
-
+
if test $cc_vers_major -le 4; then
HIGH_OPT_CFLAGS="-O3"
DEBUG_OPT_CFLAGS=
@@ -171,12 +186,13 @@ if test "X-gcc" = "X-$cc_vendor"; then
# 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.
- H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra -Wbad-function-cast -Wno-c++-compat -Wcast-align"
- H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal"
- H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments warnings-general)"
+ H5_CFLAGS="$H5_CFLAGS -Wbad-function-cast -Wcast-align"
+ H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wdisabled-optimization"
+ H5_CFLAGS="$H5_CFLAGS -Wmissing-declarations"
H5_CFLAGS="$H5_CFLAGS -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked"
- H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-enum -Wswitch-default"
- H5_CFLAGS="$H5_CFLAGS -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings"
+ H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default"
+ H5_CFLAGS="$H5_CFLAGS -Wunused-macros -Wunsafe-loop-optimizations"
######################
# Developer warnings #
@@ -184,8 +200,8 @@ if test "X-gcc" = "X-$cc_vendor"; then
# (suggestions from gcc, not code problems)
# NOTE: -Wformat-nonliteral added back in here (from being disabled in H5_CFLAGS)
- DEVELOPER_WARNING_CFLAGS="-Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn -Wformat-nonliteral"
- NO_DEVELOPER_WARNING_CFLAGS="-Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn"
+ NO_DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-no-developer-general)
+ DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-developer-general)
#######################
# gcc 4 special cases #
@@ -196,11 +212,11 @@ if test "X-gcc" = "X-$cc_vendor"; then
H5_CFLAGS="$H5_CFLAGS -Wno-long-long"
fi
- # -Wvolatile-register-var was later incorporated into -Wall and
- # only needs to be specified explicitly for gcc 4.2-4.3
+ # -Wvolatile-register-var was later incorporated into -Wall and
+ # only needs to be specified explicitly for gcc 4.2-4.3
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then
- H5_CFLAGS="$H5_CFLAGS -Wvolatile-register-var"
- fi
+ H5_CFLAGS="$H5_CFLAGS -Wvolatile-register-var"
+ fi
# -Wstrict-aliasing was later incorporated into -Wall and
# only needs to be specified explicitly for gcc 4.5-4.6
@@ -223,10 +239,10 @@ if test "X-gcc" = "X-$cc_vendor"; then
# Version-specific warnings #
#############################
- # gcc 4.3
+ # gcc 4.3
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then
- H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2560"
- fi
+ H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2560"
+ fi
# gcc 4.4
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then
diff --git a/config/gnu-warnings-developer-general b/config/gnu-warnings-developer-general
new file mode 100644
index 0000000..fd47e76
--- /dev/null
+++ b/config/gnu-warnings-developer-general
@@ -0,0 +1,14 @@
+# (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
+# suggested dev warnings from general section
+# -Wdisabled-optimization
+# -Wswitch-default
+# -Wswitch-enum
+# -Wunsafe-loop-optimizations
+# -Wunused-macros \ No newline at end of file
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 dad210c..6b4e406 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 $arch -std=c99 -Wcheck -Wall"
+ H5_CFLAGS="$H5_CFLAGS $arch -std=c99"
+ H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments warnings-general)"
# Production
PROD_CFLAGS=
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