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

C++17 Transition #2992

Merged
merged 14 commits into from
Nov 1, 2022
Prev Previous commit
Next Next commit
Update GNU Make
  • Loading branch information
WeiqunZhang committed Oct 19, 2022
commit 4729fbe92ad821760c5ca249147ac66ca3f02b84
2 changes: 1 addition & 1 deletion .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ jobs:
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
./configure --dim 3 --with-cuda yes --enable-eb yes --enable-xsdk-defaults yes --with-fortran no
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names CXXSTD=c++17
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names
make install
1 change: 0 additions & 1 deletion Tools/AMRProfParser/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ USE_MPI = FALSE
USE_OMP = FALSE
EBASE = amrprofparser
BL_NO_FORT = FALSE
USE_CXX11 = TRUE

include $(AMREX_HOME)/Tools/GNUMake/Make.defs
include $(AMREX_HOME)/Src/Base/Make.package
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXTypecheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function( add_typecheck_target _target)
add_custom_command(
OUTPUT ${_cppd_file}
COMMAND ${CMAKE_C_COMPILER}
ARGS ${_cxx_defines} ${_includes} -E -P -x c -std=c99 ${_fullname} > ${_cppd_file}
ARGS ${_cxx_defines} ${_includes} -E -P -x c -std=c11 ${_fullname} > ${_cppd_file}
COMMAND sed
ARGS -i -e 's/amrex::Real/${AMREX_REAL}/g' ${_cppd_file}
COMMAND sed
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReX_Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function (configure_amrex)
#
# Setup compilers
#
# Set C++ standard and disable compiler-specific extensions, like "-std=gnu++14" for GNU
# Set C++ standard and disable compiler-specific extensions, like "-std=gnu++17" for GNU
# This will also enforce the same standard with the CUDA compiler
# Moreover, it will also enforce such standard on all the consuming targets
#
Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/Make.rules
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ $(tmpEXETempDir)/%.F.orig: %.F
# & --> *
$(tmpEXETempDir)/%-cppd.h: %.H
@if [ ! -d $(tmpEXETempDir) ]; then mkdir -p $(tmpEXETempDir); fi
$(SILENT) $(CC) $(CPPFLAGS) -DAMREX_TYPECHECK $(includes) -E -P -x c -std=c99 $< -o $@
$(SILENT) $(CC) $(CPPFLAGS) -DAMREX_TYPECHECK $(includes) -E -P -x c -std=c11 $< -o $@
@$(SHELL) -ec 'sed -i -e '\''s/amrex::Real/$(amrex_real)/g'\'' $@ ; \
sed -i -e '\''s/amrex_real/$(amrex_real)/g'\'' $@ ; \
sed -i -e '\''s/amrex_particle_real/$(amrex_particle_real)/g'\'' $@ ; \
Expand Down
4 changes: 2 additions & 2 deletions Tools/GNUMake/comps/armclang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ CXXFLAGS += -Wno-c++17-extensions
ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
else
CXXSTD := c++14
CXXSTD := c++17
endif

CXXFLAGS += -std=$(CXXSTD)
CFLAGS += -std=c99
CFLAGS += -std=c11

FMODULES = -J$(fmoddir) -I $(fmoddir)

Expand Down
10 changes: 3 additions & 7 deletions Tools/GNUMake/comps/cray.mak
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ endif
ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
else
CXXSTD := c++14
CXXSTD := c++17
endif

ifeq ($(CRAY_IS_CLANG_BASED),TRUE)
CXXFLAGS += -std=$(CXXSTD)
CFLAGS += -std=c99
CFLAGS += -std=c11
else
CXXFLAGS += -h std=$(CXXSTD)
CFLAGS += -h c99
CFLAGS += -h c11
endif

F90FLAGS += -N 255 -em
Expand Down Expand Up @@ -119,10 +119,6 @@ else
endif
endif

ifeq ($(CRAY_IS_CLANG_BASED),TRUE)
CXXFLAGS += -Wno-c++17-extensions
endif

CXXFLAGS += $(GENERIC_COMP_FLAGS)
CFLAGS += $(GENERIC_COMP_FLAGS)
FFLAGS += $(GENERIC_COMP_FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/comps/dpcpp.mak
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else
endif

CXXFLAGS += -Wno-error=sycl-strict -fsycl
CFLAGS += -std=c99
CFLAGS += -std=c11

ifneq ($(DEBUG),TRUE) # There is currently a bug that DEBUG build will crash.
ifeq ($(DPCPP_AOT),TRUE)
Expand Down
45 changes: 10 additions & 35 deletions Tools/GNUMake/comps/gnu.mak
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ ifeq ($(EXPORT_DYNAMIC),TRUE)
GENERIC_GNU_FLAGS += -rdynamic -fno-omit-frame-pointer
endif

gcc_major_ge_5 = $(shell expr $(gcc_major_version) \>= 5)
gcc_major_ge_6 = $(shell expr $(gcc_major_version) \>= 6)
gcc_major_ge_7 = $(shell expr $(gcc_major_version) \>= 7)
gcc_major_ge_8 = $(shell expr $(gcc_major_version) \>= 8)
gcc_major_ge_9 = $(shell expr $(gcc_major_version) \>= 9)
gcc_major_ge_10 = $(shell expr $(gcc_major_version) \>= 10)
gcc_major_ge_11 = $(shell expr $(gcc_major_version) \>= 11)
gcc_major_ge_12 = $(shell expr $(gcc_major_version) \>= 12)

ifneq ($(gcc_major_ge_8),1)
$(error GCC < 8 not supported)
endif

ifeq ($(THREAD_SANITIZER),TRUE)
GENERIC_GNU_FLAGS += -fsanitize=thread
endif
ifeq ($(FSANITIZER),TRUE)
GENERIC_GNU_FLAGS += -fsanitize=address -fsanitize=undefined
ifeq ($(gcc_major_ge_8),1)
GENERIC_GNU_FLAGS += -fsanitize=pointer-compare -fsanitize=pointer-subtract
GENERIC_GNU_FLAGS += -fsanitize=builtin -fsanitize=pointer-overflow
endif
GENERIC_GNU_FLAGS += -fsanitize=pointer-compare -fsanitize=pointer-subtract
GENERIC_GNU_FLAGS += -fsanitize=builtin -fsanitize=pointer-overflow
endif

ifeq ($(USE_OMP),TRUE)
Expand Down Expand Up @@ -97,7 +97,7 @@ else
endif

ifeq ($(WARN_ALL),TRUE)
warning_flags = -Wall -Wextra -Wlogical-op
warning_flags = -Wall -Wextra -Wlogical-op -Wfloat-conversion -Wnull-dereference -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches

ifeq ($(WARN_SIGN_COMPARE),FALSE)
warning_flags += -Wno-sign-compare
Expand All @@ -108,26 +108,10 @@ ifeq ($(WARN_ALL),TRUE)
warning_flags += -Wpedantic
endif

ifeq ($(gcc_major_ge_6),1)
warning_flags += -Wnull-dereference -Wmisleading-indentation -Wduplicated-cond
endif

ifeq ($(gcc_major_ge_5),1)
warning_flags += -Wfloat-conversion
endif

ifneq ($(WARN_SHADOW),FALSE)
warning_flags += -Wshadow
endif

ifeq ($(gcc_major_version),7)
warning_flags += -Wno-array-bounds
endif

ifeq ($(gcc_major_ge7),1)
warning_flags += -Wduplicated-branches
endif

ifeq ($(gcc_major_ge10),1)
warning_flags += -Wextra-semi
endif
Expand Down Expand Up @@ -161,21 +145,12 @@ endif

ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
ifeq ($(shell expr $(gcc_major_version) \< 5),1)
ifneq ($(NO_CONFIG_CHECKING),TRUE)
ifeq ($(CXXSTD),c++14)
$(error C++14 support requires GCC 5 or newer.)
endif
endif
endif
CXXFLAGS += -std=$(CXXSTD)
else
ifeq ($(gcc_major_version),5)
CXXFLAGS += -std=c++14
endif
CXXFLAGS += -std=c++17
endif

CFLAGS += -std=gnu99
CFLAGS += -std=c11

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

Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/comps/hip.mak
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endif

# Generic flags, always used
CXXFLAGS = -std=$(CXXSTD) -m64
CFLAGS = -std=c99 -m64
CFLAGS = -std=c11 -m64

FFLAGS = -ffixed-line-length-none -fno-range-check -fno-second-underscore
F90FLAGS = -ffree-line-length-none -fno-range-check -fno-second-underscore -fimplicit-none
Expand Down
19 changes: 3 additions & 16 deletions Tools/GNUMake/comps/intel.mak
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,12 @@ endif

ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
ifneq ($(firstword $(sort 17.0 $(intel_version))), 17.0)
ifeq ($(CXXSTD),c++14)
$(error C++14 support requires Intel icpc 17.0 or newer.)
endif
endif
CXXFLAGS += -std=$(CXXSTD)
else
ifeq ($(firstword $(sort 17.0 $(intel_version))), 17.0)
CXXFLAGS += -std=c++14
else
$(error Intel icpc 17.0 or newer is required.)
endif
CXXFLAGS += -std=c++17
endif

CFLAGS += -std=c99
CFLAGS += -std=c11

F90FLAGS += -implicitnone

Expand All @@ -64,11 +55,7 @@ FMODULES = -module $(fmoddir) -I$(fmoddir)
GENERIC_COMP_FLAGS =

ifeq ($(USE_OMP),TRUE)
ifeq ($(firstword $(sort 16.0 $(intel_version))), 16.0)
GENERIC_COMP_FLAGS += -qopenmp
else
GENERIC_COMP_FLAGS += -openmp
endif
GENERIC_COMP_FLAGS += -qopenmp
endif

CXXFLAGS += $(GENERIC_COMP_FLAGS) -pthread
Expand Down
4 changes: 2 additions & 2 deletions Tools/GNUMake/comps/llvm-flang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ endif
ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
else
CXXSTD := c++14
CXXSTD := c++17
endif

CXXFLAGS += -std=$(CXXSTD)
CFLAGS += -std=c99
CFLAGS += -std=c11

FMODULES = -J$(fmoddir) -I $(fmoddir)

Expand Down
4 changes: 2 additions & 2 deletions Tools/GNUMake/comps/llvm.mak
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ CXXFLAGS += -Wno-c++17-extensions
ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
else
CXXSTD := c++14
CXXSTD := c++17
endif

CXXFLAGS += -std=$(CXXSTD)
CFLAGS += -std=c99
CFLAGS += -std=c11

FFLAGS += -ffixed-line-length-none -fno-range-check -fno-second-underscore
F90FLAGS += -ffree-line-length-none -fno-range-check -fno-second-underscore -fimplicit-none
Expand Down
9 changes: 2 additions & 7 deletions Tools/GNUMake/comps/nag.mak
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,12 @@ endif

ifdef CXXSTD
CXXSTD := $(strip $(CXXSTD))
ifeq ($(shell expr $(gcc_major_version) \< 5),1)
ifeq ($(CXXSTD),c++14)
$(error C++14 support requires GCC 5 or newer.)
endif
endif
CXXFLAGS += -std=$(CXXSTD)
else
CXXFLAGS += -std=c++14
CXXFLAGS += -std=c++17
endif

CFLAGS += -std=gnu99
CFLAGS += -std=c11

FFLAGS += -mismatch
F90FLAGS += -mismatch -u
Expand Down
Loading