Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Cc: buildroot@buildroot.org, Eric Le Bihan <eric.le.bihan.dev@free.fr>
Subject: Re: [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources
Date: Tue, 3 Feb 2026 14:33:27 +0100	[thread overview]
Message-ID: <aYH4ESxcsrQj_6pZ@windsurf> (raw)
In-Reply-To: <20250808133112.3212687-3-elmehdi.younes@smile.fr>

Hello,

Thanks for this patch, and sorry for the delay in reviewing
it. Generally the approach looks good, but we have a few comments, see
below.

On Fri, Aug 08, 2025 at 03:31:09PM +0200, El Mehdi YOUNES via buildroot wrote:
> Rust-for-Linux requires the Rust standard library sources (e.g. core/lib.rs)
> to enable CONFIG_RUST. This patch provides them in rust-bin while keeping the
> prebuilt compiler tarball unchanged.
> 
> It adds HOST_RUST_BIN_SOURCE_TARBALL = rustc-$(VER)-src.tar.xz to
> HOST_RUST_BIN_EXTRA_DOWNLOADS, and splits extra downloads into
> HOST_RUST_BIN_STD_TARBALLS (rust-std-*) and HOST_RUST_BIN_SOURCE_TARBALL so
> extraction is controlled separately: rust-std-* are unpacked under $(@D)/std,
> and rustc-<ver>-src.tar.xz is unpacked to rust-src then only the 'library/'
> subtree from the source tarball is installed $(HOST_DIR)/lib/rustlib/src/rust/.
> 
> The utils/update-rust script is also extended to generate the sha256 line for
> rustc-<ver>-src.tar.xz in package/rust-bin/rust-bin.hash.
> 
> see
> https://github.com/torvalds/linux/blob/master/Documentation/rust/quick-start.rst
> 
> Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
> ---
>  package/rust-bin/rust-bin.hash |  2 ++
>  package/rust-bin/rust-bin.mk   | 18 ++++++++++++++++--
>  utils/update-rust              |  9 +++++++++
>  3 files changed, 27 insertions(+), 2 deletions(-)

First of all, fixing package/rust-bin is not sufficient, you also need
to ensure that package/rust does the right thing. Indeed, we have two
ways of proving the Rust compiler in Buildroot: using a pre-compiled
Rust compiler (package/rust-bin) or building the Rust compiler from
source (package/rust). The Rust support in Linux should work for both
cases.

> diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk
> index 215bd84ad3..2195584f8f 100644
> --- a/package/rust-bin/rust-bin.mk
> +++ b/package/rust-bin/rust-bin.mk
> @@ -14,16 +14,19 @@ RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
>  HOST_RUST_BIN_PROVIDES = host-rustc
>  
>  HOST_RUST_BIN_SOURCE = rust-$(RUST_BIN_VERSION)-$(RUSTC_HOST_NAME).tar.xz
> +HOST_RUST_BIN_SOURCE_TARBALL = rustc-$(RUST_BIN_VERSION)-src.tar.xz
> +HOST_RUST_BIN_STD_TARBALLS =

Setting to an empty variable is not really needed.

>  
>  ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
> -HOST_RUST_BIN_EXTRA_DOWNLOADS += rust-std-$(RUST_BIN_VERSION)-$(RUSTC_TARGET_NAME).tar.xz
> +HOST_RUST_BIN_STD_TARBALLS += rust-std-$(RUST_BIN_VERSION)-$(RUSTC_TARGET_NAME).tar.xz

This could be just a = sign.

>  endif
>  
> +HOST_RUST_BIN_EXTRA_DOWNLOADS += $(HOST_RUST_BIN_SOURCE_TARBALL) $(HOST_RUST_BIN_STD_TARBALLS)
>  HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUSTC_HOST_NAME)
>  
>  define HOST_RUST_BIN_LIBSTD_EXTRACT
>  	mkdir -p $(@D)/std
> -	$(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \
> +	$(foreach f,$(HOST_RUST_BIN_STD_TARBALLS), \

The change from HOST_RUST_BIN_EXTRA_DOWNLOADS to
HOST_RUST_BIN_STD_TARBALLS could actually go in a separate,
preparatory commit. It would make the commit adding the installation
of Rust sources shorter and simpler to review.

>  		$(call suitable-extractor,$(f)) $(HOST_RUST_BIN_DL_DIR)/$(f) | \
>  			$(TAR) -C $(@D)/std $(TAR_OPTIONS) -
>  	)
> @@ -61,4 +64,15 @@ endef
>  
>  HOST_RUST_BIN_POST_INSTALL_HOOKS += HOST_RUST_INSTALL_CARGO_CONFIG
>  
> +define HOST_RUST_BIN_EXTRACT_SRC_LIBRARY
> +	mkdir -p $(@D)/rust-src
> +	$(call suitable-extractor,$(HOST_RUST_BIN_SOURCE_TARBALL)) \
> +	$(HOST_RUST_BIN_DL_DIR)/$(HOST_RUST_BIN_SOURCE_TARBALL) | \
> +	$(TAR) -C $(@D)/rust-src --strip-components=1 $(TAR_OPTIONS) -

Please indent follow-up lines, as such:

	$(call suitable-extractor,$(HOST_RUST_BIN_SOURCE_TARBALL)) \
	       $(HOST_RUST_BIN_DL_DIR)/$(HOST_RUST_BIN_SOURCE_TARBALL) | \
	       $(TAR) -C $(@D)/rust-src --strip-components=1 $(TAR_OPTIONS) -

so that's it's clearly visible it's the same command.

> +	mkdir -p $(HOST_DIR)/lib/rustlib/src/rust
> +	cp -a $(@D)/rust-src/library $(HOST_DIR)/lib/rustlib/src/rust/

Can we install in $(HOST_DIR)/src/rust for example? In PATCH 5/5,
you're anyway passing explicitly the path to the Rust source code.

Or do we need to use $(HOST_DIR)/lib/rustlib/src/rust/ because in the
package/rust case (where we build the compiler ourselves), the source
gets installed there automatically?

Could you fixup those issues and submit an updated version?

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2026-02-03 13:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-08 13:31 [Buildroot] [RFC PATCH 0/5] Add Rust for Linux support El Mehdi YOUNES via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 1/5] package/rust-bindgen: add host-clang dependency El Mehdi YOUNES via buildroot
2026-02-03 11:11   ` Thomas Petazzoni via buildroot
2026-02-13 19:37   ` Thomas Perale via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources El Mehdi YOUNES via buildroot
2026-02-03 13:33   ` Thomas Petazzoni via buildroot [this message]
2026-02-03 14:27     ` El Mehdi YOUNES via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt El Mehdi YOUNES via buildroot
2026-02-03 13:35   ` Thomas Petazzoni via buildroot
2026-02-03 14:27     ` El Mehdi YOUNES via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags El Mehdi YOUNES via buildroot
2026-02-03 13:50   ` Thomas Petazzoni via buildroot
2026-02-03 14:29     ` El Mehdi YOUNES via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 5/5] linux: Add Rust support El Mehdi YOUNES via buildroot
2026-02-03 14:08   ` Thomas Petazzoni via buildroot
2026-02-03 14:34     ` El Mehdi YOUNES via buildroot
2026-02-03 15:09       ` Thomas Petazzoni via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYH4ESxcsrQj_6pZ@windsurf \
    --to=buildroot@buildroot.org \
    --cc=elmehdi.younes@smile.fr \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox