Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU Make option to turn warnings into errors #1198

Merged
merged 1 commit into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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