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_LIBS =
EXE_INC = -Idummy
EXE_LIBS = \
-lOpenFOAM-dummy
EXE_LIBS = -lOpenFOAM-dummy
/* Without the normal defaults */
/* Without the normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
......@@ -8,5 +8,4 @@ EXE_INC = \
-DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \
-DWM_OPTIONS=\"$(WM_OPTIONS)\"
/* LIB_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC = /*-DFULLDEBUG -O0 -g*/ \
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC = /*-DFULLDEBUG -O0 -g*/ \
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
......@@ -83,6 +83,11 @@ export WM_LABEL_SIZE=32
# Other is processor or packaging specific (eg, OptKNL)
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:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
# HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
......
......@@ -47,11 +47,11 @@ unsetenv WM_ARCH
unsetenv WM_ARCH_OPTION
unsetenv WM_COMPILER
unsetenv WM_COMPILER_ARCH
unsetenv WM_COMPILER_TYPE
unsetenv WM_COMPILER_LIB_ARCH
unsetenv WM_COMPILER_TYPE
unsetenv WM_COMPILE_CONTROL
unsetenv WM_COMPILE_OPTION
unsetenv WM_DIR
unsetenv WM_HOSTS
unsetenv WM_LABEL_OPTION
unsetenv WM_LABEL_SIZE
unsetenv WM_MPLIB
......@@ -60,21 +60,21 @@ unsetenv WM_OPTIONS
unsetenv WM_OSTYPE
unsetenv WM_PRECISION_OPTION
unsetenv WM_PROJECT
unsetenv WM_PROJECT_API
unsetenv WM_PROJECT_DIR
unsetenv WM_PROJECT_INST_DIR
unsetenv WM_PROJECT_SITE
unsetenv WM_PROJECT_USER_DIR
unsetenv WM_PROJECT_VERSION
unsetenv WM_SCHEDULER
unsetenv WM_THIRD_PARTY_DIR
# Older variables
# Older, unused variables
unsetenv WM_HOSTS
unsetenv WM_PROJECT_API
unsetenv WM_PROJECT_INST_DIR
# Before 1906
unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
#------------------------------------------------------------------------------
# Unset FOAM_* environment variables
......@@ -106,7 +106,7 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES
# Old variables
# Older, unused variables
# Before 1812
unsetenv FOAM_INST_DIR
......
......@@ -35,11 +35,12 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
unset WM_ARCH
unset WM_ARCH_OPTION
unset WM_COMPILER
unset WM_COMPILER_TYPE
unset WM_COMPILER_ARCH
unset WM_COMPILER_LIB_ARCH
unset WM_COMPILER_TYPE
unset WM_COMPILE_CONTROL
unset WM_COMPILE_OPTION
unset WM_DIR
unset WM_HOSTS
unset WM_LABEL_OPTION
unset WM_LABEL_SIZE
unset WM_MPLIB
......@@ -48,16 +49,17 @@ unset WM_OPTIONS
unset WM_OSTYPE
unset WM_PRECISION_OPTION
unset WM_PROJECT
unset WM_PROJECT_API
unset WM_PROJECT_DIR
unset WM_PROJECT_INST_DIR
unset WM_PROJECT_SITE
unset WM_PROJECT_USER_DIR
unset WM_PROJECT_VERSION
unset WM_SCHEDULER
unset WM_THIRD_PARTY_DIR
# Older variables
# Older, unused variables
unset WM_HOSTS
unset WM_PROJECT_API
unset WM_PROJECT_INST_DIR
# Before 1906
unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
......@@ -93,7 +95,7 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES
# Old variables
# Older, unused variables
# Before 1812
unset FOAM_INST_DIR
......
......@@ -83,6 +83,11 @@ setenv WM_LABEL_SIZE 32
# Other is processor or packaging specific (eg, OptKNL)
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:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
# HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
......
......@@ -20,6 +20,9 @@ fi
wmakeLnInclude -u OpenFOAM
wmakeLnInclude -u OSspecific/"${WM_OSTYPE:-POSIX}"
# Update version info (as required)
OpenFOAM/Alltouch -check 2>/dev/null
OSspecific/"${WM_OSTYPE:-POSIX}"/Allwmake $targetType $*
case "$WM_COMPILER" in
......@@ -37,9 +40,6 @@ Mingw*)
;;
*)
Pstream/Allwmake $targetType $*
# Update version info (as required)
OpenFOAM/Alltouch -check 2>/dev/null
;;
esac
......
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
/* Never self-link with WM_PROJECT == OpenFOAM */
PROJECT_LIBS =
EXE_INC = \
-I$(OBJECTS_DIR)
LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o
ifeq ($(FOAM_LINK_DUMMY_PSTREAM),libo)
ifeq (libo,$(FOAM_LINK_DUMMY_PSTREAM))
LIB_LIBS += $(FOAM_LIBBIN)/dummy/libPstream.o
else
LIB_LIBS += -L$(FOAM_LIBBIN)/dummy -lPstream
......@@ -17,3 +14,7 @@ endif
EXE_INC += -DHAVE_LIBZ
LIB_LIBS += -lz
/* Project lib dependencies. Never self-link (WM_PROJECT == OpenFOAM) */
PROJECT_LIBS =
EXE_INC =
LIB_LIBS =
/* EXE_INC = */
/* LIB_LIBS = */
/* Project lib dependencies */
PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
......@@ -10,4 +10,5 @@ EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN)
LIB_LIBS = $(PLIBS)
/* Project lib dependencies */
PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
EXE_INC =
EXE_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */
EXE_INC =
LIB_LIBS =
/* EXE_INC = */
/* LIB_LIBS = */
......@@ -33,6 +33,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
endif
/* May require librt, but scotch does not declare the dependency */
ifeq ($(EXT_SO),.so)
ifeq (.so,$(EXT_SO))
LIB_LIBS += -lrt
endif
......@@ -13,6 +13,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
endif
/* May require librt, but scotch does not declare the dependency */
ifeq ($(EXT_SO),.so)
ifeq (.so,$(EXT_SO))
LIB_LIBS += -lrt
endif
EXE_INC =
LIB_LIBS =
/* EXE_INC = */
/* LIB_LIBS = */
EXE_INC =
LIB_LIBS =
/* EXE_INC = */
/* LIB_LIBS = */
......@@ -59,7 +59,7 @@ PROJECT_INC = \
-I$(LIB_SRC)/$(WM_PROJECT)/lnInclude \
-I$(LIB_SRC)/OSspecific/$(WM_OSTYPE)/lnInclude
PROJECT_LIBS = -l$(WM_PROJECT)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
EXE_INC =
EXE_LIBS =
......
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)
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)
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)
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
WMKDEP_FLAGS := -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR
ifneq ("$(WM_QUIET)","")
ifneq ("","$(WM_QUIET)")
E=@
define QUIET_MESSAGE
@echo " $1: $2";
......
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
## include $(GENERAL_RULES)/Clang/openmp
......@@ -10,9 +8,10 @@ include $(GENERAL_RULES)/standard
COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
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++
......
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/no-openmp
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++
# -----------------------------------------------------------------------------
......@@ -11,4 +11,10 @@ cxxtoo = $(Ctoo)
cctoo = $(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)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Clang/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++
# -----------------------------------------------------------------------------
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
# include $(GENERAL_RULES)/Gcc/openmp
## include $(GENERAL_RULES)/Gcc/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++
# -----------------------------------------------------------------------------
......@@ -11,4 +11,10 @@ cxxtoo = $(Ctoo)
cctoo = $(Ctoo)
cpptoo = $(Ctoo)
include $(GENERAL_RULES)/Gcc/link-c++
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Gcc/link-gold-c++
else
include $(GENERAL_RULES)/Gcc/link-c++
endif
#------------------------------------------------------------------------------
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Gcc/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++
#------------------------------------------------------------------------------
CPP = /lib/cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Icc/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++
# -----------------------------------------------------------------------------
......@@ -19,7 +19,7 @@ LINK_LIBS = $(c++DBUG)
# Using "-Wl,--no-undefined,--enable-runtime-pseudo-reloc"
# does not forgive undefined symbols during linking
LINKLIBSO = $(CC) $(c++FLAGS) \
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-Wl,--output-def=$(LIB).def \
-Wl,--out-implib=$(LIB).dll.a \
-Wl,--no-undefined \
......@@ -27,9 +27,10 @@ LINKLIBSO = $(CC) $(c++FLAGS) \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--strip-all \
-shared
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) \
-Wl,--enable-auto-import \
-Wl,--strip-all \
-Wl,--force-exe-suffix
-Wl,--force-exe-suffix \
$(FOAM_EXTRA_LDFLAGS)
......@@ -6,7 +6,8 @@ LD = x86_64-w64-mingw32-ld
AR = x86_64-w64-mingw32-ar
RANLIB = x86_64-w64-mingw32-ranlib
PROJECT_LIBS = -l$(WM_PROJECT) -L$(FOAM_LIBBIN)/dummy -lPstream
PROJECT_LIBS = -l$(WM_PROJECT) \
-L$(FOAM_LIBBIN)/dummy -lPstream
include $(GENERAL_RULES)/standard
......
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
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++
# -----------------------------------------------------------------------------
CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Clang/openmp
ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/no-openmp
endif
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++