rust-lang / rust-lang/rust

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

Open
#143,735 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/bootstrap/src/core/build_steps/compile.rs around the StdLink logic at line 814, then inspect the copy helpers in src/bootstrap/src/lib.rs around lines 1682-1757. Reproduce the issue with the configure and x commands from the report, determine why /usr/lib is copied into stage0-sysroot, and consider the behavior complete when the command succeeds without the permission error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.