Skip to content

Commit

Permalink
Communicate cc, cc_vendor to make via config.mk.
Browse files Browse the repository at this point in the history
Details:
- Historically, the compiler selection has happened statically in the
  various make_defs.mk and would only be overriden by setting CC (either
  prior to running configure or as a configure argument). However, in
  the last couple months, configure has evolved to contain rather
  sophisticated compiler detection logic for the purposes of blacklisting
  sub-configurations. It only makes sense that configure now fully take
  over the responsibility of selecting a compiler from the GNU make side
  of the build system. Thanks to Alex Arslan for his help exposing this
  issue.
- Substitute found_cc into CC in config.mk via configure.
- Set a new variable, CC_VENDOR, in config.mk via substitution from
  configure, and disable the corresponding CC_VENDOR code in common.mk.
- Disabled default compiler selection (usually gcc) in the sub-configs'
  various make_def.mk files.
  • Loading branch information
fgvanzee committed May 14, 2018
1 parent 20af119 commit ad67dc4
Show file tree
Hide file tree
Showing 26 changed files with 23 additions and 131 deletions.
1 change: 1 addition & 0 deletions build/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ endif

# The C compiler.
CC := @CC@
CC_VENDOR := @CC_VENDOR@
RANLIB := @RANLIB@

# The level of debugging info to generate.
Expand Down
32 changes: 16 additions & 16 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,22 @@ GIT_LOG := $(GIT) log --decorate
# --- Determine the compiler vendor --------------------------------------------
#

ifneq ($(CC),)

VENDOR_STRING := $(shell $(CC) --version 2>/dev/null)
ifeq ($(VENDOR_STRING),)
VENDOR_STRING := $(shell $(CC) -qversion 2>/dev/null)
endif
ifeq ($(VENDOR_STRING),)
$(error Unable to determine compiler vendor.)
endif

CC_VENDOR := $(firstword $(shell echo '$(VENDOR_STRING)' | $(EGREP) -o 'icc|gcc|clang|ibm|cc'))
ifeq ($(CC_VENDOR),)
$(error Unable to determine compiler vendor. Have you run './configure' yet?)
endif

endif
#ifneq ($(CC),)
#
#VENDOR_STRING := $(shell $(CC) --version 2>/dev/null)
#ifeq ($(VENDOR_STRING),)
#VENDOR_STRING := $(shell $(CC) -qversion 2>/dev/null)
#endif
#ifeq ($(VENDOR_STRING),)
#$(error Unable to determine compiler vendor.)
#endif
#
#CC_VENDOR := $(firstword $(shell echo '$(VENDOR_STRING)' | $(EGREP) -o 'icc|gcc|clang|ibm|cc'))
#ifeq ($(CC_VENDOR),)
#$(error Unable to determine compiler vendor. Have you run './configure' yet?)
#endif
#
#endif



Expand Down
5 changes: 0 additions & 5 deletions config/amd64/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := amd64
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/arm32/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := arm32
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/arm64/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := arm64
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
8 changes: 4 additions & 4 deletions config/bgq/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ THIS_CONFIG := bgq
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := /bgsys/drivers/ppcfloor/comm/gcc.legacy/bin/mpixlc_r
CC_VENDOR := ibm
endif
#ifeq ($(CC),)
#CC := /bgsys/drivers/ppcfloor/comm/gcc.legacy/bin/mpixlc_r
#CC_VENDOR := ibm
#endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
Expand Down
5 changes: 0 additions & 5 deletions config/bulldozer/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := bulldozer
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/cortexa15/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := cortexa15
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/cortexa57/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := cortexa57
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/cortexa9/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := cortexa9
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/excavator/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := excavator
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/generic/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := generic
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/haswell/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := haswell
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/intel64/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := intel64
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/knc/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := knc
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := icc
CC_VENDOR := icc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/knl/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := knl
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/penryn/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := penryn
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/piledriver/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := piledriver
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/power7/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := power7
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/sandybridge/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := sandybridge
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/skx/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := skx
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/steamroller/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := steamroller
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/template/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := template
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/x86_64/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := x86_64
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
5 changes: 0 additions & 5 deletions config/zen/make_defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ THIS_CONFIG := zen
# --- Determine the C compiler and related flags ---
#

ifeq ($(CC),)
CC := gcc
CC_VENDOR := gcc
endif

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
Expand Down
3 changes: 2 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ main()
install_libdir_esc=$(echo "${install_libdir}" | sed 's/\//\\\//g')
install_incdir_esc=$(echo "${install_incdir}" | sed 's/\//\\\//g')
dist_path_esc=$(echo "${dist_path}" | sed 's/\//\\\//g')
cc_esc=$(echo "${CC}" | sed 's/\//\\\//g')
cc_esc=$(echo "${found_cc}" | sed 's/\//\\\//g')
ranlib_esc=$(echo "${RANLIB:-ranlib}" | sed 's/\//\\\//g')

# Create a #define for the configuration family (config_name).
Expand Down Expand Up @@ -2292,6 +2292,7 @@ main()
| sed -e "s/@os_name@/${os_name}/g" \
| sed -e "s/@dist_path@/${dist_path_esc}/g" \
| sed -e "s/@CC@/${cc_esc}/g" \
| sed -e "s/@CC_VENDOR@/${cc_vendor}/g" \
| sed -e "s/@RANLIB@/${ranlib_esc}/g" \
| sed -e "s/@debug_type@/${debug_type}/g" \
| sed -e "s/@threading_model@/${threading_model}/g" \
Expand Down

0 comments on commit ad67dc4

Please sign in to comment.