Commit 9423d2bd authored by Mark Olesen's avatar Mark Olesen

CONFIG: improve support for compiler/link options (#1830)

- introduce WM_COMPILE_CONTROL variable to convey control information
  into the build rules.

  The convention (as per spack):
      - '+' to select a feature
      - '~' to deselect a feature

  Eg, to select the gold linker, and disable openmp
  (spaces are not required):

      WM_COMPILE_CONTROL="+gold ~openmp"

CONFIG: accept FOAM_EXTRA_LDFLAGS for AMD, gold, Mingw linkers

CONFIG: generalize PROJECT_LIBS (-ldl used almost universally)
parent fbfcdfc7
/* Without the normal defaults */ /* Without the normal project defaults */
PROJECT_INC = PROJECT_INC =
PROJECT_LIBS = PROJECT_LIBS =
EXE_INC = -Idummy EXE_INC = -Idummy
EXE_LIBS = -lOpenFOAM-dummy
EXE_LIBS = \
-lOpenFOAM-dummy
/* Without the normal defaults */ /* Without the normal project defaults */
PROJECT_INC = PROJECT_INC =
PROJECT_LIBS = PROJECT_LIBS =
EXE_INC = \ EXE_INC = \
-DWM_ARCH=\"$(WM_ARCH)\" \ -DWM_ARCH=\"$(WM_ARCH)\" \
...@@ -8,5 +8,4 @@ EXE_INC = \ ...@@ -8,5 +8,4 @@ EXE_INC = \
-DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \ -DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \
-DWM_OPTIONS=\"$(WM_OPTIONS)\" -DWM_OPTIONS=\"$(WM_OPTIONS)\"
/* LIB_LIBS = */ /* LIB_LIBS = */
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /*-DFULLDEBUG -O0 -g*/ \ /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /*-DFULLDEBUG -O0 -g*/ \ /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
EXE_LIBS = /* EXE_LIBS = */
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
EXE_LIBS = /* EXE_LIBS = */
...@@ -83,6 +83,11 @@ export WM_LABEL_SIZE=32 ...@@ -83,6 +83,11 @@ export WM_LABEL_SIZE=32
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
export WM_COMPILE_OPTION=Opt export WM_COMPILE_OPTION=Opt
# [WM_COMPILE_CONTROL] - additional control for compiler rules
# +gold : with gold linker
# ~openmp : without openmp
#export WM_COMPILE_CONTROL="+gold"
# [WM_MPLIB] - MPI implementation: # [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM | # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
# HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI # HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
......
...@@ -47,11 +47,11 @@ unsetenv WM_ARCH ...@@ -47,11 +47,11 @@ unsetenv WM_ARCH
unsetenv WM_ARCH_OPTION unsetenv WM_ARCH_OPTION
unsetenv WM_COMPILER unsetenv WM_COMPILER
unsetenv WM_COMPILER_ARCH unsetenv WM_COMPILER_ARCH
unsetenv WM_COMPILER_TYPE
unsetenv WM_COMPILER_LIB_ARCH unsetenv WM_COMPILER_LIB_ARCH
unsetenv WM_COMPILER_TYPE
unsetenv WM_COMPILE_CONTROL
unsetenv WM_COMPILE_OPTION unsetenv WM_COMPILE_OPTION
unsetenv WM_DIR unsetenv WM_DIR
unsetenv WM_HOSTS
unsetenv WM_LABEL_OPTION unsetenv WM_LABEL_OPTION
unsetenv WM_LABEL_SIZE unsetenv WM_LABEL_SIZE
unsetenv WM_MPLIB unsetenv WM_MPLIB
...@@ -60,21 +60,21 @@ unsetenv WM_OPTIONS ...@@ -60,21 +60,21 @@ unsetenv WM_OPTIONS
unsetenv WM_OSTYPE unsetenv WM_OSTYPE
unsetenv WM_PRECISION_OPTION unsetenv WM_PRECISION_OPTION
unsetenv WM_PROJECT unsetenv WM_PROJECT
unsetenv WM_PROJECT_API
unsetenv WM_PROJECT_DIR unsetenv WM_PROJECT_DIR
unsetenv WM_PROJECT_INST_DIR
unsetenv WM_PROJECT_SITE unsetenv WM_PROJECT_SITE
unsetenv WM_PROJECT_USER_DIR unsetenv WM_PROJECT_USER_DIR
unsetenv WM_PROJECT_VERSION unsetenv WM_PROJECT_VERSION
unsetenv WM_SCHEDULER unsetenv WM_SCHEDULER
unsetenv WM_THIRD_PARTY_DIR unsetenv WM_THIRD_PARTY_DIR
# Older variables # Older, unused variables
unsetenv WM_HOSTS
unsetenv WM_PROJECT_API
unsetenv WM_PROJECT_INST_DIR
# Before 1906 # Before 1906
unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Unset FOAM_* environment variables # Unset FOAM_* environment variables
...@@ -106,7 +106,7 @@ unsetenv FOAM_USER_APPBIN ...@@ -106,7 +106,7 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES unsetenv FOAM_UTILITIES
# Old variables # Older, unused variables
# Before 1812 # Before 1812
unsetenv FOAM_INST_DIR unsetenv FOAM_INST_DIR
......
...@@ -35,11 +35,12 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ ...@@ -35,11 +35,12 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
unset WM_ARCH unset WM_ARCH
unset WM_ARCH_OPTION unset WM_ARCH_OPTION
unset WM_COMPILER unset WM_COMPILER
unset WM_COMPILER_TYPE unset WM_COMPILER_ARCH
unset WM_COMPILER_LIB_ARCH unset WM_COMPILER_LIB_ARCH
unset WM_COMPILER_TYPE
unset WM_COMPILE_CONTROL
unset WM_COMPILE_OPTION unset WM_COMPILE_OPTION
unset WM_DIR unset WM_DIR
unset WM_HOSTS
unset WM_LABEL_OPTION unset WM_LABEL_OPTION
unset WM_LABEL_SIZE unset WM_LABEL_SIZE
unset WM_MPLIB unset WM_MPLIB
...@@ -48,16 +49,17 @@ unset WM_OPTIONS ...@@ -48,16 +49,17 @@ unset WM_OPTIONS
unset WM_OSTYPE unset WM_OSTYPE
unset WM_PRECISION_OPTION unset WM_PRECISION_OPTION
unset WM_PROJECT unset WM_PROJECT
unset WM_PROJECT_API
unset WM_PROJECT_DIR unset WM_PROJECT_DIR
unset WM_PROJECT_INST_DIR
unset WM_PROJECT_SITE unset WM_PROJECT_SITE
unset WM_PROJECT_USER_DIR unset WM_PROJECT_USER_DIR
unset WM_PROJECT_VERSION unset WM_PROJECT_VERSION
unset WM_SCHEDULER unset WM_SCHEDULER
unset WM_THIRD_PARTY_DIR unset WM_THIRD_PARTY_DIR
# Older variables # Older, unused variables
unset WM_HOSTS
unset WM_PROJECT_API
unset WM_PROJECT_INST_DIR
# Before 1906 # Before 1906
unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
...@@ -93,7 +95,7 @@ unset FOAM_USER_APPBIN ...@@ -93,7 +95,7 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES unset FOAM_UTILITIES
# Old variables # Older, unused variables
# Before 1812 # Before 1812
unset FOAM_INST_DIR unset FOAM_INST_DIR
......
...@@ -83,6 +83,11 @@ setenv WM_LABEL_SIZE 32 ...@@ -83,6 +83,11 @@ setenv WM_LABEL_SIZE 32
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
setenv WM_COMPILE_OPTION Opt setenv WM_COMPILE_OPTION Opt
# [WM_COMPILE_CONTROL] - additional control for compiler rules
# +gold : with gold linker
# ~openmp : without openmp
#setenv WM_COMPILE_CONTROL "+gold"
# [WM_MPLIB] - MPI implementation: # [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM | # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
# HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI # HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
......
...@@ -20,6 +20,9 @@ fi ...@@ -20,6 +20,9 @@ fi
wmakeLnInclude -u OpenFOAM wmakeLnInclude -u OpenFOAM
wmakeLnInclude -u OSspecific/"${WM_OSTYPE:-POSIX}" wmakeLnInclude -u OSspecific/"${WM_OSTYPE:-POSIX}"
# Update version info (as required)
OpenFOAM/Alltouch -check 2>/dev/null
OSspecific/"${WM_OSTYPE:-POSIX}"/Allwmake $targetType $* OSspecific/"${WM_OSTYPE:-POSIX}"/Allwmake $targetType $*
case "$WM_COMPILER" in case "$WM_COMPILER" in
...@@ -37,9 +40,6 @@ Mingw*) ...@@ -37,9 +40,6 @@ Mingw*)
;; ;;
*) *)
Pstream/Allwmake $targetType $* Pstream/Allwmake $targetType $*
# Update version info (as required)
OpenFOAM/Alltouch -check 2>/dev/null
;; ;;
esac esac
......
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
/* Never self-link with WM_PROJECT == OpenFOAM */
PROJECT_LIBS =
EXE_INC = \ EXE_INC = \
-I$(OBJECTS_DIR) -I$(OBJECTS_DIR)
LIB_LIBS = \ LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o $(FOAM_LIBBIN)/libOSspecific.o
ifeq ($(FOAM_LINK_DUMMY_PSTREAM),libo) ifeq (libo,$(FOAM_LINK_DUMMY_PSTREAM))
LIB_LIBS += $(FOAM_LIBBIN)/dummy/libPstream.o LIB_LIBS += $(FOAM_LIBBIN)/dummy/libPstream.o
else else
LIB_LIBS += -L$(FOAM_LIBBIN)/dummy -lPstream LIB_LIBS += -L$(FOAM_LIBBIN)/dummy -lPstream
...@@ -17,3 +14,7 @@ endif ...@@ -17,3 +14,7 @@ endif
EXE_INC += -DHAVE_LIBZ EXE_INC += -DHAVE_LIBZ
LIB_LIBS += -lz LIB_LIBS += -lz
/* Project lib dependencies. Never self-link (WM_PROJECT == OpenFOAM) */
PROJECT_LIBS =
EXE_INC = /* EXE_INC = */
/* LIB_LIBS = */
LIB_LIBS =
/* Project lib dependencies */
PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
...@@ -10,4 +10,5 @@ EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN) ...@@ -10,4 +10,5 @@ EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN)
LIB_LIBS = $(PLIBS) LIB_LIBS = $(PLIBS)
/* Project lib dependencies */
PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
EXE_INC = /* EXE_INC = */
/* EXE_LIBS = */
EXE_LIBS =
EXE_INC = /* EXE_INC = */
/* LIB_LIBS = */
LIB_LIBS =
...@@ -33,6 +33,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE))) ...@@ -33,6 +33,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
endif endif
/* May require librt, but scotch does not declare the dependency */ /* May require librt, but scotch does not declare the dependency */
ifeq ($(EXT_SO),.so) ifeq (.so,$(EXT_SO))
LIB_LIBS += -lrt LIB_LIBS += -lrt
endif endif
...@@ -13,6 +13,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE))) ...@@ -13,6 +13,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
endif endif
/* May require librt, but scotch does not declare the dependency */ /* May require librt, but scotch does not declare the dependency */
ifeq ($(EXT_SO),.so) ifeq (.so,$(EXT_SO))
LIB_LIBS += -lrt LIB_LIBS += -lrt
endif endif
EXE_INC = /* EXE_INC = */
/* LIB_LIBS = */
LIB_LIBS =
EXE_INC = /* EXE_INC = */
/* LIB_LIBS = */
LIB_LIBS =
...@@ -59,7 +59,7 @@ PROJECT_INC = \ ...@@ -59,7 +59,7 @@ PROJECT_INC = \
-I$(LIB_SRC)/$(WM_PROJECT)/lnInclude \ -I$(LIB_SRC)/$(WM_PROJECT)/lnInclude \
-I$(LIB_SRC)/OSspecific/$(WM_OSTYPE)/lnInclude -I$(LIB_SRC)/OSspecific/$(WM_OSTYPE)/lnInclude
PROJECT_LIBS = -l$(WM_PROJECT) PROJECT_LIBS = -l$(WM_PROJECT) -ldl
EXE_INC = EXE_INC =
EXE_LIBS = EXE_LIBS =
......
LINK_LIBS = $(c++DBUG) -Wl,--as-needed LINK_LIBS = $(c++DBUG) -Wl,--as-needed
LINKLIBSO = $(CC) $(c++FLAGS) -shared LINKLIBSO = $(CC) $(c++FLAGS) -shared \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) -L$(FOAM_LIBBIN)/dummy -lPstream LINKEXE = $(CC) $(c++FLAGS) \
-L$(FOAM_LIBBIN)/dummy -lPstream \
$(FOAM_EXTRA_LDFLAGS)
LINK_LIBS = $(c++DBUG) LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared $(FOAM_EXTRA_LDFLAGS) LINKLIBSO = $(CC) $(c++FLAGS) -shared \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed $(FOAM_EXTRA_LDFLAGS) LINKEXE = $(CC) $(c++FLAGS) \
-Xlinker --add-needed \
$(FOAM_EXTRA_LDFLAGS)
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=gold \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=gold \
-L$(FOAM_LIBBIN)/dummy -lPstream \
$(FOAM_EXTRA_LDFLAGS)
LINK_LIBS = $(c++DBUG) LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared -fuse-ld=gold LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=gold \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=gold -L$(FOAM_LIBBIN)/dummy -lPstream LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=gold \
-L$(FOAM_LIBBIN)/dummy -lPstream \
$(FOAM_EXTRA_LDFLAGS)
LINK_LIBS = $(c++DBUG) LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared $(FOAM_EXTRA_LDFLAGS) LINKLIBSO = $(CC) $(c++FLAGS) -shared \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed $(FOAM_EXTRA_LDFLAGS) LINKEXE = $(CC) $(c++FLAGS) \
-Xlinker --add-needed \
$(FOAM_EXTRA_LDFLAGS)
...@@ -8,7 +8,7 @@ WMKDEP := $(WMAKE_BIN)/wmkdepend # 1. Ragel-based ...@@ -8,7 +8,7 @@ WMKDEP := $(WMAKE_BIN)/wmkdepend # 1. Ragel-based
WMKDEP_FLAGS := -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR WMKDEP_FLAGS := -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR
ifneq ("$(WM_QUIET)","") ifneq ("","$(WM_QUIET)")
E=@ E=@
define QUIET_MESSAGE define QUIET_MESSAGE
@echo " $1: $2"; @echo " $1: $2";
......
CPP = cpp -traditional-cpp $(GFLAGS) CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard include $(GENERAL_RULES)/standard
## include $(GENERAL_RULES)/Clang/openmp ## include $(GENERAL_RULES)/Clang/openmp
...@@ -10,9 +8,10 @@ include $(GENERAL_RULES)/standard ...@@ -10,9 +8,10 @@ include $(GENERAL_RULES)/standard
COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
LINK_OPENMP = -lomp LINK_OPENMP = -lomp
# ---- # ----
# Or disable
# include $(GENERAL_RULES)/no-openmp ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
# ---- include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++ include $(DEFAULT_RULES)/c++
......
CPP = cpp -traditional-cpp $(GFLAGS) CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/no-openmp include $(GENERAL_RULES)/no-openmp
include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++ include $(DEFAULT_RULES)/c++
# -----------------------------------------------------------------------------
...@@ -11,4 +11,10 @@ cxxtoo = $(Ctoo) ...@@ -11,4 +11,10 @@ cxxtoo = $(Ctoo)
cctoo = $(Ctoo) cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
include $(GENERAL_RULES)/Clang/link-c++ ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-gold-c++
else
include $(GENERAL_RULES)/Clang/link-c++
endif
#------------------------------------------------------------------------------
CPP = cpp -traditional-cpp $(GFLAGS) CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Clang/openmp include $(GENERAL_RULES)/Clang/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif