Commit 826c9ef6 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

build: detect architecture via cc -dumpmachine



Similar to commit 98f84e62 ("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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/385709


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1a2dc661
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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