Commit 4200774d authored by Mark Olesen's avatar Mark Olesen
Browse files

CONFIG: improve support for compiler derivatives (#1671)

- add '[-+.~]' to the recognized qualifiers.
  This allows simple readable names such as

      WM_COMPILER=Clang-vendor

  but also opens the FUTURE (not yet supported) possibility of
  combining in additional information. For example,

      WM_COMPILER=Clang~openmp
      WM_COMPILER=Clang+cuda~openmp

  by using '+' (add) and '~' (subtract) notation similar to what
  spack uses.

CONFIG: support 'override' rules

- if present, compiler-family 'override' rules are included after
  compiler-family 'general' rules have been included. This allows a
  central means for including dynamically generated content to
  override some values.

  Some examples:

  To handle different gcc versions (system compiler):

  wmake/rules/...Gcc/override

  ```
  ifneq (,$(findstring 9, $(WM_COMPILER)))
      cc  := gcc-9
      CC  := g++-9 -std=c++11
  endif
  ```

  To handle different openmp on Darwin (#1656):

  wmake/rules/darwin64Clang/override

  ```
  # Use libomp (not libgomp) unless openmp is disabled
  ifeq (,$(findstring "~openmp", "$(WM_COMPILER)"))
      COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
      LINK_OPENMP = -lomp
  else
      include $(GENERAL_RULES)/no-openmp
  endif
  ```

  This treatment arguably fits into wmake/rules/darwin64Clang/general,
  but it serves to illustrate a possible use case.
parent 04b5291c
......@@ -14,25 +14,29 @@ GLIBS = -lm
GLIB_LIBS =
COMPILER_FAMILY = $(shell echo "$(WM_COMPILER)" | sed -e 's/[0-9].*//')
DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_FAMILY)
RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
ARCHITECTURE_RULES = $(WM_DIR)/rules/$(WM_ARCH)
COMPILER_FAMILY = $(shell echo "$(WM_COMPILER)" | sed -e 's/[-+.0-9~].*//')
DEFAULT_RULES = $(ARCHITECTURE_RULES)$(COMPILER_FAMILY)
RULES = $(ARCHITECTURE_RULES)$(WM_COMPILER)
WMAKE_BIN = $(WM_PROJECT_DIR)/platforms/tools/$(WM_ARCH)$(WM_COMPILER)
# Default compilation is 'Opt' - never permit an empty value
ifeq ($(WM_COMPILE_OPTION),)
ifeq (,$(WM_COMPILE_OPTION))
WM_COMPILE_OPTION = Opt
endif
ifeq ($(WM_SCHEDULER),)
ifeq (,$(WM_SCHEDULER))
AND = &&
else
AND = '&&'
endif
include $(DEFAULT_RULES)/general
sinclude $(DEFAULT_RULES)/override
ifneq ("$(COMPILER_FAMILY)","$(WM_COMPILER)")
sinclude $(RULES)/general
sinclude $(RULES)/c++
endif
include $(GENERAL_RULES)/transform
#------------------------------------------------------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment