* [Buildroot] [RFC PATCH 1/5] package/rust-bindgen: add host-clang dependency
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 ` 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
` (3 subsequent siblings)
4 siblings, 2 replies; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2025-08-08 13:31 UTC (permalink / raw)
To: buildroot; +Cc: Eric Le Bihan, El Mehdi YOUNES
According to the official requirements, bindgen needs libclang to
parse C/C++ headers. Until now the tool was used mainly by Mesa and
worked, but Rust-for-Linux explicitly relies on bindgen + libclang,
otherwise we can't activate Rust for linux.
See
https://rust-lang.github.io/rust-bindgen/requirements.html
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
package/rust-bindgen/rust-bindgen.mk | 2 ++
1 file changed, 2 insertions(+)
diff --git a/package/rust-bindgen/rust-bindgen.mk b/package/rust-bindgen/rust-bindgen.mk
index 349d4c3670..0ec620002a 100644
--- a/package/rust-bindgen/rust-bindgen.mk
+++ b/package/rust-bindgen/rust-bindgen.mk
@@ -9,6 +9,8 @@ RUST_BINDGEN_SITE = $(call github,rust-lang,rust-bindgen,v$(RUST_BINDGEN_VERSION
RUST_BINDGEN_LICENSE = BSD-3-clause
RUST_BINDGEN_LICENSE_FILES = LICENSE
+HOST_RUST_BINDGEN_DEPENDENCIES = host-clang
+
# The Cargo.toml at the root directory is a "virtual manifest".
# Since we only want to build and install bindgen use the Cargo.toml
# from the bindgen-cli subdirectory.
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [Buildroot] [RFC PATCH 1/5] package/rust-bindgen: add host-clang dependency
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
1 sibling, 0 replies; 17+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-02-03 11:11 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: buildroot, Eric Le Bihan
Hello Mehdi,
Sorry for the long delay in getting back to you!
On Fri, Aug 08, 2025 at 03:31:08PM +0200, El Mehdi YOUNES via buildroot wrote:
> According to the official requirements, bindgen needs libclang to
> parse C/C++ headers. Until now the tool was used mainly by Mesa and
> worked, but Rust-for-Linux explicitly relies on bindgen + libclang,
> otherwise we can't activate Rust for linux.
>
> See
> https://rust-lang.github.io/rust-bindgen/requirements.html
>
> Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
We have finally applied your patch! However, we improved the commit
log to clarify further what happens, why it worked today without any
issue, and we also added a comment in .mk explaining why we use a
build time dependency for what really is a run-time dependency.
See:
https://gitlab.com/buildroot.org/buildroot/-/commit/34ed3bbf0a5f2576043ff627c76df584ea936a71
for the final commit.
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 1/5] package/rust-bindgen: add host-clang dependency
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
1 sibling, 0 replies; 17+ messages in thread
From: Thomas Perale via buildroot @ 2026-02-13 19:37 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: Thomas Perale, buildroot
In reply of:
> According to the official requirements, bindgen needs libclang to
> parse C/C++ headers. Until now the tool was used mainly by Mesa and
> worked, but Rust-for-Linux explicitly relies on bindgen + libclang,
> otherwise we can't activate Rust for linux.
>
> See
> https://rust-lang.github.io/rust-bindgen/requirements.html
>
> Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Applied to 2025.02.x & 2025.11.x. Thanks
> ---
> package/rust-bindgen/rust-bindgen.mk | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/package/rust-bindgen/rust-bindgen.mk b/package/rust-bindgen/rust-bindgen.mk
> index 349d4c3670..0ec620002a 100644
> --- a/package/rust-bindgen/rust-bindgen.mk
> +++ b/package/rust-bindgen/rust-bindgen.mk
> @@ -9,6 +9,8 @@ RUST_BINDGEN_SITE = $(call github,rust-lang,rust-bindgen,v$(RUST_BINDGEN_VERSION
> RUST_BINDGEN_LICENSE = BSD-3-clause
> RUST_BINDGEN_LICENSE_FILES = LICENSE
>
> +HOST_RUST_BINDGEN_DEPENDENCIES = host-clang
> +
> # The Cargo.toml at the root directory is a "virtual manifest".
> # Since we only want to build and install bindgen use the Cargo.toml
> # from the bindgen-cli subdirectory.
> --
> 2.43.0
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources
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
@ 2025-08-08 13:31 ` El Mehdi YOUNES via buildroot
2026-02-03 13:33 ` Thomas Petazzoni via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt El Mehdi YOUNES via buildroot
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2025-08-08 13:31 UTC (permalink / raw)
To: buildroot; +Cc: Eric Le Bihan, El Mehdi YOUNES
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(-)
diff --git a/package/rust-bin/rust-bin.hash b/package/rust-bin/rust-bin.hash
index 7f9d2f6339..b49edb7580 100644
--- a/package/rust-bin/rust-bin.hash
+++ b/package/rust-bin/rust-bin.hash
@@ -1,6 +1,8 @@
# Generated with utils/update-rust
# Do not edit manually
+# From https://static.rust-lang.org/dist/rustc-1.88.0-src.tar.xz.sha256
+sha256 0c1dcbb4f762513d021e1a282c0ac58c0a423642b3a6bf581cafb5414df4193e rustc-1.88.0-src.tar.xz
# From https://static.rust-lang.org/dist/rust-1.88.0-aarch64-unknown-linux-gnu.tar.xz.sha256
sha256 d5decc46123eb888f809f2ee3b118d13586a37ffad38afaefe56aa7139481d34 rust-1.88.0-aarch64-unknown-linux-gnu.tar.xz
# From https://static.rust-lang.org/dist/rust-1.88.0-i686-unknown-linux-gnu.tar.xz.sha256
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 =
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
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), \
$(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) -
+ mkdir -p $(HOST_DIR)/lib/rustlib/src/rust
+ cp -a $(@D)/rust-src/library $(HOST_DIR)/lib/rustlib/src/rust/
+endef
+
+HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_EXTRACT_SRC_LIBRARY
+
$(eval $(host-generic-package))
diff --git a/utils/update-rust b/utils/update-rust
index 7db3feff9c..a1164db0d0 100755
--- a/utils/update-rust
+++ b/utils/update-rust
@@ -100,6 +100,15 @@ def gen_hash_file_src(hash_file, new_version):
def gen_hash_file_bin(hash_file, new_version):
with hash_file.open("w") as fd:
fd.write("# Generated with utils/update-rust\n# Do not edit manually\n\n")
+ f_name = f"rustc-{new_version}-src.tar.xz"
+ print(f"\r\033[KUpdating {f_name}", end="")
+ h_url = f"{RUST_DIST_URL}/{f_name}.sha256"
+ with urllib.request.urlopen(h_url) as r:
+ if r.status != 200:
+ raise RuntimeError(f"No hash for {f_name}. Has source been removed?")
+ # rstrip() content, and explicitly add the \n, in case
+ # a hash file does not have a trailing \n.
+ fd.write(f"# From {h_url}\nsha256 {r.read().decode().rstrip()}\n")
for host in RUST_HOSTS:
f_name = f"rust-{new_version}-{host}.tar.xz"
print(f"\r\033[KUpdating {f_name}", end="")
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources
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
2026-02-03 14:27 ` El Mehdi YOUNES via buildroot
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-02-03 13:33 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: buildroot, Eric Le Bihan
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources
2026-02-03 13:33 ` Thomas Petazzoni via buildroot
@ 2026-02-03 14:27 ` El Mehdi YOUNES via buildroot
0 siblings, 0 replies; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2026-02-03 14:27 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Eric Le Bihan
Hi Thomas,
On 2/3/26 14:33, Thomas Petazzoni wrote:
> 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.
Thanks a lot for the feedback, this series was first sent only for feedback,
the change only for rust-bin was in purpose to facilitate testing and
have some
feedback before the final patch.
I will add it on a v2
>> 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?
Thank you so mush for the feedback, I will fix.
I'll try to send a v2 on the next days
>
> Thanks a lot!
>
> Thomas
Best regards,
El Mehdi
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt
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
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 2/5] package/rust-bin: add Rust sources El Mehdi YOUNES via buildroot
@ 2025-08-08 13:31 ` El Mehdi YOUNES via buildroot
2026-02-03 13:35 ` Thomas Petazzoni via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags El Mehdi YOUNES via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 5/5] linux: Add Rust support El Mehdi YOUNES via buildroot
4 siblings, 1 reply; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2025-08-08 13:31 UTC (permalink / raw)
To: buildroot; +Cc: Eric Le Bihan, El Mehdi YOUNES
Rust-for-Linux expects rustfmt to be available; otherwise the kernel
emits a "rustfmt not found" warning and the generated bindings are not
correct. Provide rustfmt from rust-bin by adding it to the installed
components.
Note: the dist tarball exposes the component as "rustfmt-preview"
(as listed in 'components' file), so we use that name.
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
package/rust-bin/rust-bin.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk
index 2195584f8f..75494fb286 100644
--- a/package/rust-bin/rust-bin.mk
+++ b/package/rust-bin/rust-bin.mk
@@ -43,7 +43,7 @@ HOST_RUST_BIN_INSTALL_COMMON_OPTS = \
HOST_RUST_BIN_INSTALL_OPTS = \
$(HOST_RUST_BIN_INSTALL_COMMON_OPTS) \
- --components=rustc,cargo,rust-std-$(RUSTC_HOST_NAME)
+ --components=rustc,cargo,rust-std-$(RUSTC_HOST_NAME),rustfmt-preview
define HOST_RUST_BIN_INSTALL_RUSTC
(cd $(@D); \
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt
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
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-02-03 13:35 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: buildroot, Eric Le Bihan
Hello Mehdi,
On Fri, Aug 08, 2025 at 03:31:10PM +0200, El Mehdi YOUNES via buildroot wrote:
> Rust-for-Linux expects rustfmt to be available; otherwise the kernel
> emits a "rustfmt not found" warning and the generated bindings are not
> correct. Provide rustfmt from rust-bin by adding it to the installed
> components.
>
> Note: the dist tarball exposes the component as "rustfmt-preview"
> (as listed in 'components' file), so we use that name.
>
> Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Thanks for the patch. Here as well, you not only have to adjust
package/rust-bin, but also package/rust, so that package/rust also
installs rustfmt.
Could you have a look into this, and send 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt
2026-02-03 13:35 ` Thomas Petazzoni via buildroot
@ 2026-02-03 14:27 ` El Mehdi YOUNES via buildroot
0 siblings, 0 replies; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2026-02-03 14:27 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Eric Le Bihan
On 2/3/26 14:35, Thomas Petazzoni wrote:
> Hello Mehdi,
>
> On Fri, Aug 08, 2025 at 03:31:10PM +0200, El Mehdi YOUNES via buildroot wrote:
>> Rust-for-Linux expects rustfmt to be available; otherwise the kernel
>> emits a "rustfmt not found" warning and the generated bindings are not
>> correct. Provide rustfmt from rust-bin by adding it to the installed
>> components.
>>
>> Note: the dist tarball exposes the component as "rustfmt-preview"
>> (as listed in 'components' file), so we use that name.
>>
>> Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
> Thanks for the patch. Here as well, you not only have to adjust
> package/rust-bin, but also package/rust, so that package/rust also
> installs rustfmt.
>
> Could you have a look into this, and send an updated version?
Thanks, It will be added on the v2
>
> Thanks a lot!
>
> Thomas
Best regards,
El Mehdi
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags
2025-08-08 13:31 [Buildroot] [RFC PATCH 0/5] Add Rust for Linux support El Mehdi YOUNES via buildroot
` (2 preceding siblings ...)
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 3/5] package/rust-bin: install rustfmt El Mehdi YOUNES via buildroot
@ 2025-08-08 13:31 ` El Mehdi YOUNES via buildroot
2026-02-03 13:50 ` Thomas Petazzoni via buildroot
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 5/5] linux: Add Rust support El Mehdi YOUNES via buildroot
4 siblings, 1 reply; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2025-08-08 13:31 UTC (permalink / raw)
To: buildroot; +Cc: Eric Le Bihan, El Mehdi YOUNES
Rust-for-Linux invokes rustc like:
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \
-Clinker-flavor=gcc -Clinker=$(HOSTCC) (see:
https://github.com/torvalds/linux/blob/master/rust/Makefile#L407).
When Buildroot embeds flags into HOSTCC (e.g. HOSTCC="gcc <cflags> <ldflags>"),
rustc treats the entire value as the linker program name; and it fails.
This patch passes a clean HOSTCC and moves flags to the dedicated host-side
variables accepted by Kbuild:
- HOSTCC := $(HOSTCC)
- HOSTCFLAGS := $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))
- HOSTLDFLAGS := $(HOST_LDFLAGS)
Since Linux v4.19, Kbuild provides explicit variables for host flags, so splitting
compiler vs flags is supported upstream (see:
https://github.com/torvalds/linux/commit/96f14fe738b69dd97a33efe3cc8ab330af5fd1f1
https://github.com/torvalds/linux/commit/b90a368000abe5e015e0b045ca2ff7c2173b94c0
https://github.com/torvalds/linux/commit/f92d19e0ef9bbbb2984845682e740934ad45473b).
But with this change we can have problems with older kernel versions
(< 4.19), as the Buildroot commit below warned when avoiding HOSTCFLAGS
to not override internal kernel flags:
https://gitlab.com/buildroot.org/buildroot/-/commit/dde090c299b0357fdb1a4ec44ad8d332ac57f65e
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
I’m aware this split is currently needed only for Rust-for-Linux (which targets
>= 6.1). I considered adding a version-based condition, but I’m not sure about
the best way to express that in Buildroot, or if there’s a better approach to
avoid regressions on pre-4.19 kernels. I’m requesting ideas/guidance
on how you’d like this to be gated.
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
linux/linux.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/linux/linux.mk b/linux/linux.mk
index 0520394931..f5ac64fdd2 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -161,7 +161,9 @@ endif
# Disable building host tools with -Werror: newer gcc versions can be
# extra picky about some code (https://bugs.busybox.net/show_bug.cgi?id=14826)
LINUX_MAKE_FLAGS = \
- HOSTCC="$(HOSTCC) $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS))) $(HOST_LDFLAGS)" \
+ HOSTCC="$(HOSTCC)" \
+ HOSTCFLAGS="$(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))" \
+ HOSTLDFLAGS="$(HOST_LDFLAGS)" \
ARCH=$(KERNEL_ARCH) \
KCFLAGS="$(LINUX_CFLAGS)" \
INSTALL_MOD_PATH=$(TARGET_DIR) \
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags
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
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-02-03 13:50 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: buildroot, Eric Le Bihan
Hello Mehdi,
Thanks for your patch!
On Fri, Aug 08, 2025 at 03:31:11PM +0200, El Mehdi YOUNES via buildroot wrote:
> Since Linux v4.19, Kbuild provides explicit variables for host flags, so splitting
> compiler vs flags is supported upstream (see:
> https://github.com/torvalds/linux/commit/96f14fe738b69dd97a33efe3cc8ab330af5fd1f1
> https://github.com/torvalds/linux/commit/b90a368000abe5e015e0b045ca2ff7c2173b94c0
> https://github.com/torvalds/linux/commit/f92d19e0ef9bbbb2984845682e740934ad45473b).
>
> But with this change we can have problems with older kernel versions
> (< 4.19), as the Buildroot commit below warned when avoiding HOSTCFLAGS
> to not override internal kernel flags:
> https://gitlab.com/buildroot.org/buildroot/-/commit/dde090c299b0357fdb1a4ec44ad8d332ac57f65e
Since your change as-is would break Linux < 4.19, here is the
suggestion that we have after discussing at the Buildroot Developers
Meeting: make things condition based on
BR2_LINUX_KERNEL_RUST_SUPPORT. Something along the lines of:
ifeq ($(BR2_LINUX_KERNEL_RUST_SUPPORT),y)
LINUX_MAKE_FLAGS += \
HOSTCC="$(HOSTCC)" \
HOSTCFLAGS="$(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))" \
HOSTLDFLAGS="$(HOST_LDFLAGS)"
else
LINUX_MAKE_FLAGS += \
HOSTCC="$(HOSTCC) $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS))) $(HOST_LDFLAGS)"
endif
Of course, if someone enables BR2_LINUX_KERNEL_RUST_SUPPORT with a
kernel < 4.19 it would fail to build, but that's acceptable as it's
stupid to do this since Linux 4.19 did not have any Rust support.
Thanks!
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags
2026-02-03 13:50 ` Thomas Petazzoni via buildroot
@ 2026-02-03 14:29 ` El Mehdi YOUNES via buildroot
0 siblings, 0 replies; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2026-02-03 14:29 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Eric Le Bihan
Hi Thomas,
On 2/3/26 14:50, Thomas Petazzoni wrote:
> Hello Mehdi,
>
> Thanks for your patch!
>
> On Fri, Aug 08, 2025 at 03:31:11PM +0200, El Mehdi YOUNES via buildroot wrote:
>
>> Since Linux v4.19, Kbuild provides explicit variables for host flags, so splitting
>> compiler vs flags is supported upstream (see:
>> https://github.com/torvalds/linux/commit/96f14fe738b69dd97a33efe3cc8ab330af5fd1f1
>> https://github.com/torvalds/linux/commit/b90a368000abe5e015e0b045ca2ff7c2173b94c0
>> https://github.com/torvalds/linux/commit/f92d19e0ef9bbbb2984845682e740934ad45473b).
>>
>> But with this change we can have problems with older kernel versions
>> (< 4.19), as the Buildroot commit below warned when avoiding HOSTCFLAGS
>> to not override internal kernel flags:
>> https://gitlab.com/buildroot.org/buildroot/-/commit/dde090c299b0357fdb1a4ec44ad8d332ac57f65e
> Since your change as-is would break Linux < 4.19, here is the
> suggestion that we have after discussing at the Buildroot Developers
> Meeting: make things condition based on
> BR2_LINUX_KERNEL_RUST_SUPPORT. Something along the lines of:
>
> ifeq ($(BR2_LINUX_KERNEL_RUST_SUPPORT),y)
> LINUX_MAKE_FLAGS += \
> HOSTCC="$(HOSTCC)" \
> HOSTCFLAGS="$(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))" \
> HOSTLDFLAGS="$(HOST_LDFLAGS)"
> else
> LINUX_MAKE_FLAGS += \
> HOSTCC="$(HOSTCC) $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS))) $(HOST_LDFLAGS)"
> endif
Thank you for the suggestion, I will add it on the next version
>
> Of course, if someone enables BR2_LINUX_KERNEL_RUST_SUPPORT with a
> kernel < 4.19 it would fail to build, but that's acceptable as it's
> stupid to do this since Linux 4.19 did not have any Rust support.
>
> Thanks!
>
> Thomas
Best regards,
El Mehdi
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Buildroot] [RFC PATCH 5/5] linux: Add Rust support
2025-08-08 13:31 [Buildroot] [RFC PATCH 0/5] Add Rust for Linux support El Mehdi YOUNES via buildroot
` (3 preceding siblings ...)
2025-08-08 13:31 ` [Buildroot] [RFC PATCH 4/5] linux: split HOSTCC from flags El Mehdi YOUNES via buildroot
@ 2025-08-08 13:31 ` El Mehdi YOUNES via buildroot
2026-02-03 14:08 ` Thomas Petazzoni via buildroot
4 siblings, 1 reply; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2025-08-08 13:31 UTC (permalink / raw)
To: buildroot; +Cc: Eric Le Bihan, El Mehdi YOUNES
Add a menu option to enable Rust-for-Linux from Buildroot. When
BR2_LINUX_KERNEL_RUST_SUPPORT=y, select the required host tools and pass
them to the kernel build:
- Dependencies: host-rustc, host-rust-bindgen
- Make vars: RUSTC, BINDGEN, RUST_LIB_SRC, LIBCLANG_PATH, RUSTFMT
- Kconfig fixup: force CONFIG_RUST=y, since all prerequisites are now
provided by the above variables/paths
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
linux/Config.in | 6 ++++++
linux/linux.mk | 12 ++++++++++++
2 files changed, 18 insertions(+)
diff --git a/linux/Config.in b/linux/Config.in
index 7f90c566b0..86525c9b0a 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -557,6 +557,12 @@ config BR2_LINUX_KERNEL_NEEDS_HOST_PYTHON3
Enable this option if you get a Linux kernel build failure
such as "python3: not found".
+config BR2_LINUX_KERNEL_RUST_SUPPORT
+ bool "Enable Rust support in the kernel"
+ depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+ select BR2_PACKAGE_HOST_RUSTC
+ select BR2_PACKAGE_HOST_RUST_BINDGEN
+
# Linux extensions
source "linux/Config.ext.in"
diff --git a/linux/linux.mk b/linux/linux.mk
index f5ac64fdd2..d95356342b 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -180,6 +180,16 @@ LINUX_MAKE_ENV += \
KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C TZ='UTC' date -d @$(SOURCE_DATE_EPOCH))"
endif
+ifeq ($(BR2_LINUX_KERNEL_RUST_SUPPORT),y)
+LINUX_DEPENDENCIES += host-rustc host-rust-bindgen
+LINUX_MAKE_FLAGS += \
+ RUSTC=$(HOST_DIR)/bin/rustc \
+ BINDGEN=$(HOST_DIR)/bin/bindgen \
+ RUST_LIB_SRC=$(HOST_DIR)/lib/rustlib/src/rust/library \
+ LIBCLANG_PATH=$(HOST_DIR)/lib \
+ RUSTFMT=$(HOST_DIR)/bin/rustfmt
+endif
+
# gcc-8 started warning about function aliases that have a
# non-matching prototype. This seems rather useful in general, but it
# causes tons of warnings in the Linux kernel, where we rely on
@@ -479,6 +489,8 @@ define LINUX_KCONFIG_FIXUP_CMDS
$(call KCONFIG_ENABLE_OPT,CONFIG_FB)
$(call KCONFIG_ENABLE_OPT,CONFIG_LOGO)
$(call KCONFIG_ENABLE_OPT,CONFIG_LOGO_LINUX_CLUT224))
+ $(if $(BR2_LINUX_KERNEL_RUST_SUPPORT),
+ $(call KCONFIG_ENABLE_OPT,CONFIG_RUST))
$(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
$(call KCONFIG_DISABLE_OPT,CONFIG_WERROR)
$(PACKAGES_LINUX_CONFIG_FIXUPS)
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [Buildroot] [RFC PATCH 5/5] linux: Add Rust support
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
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-02-03 14:08 UTC (permalink / raw)
To: El Mehdi YOUNES; +Cc: buildroot, Eric Le Bihan
On Fri, Aug 08, 2025 at 03:31:12PM +0200, El Mehdi YOUNES via buildroot wrote:
> +ifeq ($(BR2_LINUX_KERNEL_RUST_SUPPORT),y)
> +LINUX_DEPENDENCIES += host-rustc host-rust-bindgen
> +LINUX_MAKE_FLAGS += \
> + RUSTC=$(HOST_DIR)/bin/rustc \
> + BINDGEN=$(HOST_DIR)/bin/bindgen \
> + RUST_LIB_SRC=$(HOST_DIR)/lib/rustlib/src/rust/library \
You'll have to update this to $(HOST_DIR)/src/rust if that ends up
working (see our comments on PATCH 2/5).
Make sure to test this with both pre-compiled Rust compiler and
compiled-from-source Rust compiler.
And finally, we would like to have a test in support/testing/ to
verify that this continues to work. You don't need a test that boots
the kernel, but at least something that builds the kernel with Rust
support. Of course if there's some HW-agnostic kernel feature in Rust
that we can test in Qemu, it would be nice. Maybe binder? But I'm not
sure how to use it under a pure Linux system. But don't spend too much
time on this: a compile-time only test will be good enough.
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Buildroot] [RFC PATCH 5/5] linux: Add Rust support
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
0 siblings, 1 reply; 17+ messages in thread
From: El Mehdi YOUNES via buildroot @ 2026-02-03 14:34 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Eric Le Bihan
On 2/3/26 15:08, Thomas Petazzoni wrote:
> On Fri, Aug 08, 2025 at 03:31:12PM +0200, El Mehdi YOUNES via buildroot wrote:
>
>> +ifeq ($(BR2_LINUX_KERNEL_RUST_SUPPORT),y)
>> +LINUX_DEPENDENCIES += host-rustc host-rust-bindgen
>> +LINUX_MAKE_FLAGS += \
>> + RUSTC=$(HOST_DIR)/bin/rustc \
>> + BINDGEN=$(HOST_DIR)/bin/bindgen \
>> + RUST_LIB_SRC=$(HOST_DIR)/lib/rustlib/src/rust/library \
> You'll have to update this to $(HOST_DIR)/src/rust if that ends up
> working (see our comments on PATCH 2/5).
>
> Make sure to test this with both pre-compiled Rust compiler and
> compiled-from-source Rust compiler.
I will improve it on v2, Thanks a lot!
>
> And finally, we would like to have a test in support/testing/ to
> verify that this continues to work. You don't need a test that boots
> the kernel, but at least something that builds the kernel with Rust
> support. Of course if there's some HW-agnostic kernel feature in Rust
> that we can test in Qemu, it would be nice. Maybe binder? But I'm not
> sure how to use it under a pure Linux system. But don't spend too much
> time on this: a compile-time only test will be good enough.
Maybe we can add a runtime test using the rust_minimal sample.
https://github.com/torvalds/linux/blob/master/samples/rust/rust_minimal.rs
I have already tested it on Qemu, so I will try to add a runtime test
using it.
I will add it to the v2.
>
> Thanks a lot!
>
> Thomas
Best regards,
El Mehdi
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 17+ messages in thread