Browse Source

package/rust: provide RUSTFLAGS for cargo

While building the rust toolchain, the build system ends up using
cargo (from [...]/output/build/host-rust-bin-1.74.1/cargo/bin/cargo)
to build some tools like rustdoc-tool.

But the host-rust package doesn't use the cargo infractructure (since
it provides cargo binary) and our cargo environment variables [1] are
not set to crosscompile cargo packages in the rust toolchain.

For exemple, we usually set RUSTFLAGS="-C link-arg=-Wl,-rpath,$(HOST_DIR)/lib"
to force cargo using libraries provided by Buildroot in $(HOST_DIR)/lib.

RUSTFLAGS is actually needed to find zlib library (host-zlib) to link
rustdoc-tool when zlib is not installed on the host.

Add $(HOST_PKG_CARGO_ENV) in HOST_RUST_BUILD_CMDS since it already
includes RUSTFLAGS but also CARGO_HOME.

Fixes:

  error: could not compile `rustdoc-tool` (bin "rustdoc_tool_binary") due to previous error

[1] https://gitlab.com/buildroot.org/buildroot/-/blob/2024.02-rc1/package/pkg-cargo.mk#L165

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Romain Naour 1 year ago
parent
commit
20406b7159
1 changed files with 2 additions and 1 deletions
  1. 2 1
      package/rust/rust.mk

+ 2 - 1
package/rust/rust.mk

@@ -70,7 +70,8 @@ define HOST_RUST_CONFIGURE_CMDS
 endef
 
 define HOST_RUST_BUILD_CMDS
-	cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py build
+	cd $(@D); $(HOST_MAKE_ENV) $(HOST_PKG_CARGO_ENV) \
+		$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py build
 endef
 
 HOST_RUST_INSTALL_OPTS = \