Skip to content

x build fails copying files into stage0-sysroot using local rust #143735

Open
@pmur

Description

@pmur

Summary

When building rust with a local toolchain, boostrap fails with errors like:

thread 'main' panicked at src/bootstrap/src/lib.rs:1729:17:
failed to copy `/usr/lib/cups/backend/gutenprint53+usb` to `/home/paumurph/git/rust-dev/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/cups/backend/gutenprint53+usb`: Permission denied (os error 13)

Command used

./configure --local-rust-root=/usr --llvm-root=/usr
RUST_BACKTRACE=1 ./x --stage=1 build sysroot

Expected behaviour

The x command succeeds

Actual behaviour

bootstrap attempts to copy the contents /usr/lib and fails when it encounters files with unexpected permissions.

Bootstrap configuration (bootstrap.toml)

See configure command above.

Operating system

Fedora 41

HEAD

On the beta branch, based off b5e10d8c000a153cae6a14d70372dc4b39439a3f

Additional context

Build Log

   0: __rustc::rust_begin_unwind
             at /builddir/build/BUILD/rust-1.88.0-build/rustc-1.88.0-src/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /builddir/build/BUILD/rust-1.88.0-build/rustc-1.88.0-src/library/core/src/panicking.rs:75:14
   2: bootstrap::Build::copy_link_internal
             at ./src/bootstrap/src/lib.rs:1729:17
   3: bootstrap::Build::copy_link
             at ./src/bootstrap/src/lib.rs:1682:9
   4: bootstrap::Build::cp_link_r
             at ./src/bootstrap/src/lib.rs:1757:17
   5: bootstrap::Build::cp_link_r
             at ./src/bootstrap/src/lib.rs:1755:17
   6: bootstrap::Build::cp_link_r
             at ./src/bootstrap/src/lib.rs:1755:17
   7: <bootstrap::core::build_steps::compile::StdLink as bootstrap::core::builder::Step>::run
             at ./src/bootstrap/src/core/build_steps/compile.rs:814:13
   8: bootstrap::core::builder::Builder::ensure
             at ./src/bootstrap/src/core/builder/mod.rs:1596:23
   9: <bootstrap::core::build_steps::compile::Std as bootstrap::core::builder::Step>::run
             at ./src/bootstrap/src/core/build_steps/compile.rs:156:13
  10: bootstrap::core::builder::Builder::ensure
             at ./src/bootstrap/src/core/builder/mod.rs:1596:23
  11: <bootstrap::core::build_steps::compile::Rustc as bootstrap::core::builder::Step>::run
             at ./src/bootstrap/src/core/build_steps/compile.rs:1074:9
  12: bootstrap::core::builder::Builder::ensure
             at ./src/bootstrap/src/core/builder/mod.rs:1596:23
  13: <bootstrap::core::build_steps::compile::Assemble as bootstrap::core::builder::Step>::run
             at ./src/bootstrap/src/core/build_steps/compile.rs:2155:28
  14: bootstrap::core::builder::Builder::ensure
             at ./src/bootstrap/src/core/builder/mod.rs:1596:23
  15: bootstrap::core::builder::Builder::compiler
             at ./src/bootstrap/src/core/builder/mod.rs:1298:9
  16: <bootstrap::core::build_steps::compile::Std as bootstrap::core::builder::Step>::make_run
             at ./src/bootstrap/src/core/build_steps/compile.rs:123:23
  17: bootstrap::core::builder::StepDescription::maybe_run
             at ./src/bootstrap/src/core/builder/mod.rs:475:13
  18: bootstrap::core::builder::StepDescription::run
             at ./src/bootstrap/src/core/builder/mod.rs:607:17
  19: bootstrap::core::builder::Builder::run_step_descriptions
             at ./src/bootstrap/src/core/builder/mod.rs:1271:9
  20: bootstrap::core::builder::Builder::execute_cli
             at ./src/bootstrap/src/core/builder/mod.rs:1251:9
  21: bootstrap::Build::build
             at ./src/bootstrap/src/lib.rs:705:17
  22: bootstrap::main
             at ./src/bootstrap/src/bin/main.rs:99:5
  23: core::ops::function::FnOnce::call_once
             at /builddir/build/BUILD/rust-1.88.0-build/rustc-1.88.0-src/library/core/src/ops/function.rs:250:5

My first attempt at working around was the oneliner, though I am not sure this is correct:

--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -811,7 +811,7 @@ fn run(self, builder: &Builder<'_>) {
                 let _ = fs::remove_dir_all(sysroot.join("lib/rustlib/src/rust"));
             }
 
-            builder.cp_link_r(&builder.initial_sysroot.join("lib"), &sysroot.join("lib"));
+            builder.cp_link_r(&builder.initial_sysroot.join("lib/rustlib"), &sysroot.join("lib/rustlib"));
         } else {
             if builder.download_rustc() {
                 // Ensure there are no CI-rustc std artifacts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions