mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONFIG: update c++ standard, some compiler rules (partially addresses #2209)
- migrate to c++14 for most compilers *except* gcc. There are still many systems in use with gcc-4.8.5, which does not support c++14. - initial rules for nvidia compilers (pgi is will soon be defunct). Not fully tested... CONFIG: provide fallback value for the user directory name - in containers may have an unset USER env variable. Default to 'user' to prevent ugly looking directory names.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = clang++ -std=c++11
|
||||
CC = clang++ -std=c++14
|
||||
|
||||
c++ARCH =
|
||||
c++DBUG =
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# C++14 support with gcc-5 and later, but several systems (as of 2021)
|
||||
# are still using gcc-4.8.4 (centos7, suse SLES12, ...)
|
||||
#
|
||||
# NOTE if your system gcc is new enough can simply use c++14 too.
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = g++ -std=c++11
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Intel compiler is new enough to support c++14
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = icpc -std=c++11
|
||||
CC = icpc -std=c++14
|
||||
|
||||
c++ARCH =
|
||||
c++DBUG =
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Intel compiler is new enough to support c++14
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = icpx -std=c++11
|
||||
CC = icpx -std=c++14
|
||||
|
||||
c++ARCH =
|
||||
c++DBUG =
|
||||
|
||||
13
wmake/rules/General/Nvidia/c
Normal file
13
wmake/rules/General/Nvidia/c
Normal file
@ -0,0 +1,13 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Nvidia compilers
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .c
|
||||
|
||||
cc = nvc
|
||||
|
||||
cARCH =
|
||||
cDBUG =
|
||||
cOPT = -O2
|
||||
cWARN = $(FOAM_EXTRA_CFLAGS)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
37
wmake/rules/General/Nvidia/c++
Normal file
37
wmake/rules/General/Nvidia/c++
Normal file
@ -0,0 +1,37 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Nvidia compilers
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = nvc++ -std=c++14
|
||||
|
||||
c++ARCH =
|
||||
c++DBUG =
|
||||
c++OPT = -O2
|
||||
ptFLAGS = -DNoRepository
|
||||
|
||||
# - Standard warnings
|
||||
# - Less restrictive warnings (may be needed for flex++, CGAL, etc.)
|
||||
|
||||
c++WARN = \
|
||||
-Wall -Wextra \
|
||||
--diag_suppress=111,128,177,185,612,998,1098 \
|
||||
--display_error_number \
|
||||
$(FOAM_EXTRA_CXXFLAGS)
|
||||
|
||||
c++LESSWARN =
|
||||
|
||||
# Warnings
|
||||
# --------
|
||||
# Run with --display_error_number to get numbers
|
||||
# and --diag_suppress=XXX to suppress
|
||||
#
|
||||
#111-D: statement is unreachable
|
||||
#128-D: loop is not reachable
|
||||
#177-D: function was declared but never referenced
|
||||
#185-D: dynamic initialization in unreachable code
|
||||
#612-D: overloaded virtual function ... is only partially overridden
|
||||
#998-D: function XX is hidden by YY -- virtual function override intended?
|
||||
#1098-D: unknown attribute "fallthrough"
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
5
wmake/rules/General/Nvidia/link-c
Normal file
5
wmake/rules/General/Nvidia/link-c
Normal file
@ -0,0 +1,5 @@
|
||||
LINK_LIBS = $(cDBUG)
|
||||
|
||||
LINKLIBSO = $(cc) $(cARCH) -shared
|
||||
|
||||
LINKEXE = $(cc) $(cARCH) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs
|
||||
8
wmake/rules/General/Nvidia/link-c++
Normal file
8
wmake/rules/General/Nvidia/link-c++
Normal file
@ -0,0 +1,8 @@
|
||||
LINK_LIBS = $(c++DBUG)
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
|
||||
$(FOAM_EXTRA_LDFLAGS)
|
||||
|
||||
LINKEXE = $(CC) $(c++FLAGS) \
|
||||
-Xlinker --add-needed \
|
||||
$(FOAM_EXTRA_LDFLAGS)
|
||||
5
wmake/rules/General/Nvidia/openmp
Normal file
5
wmake/rules/General/Nvidia/openmp
Normal file
@ -0,0 +1,5 @@
|
||||
# Flags for compiling/linking openmp
|
||||
# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP)
|
||||
|
||||
COMP_OPENMP = -DUSE_OMP -fopenmp
|
||||
LINK_OPENMP = -lnvomp
|
||||
@ -1,3 +1,6 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# PGI Compilers are defunct - now in NVIDIA HPC SDK (2021)
|
||||
#------------------------------------------------------------------------------
|
||||
SUFFIXES += .C .cc .cpp .cxx
|
||||
|
||||
CC = pgc++ -std=c++11
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Cray compiler - a gcc variant/wrapper
|
||||
# presumably new enough to support c++14
|
||||
#------------------------------------------------------------------------------
|
||||
include $(GENERAL_RULES)/Gcc/c++
|
||||
|
||||
CC = CC -std=c++11
|
||||
CC = CC -std=c++14
|
||||
|
||||
c++ARCH = -m64 -pthread
|
||||
|
||||
@ -15,3 +18,5 @@ cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
include $(GENERAL_RULES)/Gcc/link-c++
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# mingw is gcc, but new enough to support c++14
|
||||
#------------------------------------------------------------------------------
|
||||
include $(GENERAL_RULES)/Gcc/c++
|
||||
|
||||
c++ARCH = -m64 -pthread
|
||||
|
||||
# With gnu++11 (not c++11) to ensure __STRICT_ANSI__ is not defined
|
||||
CC = x86_64-w64-mingw32-g++ -std=gnu++11
|
||||
# With gnu++14 (not c++14) to ensure __STRICT_ANSI__ is not defined
|
||||
CC = x86_64-w64-mingw32-g++ -std=gnu++14
|
||||
|
||||
include $(RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
@ -34,3 +37,5 @@ LINKEXE = $(CC) $(c++FLAGS) \
|
||||
-Wl,--strip-all \
|
||||
-Wl,--force-exe-suffix \
|
||||
$(FOAM_EXTRA_LDFLAGS)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
12
wmake/rules/linux64Nvidia/c
Normal file
12
wmake/rules/linux64Nvidia/c
Normal file
@ -0,0 +1,12 @@
|
||||
include $(GENERAL_RULES)/Nvidia/c
|
||||
|
||||
cARCH = -m64
|
||||
|
||||
# Compile option is non-mandatory, but must be non-empty
|
||||
sinclude $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
|
||||
|
||||
cFLAGS = $(cARCH) $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@
|
||||
|
||||
include $(GENERAL_RULES)/Nvidia/link-c
|
||||
14
wmake/rules/linux64Nvidia/c++
Normal file
14
wmake/rules/linux64Nvidia/c++
Normal file
@ -0,0 +1,14 @@
|
||||
include $(GENERAL_RULES)/Nvidia/c++
|
||||
|
||||
c++ARCH = -m64
|
||||
|
||||
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
c++FLAGS = $(c++ARCH) $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@
|
||||
cxxtoo = $(Ctoo)
|
||||
cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
include $(GENERAL_RULES)/Nvidia/link-c++
|
||||
2
wmake/rules/linux64Nvidia/c++Debug
Normal file
2
wmake/rules/linux64Nvidia/c++Debug
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -g -DFULLDEBUG
|
||||
c++OPT = -O0
|
||||
2
wmake/rules/linux64Nvidia/c++Opt
Normal file
2
wmake/rules/linux64Nvidia/c++Opt
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG =
|
||||
c++OPT = -O3
|
||||
2
wmake/rules/linux64Nvidia/c++Prof
Normal file
2
wmake/rules/linux64Nvidia/c++Prof
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -pg
|
||||
c++OPT = -O2
|
||||
2
wmake/rules/linux64Nvidia/cDebug
Normal file
2
wmake/rules/linux64Nvidia/cDebug
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -g -DFULLDEBUG
|
||||
cOPT = -O0
|
||||
2
wmake/rules/linux64Nvidia/cOpt
Normal file
2
wmake/rules/linux64Nvidia/cOpt
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG =
|
||||
cOPT = -O3
|
||||
2
wmake/rules/linux64Nvidia/cProf
Normal file
2
wmake/rules/linux64Nvidia/cProf
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -pg
|
||||
cOPT = -O2
|
||||
13
wmake/rules/linux64Nvidia/general
Normal file
13
wmake/rules/linux64Nvidia/general
Normal file
@ -0,0 +1,13 @@
|
||||
CPP = cpp -traditional-cpp $(GFLAGS)
|
||||
|
||||
include $(GENERAL_RULES)/standard
|
||||
## include $(GENERAL_RULES)/Pgi/openmp
|
||||
|
||||
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
|
||||
include $(GENERAL_RULES)/no-openmp
|
||||
endif
|
||||
|
||||
include $(DEFAULT_RULES)/c
|
||||
include $(DEFAULT_RULES)/c++
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
3
wmake/rules/linux64Nvidia/mplibOPENMPI
Normal file
3
wmake/rules/linux64Nvidia/mplibOPENMPI
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX
|
||||
PINC = -I$(MPI_ARCH_PATH)/include
|
||||
PLIBS = -L$(MPI_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) -L$(MPI_ARCH_PATH)/lib -lmpi
|
||||
@ -1,7 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# A clang variant
|
||||
#------------------------------------------------------------------------------
|
||||
include $(GENERAL_RULES)/Clang/c++
|
||||
|
||||
CC = armclang++ -std=c++11
|
||||
CC = armclang++ -std=c++14
|
||||
|
||||
c++ARCH = -mcpu=native -pthread
|
||||
|
||||
@ -18,3 +20,5 @@ include $(GENERAL_RULES)/Clang/link-c++
|
||||
|
||||
LINKLIBSO += -armpl
|
||||
LINKEXE += -armpl
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Fujitsu compiler - a clang variant
|
||||
#------------------------------------------------------------------------------
|
||||
include $(GENERAL_RULES)/Clang/c++
|
||||
|
||||
CC = FCC -std=c++11
|
||||
CC = FCC -std=c++14
|
||||
|
||||
c++ARCH = -pthread
|
||||
|
||||
@ -15,3 +17,5 @@ cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
include $(GENERAL_RULES)/Clang/link-c++
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user