From 3c47efa808baf7224194373a27ae56035a4a2ba6 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 10 Feb 2019 19:07:28 +0100 Subject: [PATCH] common: expose build profile in cross env [ci skip] --- common/build-profiles/README | 4 ++++ common/xbps-src/shutils/common.sh | 32 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/common/build-profiles/README b/common/build-profiles/README index 23cb38945e..e4457c16f2 100644 --- a/common/build-profiles/README +++ b/common/build-profiles/README @@ -9,3 +9,7 @@ for a specific architecture: - XBPS_CXXFLAGS (C++ compiler flags for the host compiler) - XBPS_FFLAGS (Fortran compiler flags for the host compiler) - XBPS_RUST_TARGET (the compiler triplet for usage by cargo) + +These properties are also set in a cross environment, but the compiler +flags are not added into the global flags. XBPS_RUST_TARGET is also +exposed as RUST_BUILD instead of RUST_TARGET. diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index a914ce1ac4..cdf1803a4d 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -436,21 +436,21 @@ setup_pkg() { dbgflags="-g" fi - if [ -z "$cross" ]; then - if [ -z "$CHROOT_READY" ]; then - source_file ${XBPS_COMMONDIR}/build-profiles/bootstrap.sh - else - source_file ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh - fi + # build profile is used always in order to expose the host triplet, + # but the compiler flags from it are only used when not crossing + if [ -z "$CHROOT_READY" ]; then + source_file ${XBPS_COMMONDIR}/build-profiles/bootstrap.sh + else + source_file ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh fi set_build_options - export CFLAGS="$XBPS_TARGET_CFLAGS $XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags" - export CXXFLAGS="$XBPS_TARGET_CXXFLAGS $XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags" - export FFLAGS="$XBPS_TARGET_FFLAGS $XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS" - export CPPFLAGS="$XBPS_TARGET_CPPFLAGS $XBPS_CPPFLAGS $XBPS_CROSS_CPPFLAGS $CPPFLAGS" - export LDFLAGS="$XBPS_TARGET_LDFLAGS $XBPS_LDFLAGS $XBPS_CROSS_LDFLAGS $LDFLAGS" + export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags" + export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags" + export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS" + export CPPFLAGS="$XBPS_CPPFLAGS $XBPS_CROSS_CPPFLAGS $CPPFLAGS" + export LDFLAGS="$XBPS_LDFLAGS $XBPS_CROSS_LDFLAGS $LDFLAGS" export BUILD_CC="cc" export BUILD_CFLAGS="$XBPS_CFLAGS" @@ -530,7 +530,16 @@ setup_pkg() { export RUSTFLAGS="$XBPS_CROSS_RUSTFLAGS" # Rust target, which differs from our triplets export RUST_TARGET="$XBPS_CROSS_RUST_TARGET" + # Rust build, which is the host system, may also differ + export RUST_BUILD="$XBPS_RUST_TARGET" else + # Target flags from build-profile + export CFLAGS="$XBPS_TARGET_CFLAGS $CFLAGS" + export CXXFLAGS="$XBPS_TARGET_CXXFLAGS $CXXFLAGS" + export FFLAGS="$XBPS_TARGET_FFLAGS $FFLAGS" + export CPPFLAGS="$XBPS_TARGET_CPPFLAGS $CPPFLAGS" + export LDFLAGS="$XBPS_TARGET_LDFLAGS $LDFLAGS" + # Tools export CC="cc" export CXX="g++" export CPP="cpp" @@ -546,6 +555,7 @@ setup_pkg() { export NM="nm" export READELF="readelf" export RUST_TARGET="$XBPS_RUST_TARGET" + export RUST_BUILD="$XBPS_RUST_TARGET" # Unset cross evironment variables unset CC_target CXX_target CPP_target GCC_target FC_target LD_target AR_target AS_target unset RANLIB_target STRIP_target OBJDUMP_target OBJCOPY_target NM_target READELF_target