From 3def834c65c57d689f65f58821404ead785a358c Mon Sep 17 00:00:00 2001 From: Amelia Blachuciak Date: Tue, 9 Jul 2019 14:40:41 +0200 Subject: [PATCH] make: add cross-compilation support There might be a need for user to cross-compile SPDK for other platforms than native. Since DPDK supports cross-compilation already, only enablement of cross-compilation for SPDK is missing. This patch aims to provide the user with additional option to configure script that works similar to what DPDK already provides. To enable cross-compilation run ./configure.sh with additional --cross-prefix parameter. The parameter should work in similar manner to DPDK CROSS parameter and specifies prefix of cross-compiler defined in PATH variable. Note: To cross-compile, toolchain must have SPDK dependencies such as e.g. Libaio. Signed-off-by: Amelia Blachuciak Change-Id: Ia7cb879d39d624552cad1af98a563070ea7676b2 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460977 Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Reviewed-by: Darek Stojaczyk Reviewed-by: Paul Luse Tested-by: SPDK CI Jenkins --- CONFIG | 3 +++ configure | 8 +++++++- dpdkbuild/Makefile | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CONFIG b/CONFIG index e2bb8a358..1a1515e73 100644 --- a/CONFIG +++ b/CONFIG @@ -37,6 +37,9 @@ CONFIG_PREFIX="/usr/local" # Target architecture CONFIG_ARCH=native +# Prefix for cross compilation +CONFIG_CROSS_PREFIX= + # Build with debug logging. Turn off for performance testing and normal usage CONFIG_DEBUG=n diff --git a/configure b/configure index 2669cbbef..7c7d7f583 100755 --- a/configure +++ b/configure @@ -18,6 +18,9 @@ function usage() echo " --prefix=path Configure installation prefix (default: /usr/local)" echo " --target-arch=arch Target build architecture. Must be a valid GNU arch. Default: native" echo "" + echo " --cross-prefix=prefix Prefix for cross compilation (default: none)" + echo " example: aarch64-linux-gnu" + echo "" echo " --enable-debug Configure for debug builds" echo " --enable-log-bt Enable support of backtrace printing in SPDK logs (requires libunwind)." echo " --enable-werror Treat compiler warnings as errors" @@ -124,6 +127,9 @@ for i in "$@"; do --target-arch=*) CONFIG[ARCH]="${i#*=}" ;; + --cross-prefix=*) + CONFIG[CROSS_PREFIX]="${i#*=}" + ;; --enable-debug) CONFIG[DEBUG]=y ;; @@ -342,7 +348,7 @@ for i in "$@"; do done # Detect the compiler toolchain -scripts/detect_cc.sh --cc="$CC" --cxx="$CXX" --lto="${CONFIG[LTO]}" --ld="$LD" > mk/cc.mk +scripts/detect_cc.sh --cc="$CC" --cxx="$CXX" --lto="${CONFIG[LTO]}" --ld="$LD" --cross-prefix="${CONFIG[CROSS_PREFIX]}" > mk/cc.mk CC=$(cat mk/cc.mk | grep "CC=" | cut -d "=" -f 2) CC_TYPE=$(cat mk/cc.mk | grep "CC_TYPE=" | cut -d "=" -f 2) diff --git a/dpdkbuild/Makefile b/dpdkbuild/Makefile index e086998ed..e458af28a 100644 --- a/dpdkbuild/Makefile +++ b/dpdkbuild/Makefile @@ -93,6 +93,10 @@ else DPDK_CONFIG := $(TARGET_MACHINE)-native endif +ifneq ($(CONFIG_CROSS_PREFIX),) +DPDK_OPTS += CROSS=$(CONFIG_CROSS_PREFIX)- +endif + ifeq ($(OS),Linux) DPDK_CONFIG := $(DPDK_CONFIG)-linuxapp NPROC := $(shell nproc)