cargo.bbclass: ensure extra RUSTFLAGS are properly passed
The RUSTFLAGS env var overrides the rustflags specified in the cargo config so we need to take anything passed in the environment variable and put it in the config.
This commit is contained in:
@@ -54,7 +54,13 @@ EOF
|
|||||||
# and uses HOST to be the currently selected one. However
|
# and uses HOST to be the currently selected one. However
|
||||||
# LDFLAGS and TOOLCHAIN_OPTIONS are not prefixed with HOST
|
# LDFLAGS and TOOLCHAIN_OPTIONS are not prefixed with HOST
|
||||||
echo "[build]" >> ${CARGO_HOME}/config
|
echo "[build]" >> ${CARGO_HOME}/config
|
||||||
echo "rustflags = ['-C', 'link-args=${LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}']" >> ${CARGO_HOME}/config
|
echo "rustflags = [" >> ${CARGO_HOME}/config
|
||||||
|
echo "'-C'," >> ${CARGO_HOME}/config
|
||||||
|
echo "'link-args=${LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}'," >> ${CARGO_HOME}/config
|
||||||
|
for p in ${RUSTFLAGS}; do
|
||||||
|
printf "'%s'\n" "$p"
|
||||||
|
done | sed -e 's/$/,/' >> ${CARGO_HOME}/config
|
||||||
|
echo "]" >> ${CARGO_HOME}/config
|
||||||
echo "[target.${RUST_HOST_SYS}]" >> ${CARGO_HOME}/config
|
echo "[target.${RUST_HOST_SYS}]" >> ${CARGO_HOME}/config
|
||||||
echo "linker = '${HOST_PREFIX}gcc'" >> ${CARGO_HOME}/config
|
echo "linker = '${HOST_PREFIX}gcc'" >> ${CARGO_HOME}/config
|
||||||
}
|
}
|
||||||
@@ -75,6 +81,7 @@ CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} --release"
|
|||||||
# change if CARGO_BUILD_FLAGS changes.
|
# change if CARGO_BUILD_FLAGS changes.
|
||||||
CARGO_TARGET_SUBDIR="${HOST_SYS}/release"
|
CARGO_TARGET_SUBDIR="${HOST_SYS}/release"
|
||||||
oe_cargo_build () {
|
oe_cargo_build () {
|
||||||
|
unset RUSTFLAGS
|
||||||
bbnote "cargo = $(which cargo)"
|
bbnote "cargo = $(which cargo)"
|
||||||
bbnote "rustc = $(which rustc)"
|
bbnote "rustc = $(which rustc)"
|
||||||
bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
|
bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ SRC_URI = "\
|
|||||||
|
|
||||||
B = "${S}"
|
B = "${S}"
|
||||||
|
|
||||||
|
# Can't use the default from rust-vars as it cause a compiler crash
|
||||||
|
# the crate_hash option will cause the compiler to crash
|
||||||
|
RUSTFLAGS = "-C rpath ${RUSTLIB}"
|
||||||
|
|
||||||
PACKAGECONFIG ??= ""
|
PACKAGECONFIG ??= ""
|
||||||
|
|
||||||
# Note: this does not appear to work very well due to our use of bitbake triples
|
# Note: this does not appear to work very well due to our use of bitbake triples
|
||||||
|
|||||||
Reference in New Issue
Block a user