classes: create proper compiler and linker wrappers

Rust builds (custom build.rs and gcc-rs users) expect to have the
compiler and the linker available to them as a single command with no
white space trailing. Yocto unfortunately does not conform to that. The
build compiler and linker almost always have a trailing space due to
how the variables are composed and the target compiler and linker are
almost always more than a single command. Then if you throw ccache into
the mix you'll get another command. As a result to handle all these
cases properly there need to be wrappers created. This change creates
wrappers for both build and target and both the linker and compiler.
This likely fixes #76.
This commit is contained in:
Doug Goldstein
2016-11-27 23:42:20 -06:00
parent 168396820d
commit 864fe95722
2 changed files with 51 additions and 8 deletions
+3 -8
View File
@@ -30,9 +30,6 @@ export PKG_CONFIG_ALLOW_CROSS = "1"
cargo_do_configure () {
mkdir -p ${CARGO_HOME}
# NOTE: we cannot pass more flags via this interface, the 'linker' is
# assumed to be a path to a binary. If flags are needed, a wrapper must
# be used.
echo "paths = [" > ${CARGO_HOME}/config
for p in ${EXTRA_OECARGO_PATHS}; do
@@ -62,7 +59,7 @@ EOF
done | sed -e 's/$/,/' >> ${CARGO_HOME}/config
echo "]" >> ${CARGO_HOME}/config
echo "[target.${RUST_HOST_SYS}]" >> ${CARGO_HOME}/config
echo "linker = '${HOST_PREFIX}gcc'" >> ${CARGO_HOME}/config
echo "linker = '${RUST_TARGET_CCLD}'" >> ${CARGO_HOME}/config
}
# All the rust & cargo ecosystem assume that CC, LD, etc are a path to a single
@@ -70,9 +67,7 @@ EOF
# XXX: this is hard coded based on meta/conf/bitbake.conf
# TODO: we do quite a bit very similar to this in rust.inc, see if it can be
# generalized.
export RUST_CC = "${CCACHE}${HOST_PREFIX}gcc"
export RUST_CFLAGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${CFLAGS}"
export RUST_BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc"
export RUST_BUILD_CFLAGS = "${BUILD_CC_ARCH} ${BUILD_CFLAGS}"
CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} --release"
@@ -89,10 +84,10 @@ oe_cargo_build () {
}
oe_cargo_fix_env () {
export CC="${RUST_CC}"
export CC="${RUST_TARGET_CC}"
export CFLAGS="${RUST_CFLAGS}"
export AR="${AR}"
export TARGET_CC="${RUST_CC}"
export TARGET_CC="${RUST_TARGET_CC}"
export TARGET_CFLAGS="${RUST_CFLAGS}"
export TARGET_AR="${AR}"
export HOST_CC="${RUST_BUILD_CC}"