build: detect architecture via cc -dumpmachine

Similar to commit 98f84e6255 ("build: detect OS via cc -dumpmachine"),
we can use the C compiler's -dumpmachine output to detect the target
CPU architecture rather than relying on the build machine's uname
output.  This helps enable correct CPU detection when $(CC) is a cross
compiler.

Change-Id: I72c34294a1ff7dd9df3aa45dfc319e5b81d51f85
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/385709
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2017-11-03 15:55:55 -07:00
parent 1a2dc66189
commit 826c9ef64a

View File

@ -57,11 +57,11 @@ ifneq ($(filter freebsd%,$(TARGET_TRIPLET_WORDS)),)
OS = FreeBSD
endif
TARGET_MACHINE := $(firstword $(TARGET_TRIPLET_WORDS))
COMMON_CFLAGS = -g $(C_OPT) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -fno-strict-aliasing -I$(SPDK_ROOT_DIR)/include
UNAME_P := $(shell uname -p)
ifneq ($(filter ppc%,$(UNAME_P)),)
ifneq ($(filter powerpc%,$(TARGET_MACHINE)),)
COMMON_CFLAGS += -mcpu=native
else
COMMON_CFLAGS += -march=native