Commit 3def834c authored by Amelia Blachuciak's avatar Amelia Blachuciak Committed by Jim Harris
Browse files

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: default avatarAmelia Blachuciak <amelia.blachuciak@intel.com>
Change-Id: Ia7cb879d39d624552cad1af98a563070ea7676b2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460977


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 1a56982d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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

+7 −1
Original line number Diff line number Diff line
@@ -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)
+4 −0
Original line number Diff line number Diff line
@@ -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)