Skip to content

Commit

Permalink
GNU Make option to turn warnings into errors (#1198)
Browse files Browse the repository at this point in the history
Add `WARN_ERROR` (with default of `FALSE`) to the GNU Make system to turn warnings into errors for
GCC and Clang.  Add `WARN_ERROR` to the 2d and 3d CIs using GNU Make.
  • Loading branch information
WeiqunZhang authored Jul 26, 2020
1 parent b9b0196 commit 1dbf5d7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
- name: Build & Install
run: |
./configure --dim 2 --with-fortran no --comp llvm --with-mpi no
make -j2 WARN_ALL=TRUE
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE
make install
# Build 3D libamrex with configure
Expand All @@ -219,5 +219,5 @@ jobs:
- name: Build & Install
run: |
./configure --dim 3 --enable-eb yes --enable-xsdk-defaults yes
make -j2 WARN_ALL=TRUE
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE
make install
3 changes: 2 additions & 1 deletion Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ If enabled, the library path at link time will be saved as a
When disabled, dynamic library paths could be provided via ``export LD_LIBRARY_PATH``
hints at runtime.

For GCC and Clang, the variable ``WARN_ALL`` controls the compiler's warning options.
For GCC and Clang, the variable ``WARN_ALL`` controls the compiler's warning options. There is
also a make variable ``WARN_ERROR`` (with default of ``FALSE``) to turn warnings into errors.

After defining these make variables, a number of files, ``Make.defs,
Make.package`` and ``Make.rules``, are included in the GNUmakefile. AMReX-based
Expand Down
6 changes: 6 additions & 0 deletions Tools/GNUMake/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ else
endif
endif

ifdef WARN_ERROR
WARN_ERROR := $(strip $(WARN_ERROR))
else
WARN_ERROR := FALSE
endif

ifdef USE_GPU_PRAGMA
USE_GPU_PRAGMA := $(strip $(USE_GPU_PRAGMA))
GPU_PRAGMA_NO_HOST_VERSION ?= FALSE
Expand Down
5 changes: 5 additions & 0 deletions Tools/GNUMake/comps/gnu.mak
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ ifeq ($(WARN_ALL),TRUE)
CFLAGS += $(warning_flags)
endif

ifeq ($(WARN_ERROR),TRUE)
CXXFLAGS += -Werror
CFLAGS += -Werror
endif

ifeq ($(USE_GPROF),TRUE)
CXXFLAGS += -pg
CFLAGS += -pg
Expand Down
5 changes: 5 additions & 0 deletions Tools/GNUMake/comps/llvm.mak
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ ifeq ($(WARN_ALL),TRUE)
CFLAGS += $(warning_flags)
endif

ifeq ($(WARN_ERROR),TRUE)
CXXFLAGS += -Werror
CFLAGS += -Werror
endif

########################################################################

ifdef CXXSTD
Expand Down

0 comments on commit 1dbf5d7

Please sign in to comment.