Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/rust: provide RUSTFLAGS for cargo
@ 2024-03-02 23:29 Romain Naour
  2024-03-04 19:27 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Romain Naour @ 2024-03-02 23:29 UTC (permalink / raw)
  To: buildroot; +Cc: Romain Naour

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

But the host-rust package doesn't use the cargo infractructure (since
it provide cargo binary) and some cargo environment varialble [1] is
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
include 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?ref_type=tags#L167

Signed-off-by: Romain Naour <romain.naour@smile.fr>
---
v2: no change
v3: use $(HOST_PKG_CARGO_ENV) to provide RUSTFLAGS along with CARGO_HOME. (Yann)
---
 package/rust/rust.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/rust/rust.mk b/package/rust/rust.mk
index 4903060368..c544582c99 100644
--- a/package/rust/rust.mk
+++ b/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 = \
-- 
2.43.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH] package/rust: provide RUSTFLAGS for cargo
  2024-03-02 23:29 [Buildroot] [PATCH] package/rust: provide RUSTFLAGS for cargo Romain Naour
@ 2024-03-04 19:27 ` Yann E. MORIN
  0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2024-03-04 19:27 UTC (permalink / raw)
  To: Romain Naour; +Cc: buildroot

Romain, All,

On 2024-03-03 00:29 +0100, Romain Naour spake thusly:
> While building the rust toolchain, the build system endup using
> cargo (from [...]/output/build/host-rust-bin-1.74.1/cargo/bin/cargo)
> to build some tool like rustdoc-tool.
> 
> But the host-rust package doesn't use the cargo infractructure (since
> it provide cargo binary) and some cargo environment varialble [1] is
> 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
> include 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?ref_type=tags#L167
> 
> Signed-off-by: Romain Naour <romain.naour@smile.fr>

Applied to master, after slight rewording in the commit log, thanks.

Regards,
Yann E. MORIN.

> ---
> v2: no change
> v3: use $(HOST_PKG_CARGO_ENV) to provide RUSTFLAGS along with CARGO_HOME. (Yann)
> ---
>  package/rust/rust.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/package/rust/rust.mk b/package/rust/rust.mk
> index 4903060368..c544582c99 100644
> --- a/package/rust/rust.mk
> +++ b/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 = \
> -- 
> 2.43.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-04 19:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-02 23:29 [Buildroot] [PATCH] package/rust: provide RUSTFLAGS for cargo Romain Naour
2024-03-04 19:27 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox