diff mbox series

[v2] rust: Install the Rust source

Message ID 20260305053612.1632965-1-alistair.francis@wdc.com
State New
Headers show
Series [v2] rust: Install the Rust source | expand

Commit Message

Alistair Francis March 5, 2026, 5:36 a.m. UTC
From: Alistair Francis <alistair.francis@wdc.com>

When building the Linux kernel with Rust support enabled the kernel
expects to find the Rust source as the kernel build system will cross
compile the core library.

This patch uses the Rust tooling to install the Rust source when we
install the compiller as well.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
v2:
 - Update patch with new upstream submission

 ...l-fix-for-.-x-install-src-with-build.patch | 45 +++++++++++++++++++
 meta/recipes-devtools/rust/rust-source.inc    |  1 +
 meta/recipes-devtools/rust/rust_1.93.0.bb     |  4 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/rust/files/0001-bootstrap-minimal-fix-for-.-x-install-src-with-build.patch

Comments

Varatharajan, Deepesh March 5, 2026, 7:34 p.m. UTC | #1
On Thu, Mar 5, 2026 at 11:06 AM, Alistair Francis wrote:

> 
> +inherit pkgconfig
> 
> -DEPENDS += "llvm"
> +DEPENDS += "llvm openssl"

Hi Alistair,

As you already know, there is an ongoing series of patches to enable Rust
support in the kernel. The latest version of this series can be found here:
https://lists.openembedded.org/g/openembedded-core/topic/patch_v7_00_14_enable_rust/118136908

With the newest version, the relevant changes are now controlled via the
KERNEL_RUST_SUPPORT variable. Therefore, instead of introducing additional
dependencies directly, Can you make it optional by using the same variable.

Regards,
Deepesh
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/files/0001-bootstrap-minimal-fix-for-.-x-install-src-with-build.patch b/meta/recipes-devtools/rust/files/0001-bootstrap-minimal-fix-for-.-x-install-src-with-build.patch
new file mode 100644
index 0000000000..aeb59ff567
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/0001-bootstrap-minimal-fix-for-.-x-install-src-with-build.patch
@@ -0,0 +1,45 @@ 
+From e26974ca33aa322bbc60db5d1010899e40f6d624 Mon Sep 17 00:00:00 2001
+From: Alistair Francis <alistair.francis@wdc.com>
+Date: Fri, 9 Jan 2026 08:35:43 +1000
+Subject: [PATCH] bootstrap: minimal fix for ./x install src with build.docs =
+ false
+
+When running the `install src` command I'm seeing failures as the
+`builder.doc_out(host)` directory does not exist. This is because
+`match_paths_to_steps_and_run()` doesn't actually build any
+documentation as the `paths.is_empty()` causes an early return. This
+results in install failures as the `*/doc` src directory doesn't exist.
+
+This patch ensures that the builder.doc_out(host) directory exists.
+
+This fixes installing the Rust source when `build.docs = false`.
+
+This fixes installing the Rust source code in OpenEmbedded.
+
+Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/150845]
+Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
+Signed-off-by: Jieyou Xu <jieyouxu@outlook.com>
+---
+ src/bootstrap/src/core/build_steps/dist.rs | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
+index 2e291f7c2c3..28a7afd6c61 100644
+--- a/src/bootstrap/src/core/build_steps/dist.rs
++++ b/src/bootstrap/src/core/build_steps/dist.rs
+@@ -87,6 +87,12 @@ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
+         // from a shared directory.
+         builder.run_default_doc_steps();
+ 
++        // In case no default doc steps are run for host, it is possible that `<host>/doc` directory
++        // is never created.
++        if !builder.config.dry_run() {
++            t!(fs::create_dir_all(builder.doc_out(host)));
++        }
++
+         let dest = "share/doc/rust/html";
+ 
+         let mut tarball = Tarball::new(builder, "rust-docs", &host.triple);
+-- 
+2.53.0
+
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 514f3fec1e..65c6dc2857 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -8,6 +8,7 @@  SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://0001-src-core-build_steps-tool.rs-switch-off-lto-for-rust.patch;patchdir=${RUSTSRC} \
             file://revert-link-std-statically-in-rustc_driver-feature.patch;patchdir=${RUSTSRC} \
             file://0001-riscv32-Define-plain-syscalls-as-their-time64-varian.patch;patchdir=${RUSTSRC} \
+            file://0001-bootstrap-minimal-fix-for-.-x-install-src-with-build.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "e30d898272c587a22f77679f03c5e8192b5645c7c9ccc3407ad1106761507cea"
 
diff --git a/meta/recipes-devtools/rust/rust_1.93.0.bb b/meta/recipes-devtools/rust/rust_1.93.0.bb
index 2be0bd8d89..9c3efc7453 100644
--- a/meta/recipes-devtools/rust/rust_1.93.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.93.0.bb
@@ -6,8 +6,9 @@  LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=11a3899825f4376896e438c8c753f8dc"
 
 inherit rust
 inherit cargo_common
+inherit pkgconfig
 
-DEPENDS += "llvm"
+DEPENDS += "llvm openssl"
 # native rust uses cargo/rustc from binary snapshots to bootstrap
 # but everything else should use our native builds
 DEPENDS:append:class-target = " cargo-native rust-native"
@@ -284,6 +285,7 @@  do_install () {
 
 rust_do_install() {
     rust_runx install
+    rust_runx install src
 }
 
 rust_do_install:class-nativesdk() {