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 <amelia.blachuciak@intel.com>
Change-Id: Ia7cb879d39d624552cad1af98a563070ea7676b2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460977
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Amelia Blachuciak 2019-07-09 14:40:41 +02:00 committed by Jim Harris
parent 1a56982da3
commit 3def834c65
3 changed files with 14 additions and 1 deletions

3
CONFIG
View File

@ -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

8
configure vendored
View File

@ -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)

View File

@ -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)