Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix host and target linker problem #133

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions classes/cargo.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,7 @@ CARGO_BUILD_FLAGS = "\
"

create_cargo_config() {
if [ "${RUST_BUILD}" != "${RUST_TARGET}" ]; then
echo > ${CARGO_HOME}/config
echo "[target.${RUST_BUILD}]" >> ${CARGO_HOME}/config
echo "linker = '${WRAPPER_DIR}/linker-native-wrapper.sh'" >> ${CARGO_HOME}/config

echo >> ${CARGO_HOME}/config
echo "[target.${RUST_TARGET}]" >> ${CARGO_HOME}/config
echo "linker = '${WRAPPER_DIR}/linker-wrapper.sh'" >> ${CARGO_HOME}/config
else
echo > ${CARGO_HOME}/config
echo "[target.${RUST_TARGET}]" >> ${CARGO_HOME}/config
echo "linker = '${WRAPPER_DIR}/linker-wrapper.sh'" >> ${CARGO_HOME}/config
fi

echo >> ${CARGO_HOME}/config
echo > ${CARGO_HOME}/config
echo "[build]" >> ${CARGO_HOME}/config
echo "rustflags = ['-C', 'rpath']" >> ${CARGO_HOME}/config

Expand Down Expand Up @@ -116,8 +102,8 @@ cargo_do_compile() {
export TARGET_CXX="${WRAPPER_DIR}/cxx-wrapper.sh"
export CC="${WRAPPER_DIR}/cc-native-wrapper.sh"
export CXX="${WRAPPER_DIR}/cxx-native-wrapper.sh"
export TARGET_LD="${WRAPPER_DIR}/ld-wrapper.sh"
export LD="${WRAPPER_DIR}/ld-native-wrapper.sh"
export TARGET_LD="${WRAPPER_DIR}/linker-wrapper.sh"
export LD="${WRAPPER_DIR}/linker-native-wrapper.sh"
export PKG_CONFIG_ALLOW_CROSS="1"
export LDFLAGS=""
export RUSTFLAGS="${RUSTFLAGS}"
Expand All @@ -126,6 +112,27 @@ cargo_do_compile() {
bbnote "which cargo:" `which cargo`
bbnote "cargo --version" `cargo --version`
bbnote cargo build ${CARGO_BUILD_FLAGS}

# __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" is to allow
# using nighly features on stable releases, i.e features that are not
# yet considered stable.
#
# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
# configuration option target-applies-to-host value to be set
#
# CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
# for this feature, which we disable, to make sure builds where target
# arch == host arch work correctly
#
# CARGO_UNSTABLE_HOST_CONFIG="true" enables the configuration option
# CARGO_HOST_LINKER value to be set
export __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly"
export CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true"
export CARGO_TARGET_APPLIES_TO_HOST="false"
export CARGO_UNSTABLE_HOST_CONFIG="true"
export CARGO_HOST_LINKER="${WRAPPER_DIR}/linker-native-wrapper.sh"
export CARGO_TARGET_${@d.getVar('RUST_TARGET', True).upper().replace('-','_')}_LINKER="${WRAPPER_DIR}/linker-wrapper.sh"

cargo build ${CARGO_BUILD_FLAGS}
}

Expand Down