Message ID | 20250703084219.268506-1-skandigraun@gmail.com |
---|---|
State | Under Review |
Headers | show |
Series | [meta-oe] mozjs-128: avoid using build host's rust toolchain | expand |
diff --git a/meta-oe/recipes-extended/mozjs/mozjs-128_128.5.2.bb b/meta-oe/recipes-extended/mozjs/mozjs-128_128.5.2.bb index ceb81d07e5..e327cd7723 100644 --- a/meta-oe/recipes-extended/mozjs/mozjs-128_128.5.2.bb +++ b/meta-oe/recipes-extended/mozjs/mozjs-128_128.5.2.bb @@ -57,6 +57,10 @@ export HOST_CXXFLAGS = "${BUILD_CXXFLAGS}" export AS = "${CC}" +# ensure that the correct rust binaries are used +export CARGO = "${STAGING_BINDIR_NATIVE}/cargo" +export RUSTC = "${STAGING_BINDIR_NATIVE}/rustc" + export MOZBUILD_STATE_PATH = "${WORKDIR}/mozbuild_state" export RUSTFLAGS
mozjs uses Rust to build parts of the application, however it doesn't leverage the cargo class, as it uses a Makefile to build. Due to this, only Rust class is inherited in the recipe, so the toolchain itself is available. The Cargo class is not inherited, to avoid the Yocto specific Cargo build logic. However in case Cargo class is not inherited, some Cargo specific environment variables are not set (most notably CARGO_HOME, CARGO and RUSTC - the latter two are derived from the content of CARGO_HOME, unless they are set explicitly), and Cargo tries to guess where the Rust toolchain is. Usually it guesses correctly, and uses the Yocto toolchain. However in case there is no CARGO_HOME environment variable set and the build host has a Rust toolchain available, and a ~/.cargo folder is present, then its toolchain configuration has a higher priority than the toolchain in the PATH[1], and the compilation fails due to the incorrect toolchain. To avoid this, make the CARGO and RUSTC environment variables to point to the Yocto toolchain. That way even if CARGO_HOME not defined, the correct tools will be used. [1]: https://github.com/rust-lang/rust/blob/master/src/tools/rust-analyzer/crates/toolchain/src/lib.rs#L28 Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> --- meta-oe/recipes-extended/mozjs/mozjs-128_128.5.2.bb | 4 ++++ 1 file changed, 4 insertions(+)