Define a cpp macro specific to BLIS compilation.

Details:
- Tweaked the cflags functions in common.mk so that a new preprocessor
  macro, BLIS_IS_BUILDING_LIBRARY, is defined, but only when BLIS
  itself is being built. This macro will not be defined when, for
  example, the testsuite or example code compiles code local to those
  applications. This was done in part by defining a new cflags function
  get-user-cflags-for(), which is now the designated function for
  application Makefiles if they wish to inherit a basic set of CFLAGS
  from BLIS. (The compiler flags returned are identical to that of
  get-frame-cflags-for() except that -DBLIS_IS_BUILDING_LIBRARY is
  omitted.)
- Updated all test driver-like makefiles to call get-user-cflags-for()
  instead of get-frame-cflags-for().
This commit is contained in:
Field G. Van Zee
2018-09-07 17:24:32 -05:00
parent cc2cca4f56
commit 4b5437ec7a
11 changed files with 89 additions and 65 deletions

View File

@@ -122,12 +122,12 @@ DRIVER3_BASES := $(filter %3,$(DRIVER_BASES))
#BLASTEST_CHECK := $(DIST_PATH)/$(BUILD_DIR)/check-blastest.sh
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Suppress warnings about uninitialized functions, add local header
# paths and the path to blis.h to CFLAGS.

114
common.mk
View File

@@ -93,64 +93,84 @@ endef
# included, which results in those values having been stored to
# configuration-qualified variables.
get-noopt-cflags-for = $(strip $(CFLAGS_PRESET) \
$(call load-var-for,CDBGFLAGS,$(1)) \
$(call load-var-for,CWARNFLAGS,$(1)) \
$(call load-var-for,CPICFLAGS,$(1)) \
$(call load-var-for,CMISCFLAGS,$(1)) \
$(call load-var-for,CLANGFLAGS,$(1)) \
$(call load-var-for,CPPROCFLAGS,$(1)) \
$(CTHREADFLAGS) \
$(CINCFLAGS) $(VERS_DEF) \
)
get-noopt-cflags-for = $(strip $(CFLAGS_PRESET) \
$(call load-var-for,CDBGFLAGS,$(1)) \
$(call load-var-for,CWARNFLAGS,$(1)) \
$(call load-var-for,CPICFLAGS,$(1)) \
$(call load-var-for,CMISCFLAGS,$(1)) \
$(call load-var-for,CLANGFLAGS,$(1)) \
$(call load-var-for,CPPROCFLAGS,$(1)) \
$(CTHREADFLAGS) \
$(CINCFLAGS) $(VERS_DEF) \
)
get-noopt-cxxflags-for = $(strip $(CFLAGS_PRESET) \
$(call load-var-for,CDBGFLAGS,$(1)) \
$(call load-var-for,CWARNFLAGS,$(1)) \
$(call load-var-for,CPICFLAGS,$(1)) \
$(call load-var-for,CMISCFLAGS,$(1)) \
$(call load-var-for,CXXLANGFLAGS,$(1)) \
$(call load-var-for,CPPROCFLAGS,$(1)) \
$(CTHREADFLAGS) \
$(CINCFLAGS) $(VERS_DEF) \
)
get-noopt-cxxflags-for = $(strip $(CFLAGS_PRESET) \
$(call load-var-for,CDBGFLAGS,$(1)) \
$(call load-var-for,CWARNFLAGS,$(1)) \
$(call load-var-for,CPICFLAGS,$(1)) \
$(call load-var-for,CMISCFLAGS,$(1)) \
$(call load-var-for,CXXLANGFLAGS,$(1)) \
$(call load-var-for,CPPROCFLAGS,$(1)) \
$(CTHREADFLAGS) \
$(CINCFLAGS) $(VERS_DEF) \
)
get-refinit-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
-DBLIS_CNAME=$(1) \
)
get-refinit-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
-DBLIS_CNAME=$(1) \
$(BUILD_FLAGS) \
)
get-refkern-cflags-for = $(strip $(call load-var-for,CROPTFLAGS,$(1)) \
$(call load-var-for,CRVECFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
-DBLIS_CNAME=$(1) \
)
get-refkern-cflags-for = $(strip $(call load-var-for,CROPTFLAGS,$(1)) \
$(call load-var-for,CRVECFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
-DBLIS_CNAME=$(1) \
$(BUILD_FLAGS) \
)
get-config-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
)
get-config-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(BUILD_FLAGS) \
)
get-frame-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
)
get-frame-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(BUILD_FLAGS) \
)
get-kernel-cflags-for = $(strip $(call load-var-for,CKOPTFLAGS,$(1)) \
$(call load-var-for,CKVECFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
)
get-kernel-cflags-for = $(strip $(call load-var-for,CKOPTFLAGS,$(1)) \
$(call load-var-for,CKVECFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(BUILD_FLAGS) \
)
# When compiling sandboxes, we use flags similar to those of general framework
# source. This ensures that the same code can be linked and run across various
# sub-configurations. (If we switch to using refkern/kernel flags, we should
# prevent enabling sandboxes for umbrella families by verifying that
# config_list == config_name if --enable-sandbox is given.)
get-sandbox-c99flags-for = $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(CSBOXINCFLAGS)
get-sandbox-cxxflags-for = $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cxxflags-for,$(1)) \
$(CSBOXINCFLAGS)
get-sandbox-c99flags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(CSBOXINCFLAGS) \
$(BUILD_FLAGS) \
)
get-sandbox-cxxflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cxxflags-for,$(1)) \
$(CSBOXINCFLAGS) \
$(BUILD_FLAGS) \
)
# Define a separate function that will return appropriate flags for use by
# applications that want to use the same basic flags as those used when BLIS
# was compiled. (This is the same as get-frame-cflags-for(), except that it
# omits the BUILD_FLAGS, which are exclusively for use when BLIS is being
# compiled.)
get-user-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
)
# Define functions that return messages appropriate for each non-verbose line
# of compilation output.
get-noopt-text = "(CFLAGS for no optimization)"
get-refinit-text-for = "('$(1)' CFLAGS for ref. kernel init)"
get-refkern-text-for = "('$(1)' CFLAGS for ref. kernels)"
@@ -872,6 +892,10 @@ BLIS_CONFIG_H := ./bli_config.h
# can be embedded into the library and queried later.
VERS_DEF := -DBLIS_VERSION_STRING=\"$(VERSION)\"
# Define a C preprocessor flag that is *only* defined when BLIS is being
# compiled.
BUILD_FLAGS := -DBLIS_IS_BUILDING_LIBRARY
# end of ifndef COMMON_MK_INCLUDED conditional block

View File

@@ -103,12 +103,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -91,12 +91,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -123,12 +123,12 @@ TEST_OBJS := $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -150,12 +150,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS.
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -139,12 +139,12 @@ TEST_OBJS := $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -132,12 +132,12 @@ TEST_OBJ_PATH := .
TEST_SIZES_SRC := test_size.c
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -157,12 +157,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS.
CFLAGS += -g -I$(TEST_SRC_PATH)

View File

@@ -93,12 +93,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add installed and local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)

View File

@@ -92,12 +92,12 @@ TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
# Override the value of CINCFLAGS so that the value of CFLAGS returned by
# get-frame-cflags-for() is not cluttered up with include paths needed only
# get-user-cflags-for() is not cluttered up with include paths needed only
# while building BLIS.
CINCFLAGS := -I$(INC_PATH)
# Use the "framework" CFLAGS for the configuration family.
CFLAGS := $(call get-frame-cflags-for,$(CONFIG_NAME))
CFLAGS := $(call get-user-cflags-for,$(CONFIG_NAME))
# Add local header paths to CFLAGS
CFLAGS += -I$(TEST_SRC_PATH)