Unexpected file replacement to source tree if bootstrap from rust installation with rustc-dev (lib/rustlib/rustc-src/rust/compiler)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- build-system
Hướng nghiên cứu
Start in src/bootstrap/src/core/build_steps/compile.rs, where symlink_dir creates the stage0-sysroot rustc-src/rust link and cp_link_r hard-links or copies the rustc-dev sysroot files, around lines 2071-2086 and 804-814. Reproduce by building with a stage 0 rustc that has rustc-dev installed and checking whether compiler/ or library/ in the source tree get overwritten. Done means bootstrap no longer writes into the source tree through that symlink, and a rebuild leaves git status clean.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
If you use a stage 0 rustc with the rustc-dev component installed, the bootstrap will hard link or copy source files from ${path to stage 0}/lib/rustlib/rustc-src/rust/compiler to source tree.
This will break offline installation used by Linux distributions.
This unexpected file replacement might lead me and maybe other users to suspect a Trojan, bad disk or memory, broken git/tar/linux, and spent several hours investigating the cause.
What happened
This symlink_dir create build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/rustc-src/rust -> $(rust source) symlink.
This cp_link_r hard link or copy all files from ${path to stage 0}/lib to build/x86_64-unknown-linux-musl/stage0-sysroot/lib/, then files in ${path to stage 0}/lib/rustlib/rustc-src/rust/compiler are hard linked or copied into $(rust source)/compiler via the symlink above.
Command used
./x.py build
Expected behaviour
It should build without issues.
Actual behaviour
Gentoo linux, bootstrap 1.100.0 from 1.99.1:
error: failed to select a version for the requirement `object = "^0.38.1"`
candidate versions found which didn't match: 0.39.1, 0.37.3, 0.36.7, ...
location searched: directory source `/tmp/portage/dev-lang/rust-1.100.0/work/rustc-1.100.0-src/vendor` (which is replacing registry `crates-io`)
required by package `rustc_codegen_ssa v0.0.0 (/tmp/portage/dev-lang/rust-1.100.0/work/rustc-1.100.0-src/compiler/rustc_codegen_ssa)`
note: perhaps a crate was updated and forgotten to be re-vendored?
note: offline mode (via `--frozen`) can sometimes cause surprising resolution failures
help: if this error is too confusing you may wish to retry without `--frozen`
The source code in rustc-1.100.0-src was replaced with rustc-src from 1.99.1.
Gentoo linux, bootstrap 1.100.0 from 1.100.0 itself:
--> /rustc-dev/0ef1bc386059596dada8fb65b50425aab2ea637a/compiler/rustc/src/main.rs:4:11
|
4 | #![expect(unused_crate_dependencies)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
error: `rustc-main` (bin "rustc-main") generated 1 warning
error: warnings are denied by `build.warnings` configuration
I have patched this file, but it's replaced with the old one.
bootstrap rustc from main branch (clean and updated tree) using beta rustc with rustc-dev installed from rustup
$ ./x.py build --stage 1
...
error: cannot update the lock file /home/han/Project/rust/Cargo.lock because --locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
Build completed unsuccessfully in 0:00:24
$ git status
M Cargo.lock
M compiler/rustc_abi/src/callconv/reg.rs
M compiler/rustc_abi/src/extern_abi.rs
M compiler/rustc_abi/src/layout.rs
M compiler/rustc_abi/src/layout/ty.rs
M compiler/rustc_abi/src/lib.rs
M compiler/rustc_arena/src/lib.rs
M compiler/rustc_ast/src/ast.rs
M compiler/rustc_ast/src/attr/mod.rs
M compiler/rustc_ast/src/visit.rs
M compiler/rustc_ast_lowering/src/expr.rs
...
Bootstrap configuration (bootstrap.toml)
change-id = 163731
[llvm]
download-ci-llvm = false
link-shared = true
static-libstdcpp = false
assertions = false
[build]
build = "x86_64-unknown-linux-musl"
host = ["x86_64-unknown-linux-musl"]
target = ["x86_64-unknown-linux-musl"]
build-stage = 1
docs = false
submodules = false
locked-deps = true
extended = false
rustc = "/home/han/.rustup/toolchains/beta-x86_64-unknown-linux-musl/bin/rustc"
cargo = "/home/han/.rustup/toolchains/beta-x86_64-unknown-linux-musl/bin/cargo"
rustdoc = "/home/han/.rustup/toolchains/beta-x86_64-unknown-linux-musl/bin/rustdoc"
sanitizers = false
profiler = false
optimized-compiler-builtins = false
[rust]
lld = false
[target.x86_64-unknown-linux-musl]
ar = "/usr/lib/llvm/23/bin/llvm-ar"
ranlib = "/usr/lib/llvm/23/bin/llvm-ranlib"
cc = "x86_64-pc-linux-musl-clang"
cxx = "x86_64-pc-linux-musl-clang++"
linker = "x86_64-pc-linux-musl-cc"
llvm-config = "/usr/lib/llvm/23/bin/llvm-config"
llvm-filecheck = "/usr/lib/llvm/23/bin/FileCheck"
crt-static = false
llvm-libunwind = "no"
Note: if you try to use this configuration to reproduce this issue, do not restore the git repo by using git checkout, otherwise the files from rustup will be written too.
How to resotre files:
find compiler library -type f -links +1 -delete
rm -f Cargo.lock
git checkout -- compiler library Cargo.lock
git clean -fd compiler library
Operating system
Gentoo Linux (glibc or musl profile)
HEAD
1.100.0 or 5f4effd579500175af844241eb179e756190f1e7
Additional context
error: failed to select a version for the requirement `object = "^0.38.1"`
candidate versions found which didn't match: 0.39.1, 0.37.3, 0.36.7, ...
location searched: directory source `/tmp/portage/dev-lang/rust-1.100.0/work/rustc-1.100.0-src/vendor` (which is replacing registry `crates-io`)
required by package `rustc_codegen_ssa v0.0.0 (/tmp/portage/dev-lang/rust-1.100.0/work/rustc-1.100.0-src/compiler/rustc_codegen_ssa)`
note: perhaps a crate was updated and forgotten to be re-vendored?
note: offline mode (via `--frozen`) can sometimes cause surprising resolution failures
help: if this error is too confusing you may wish to retry without `--frozen`
- Ngôn ngữ chính
- Rust
- Star
- 122k
- Fork
- 16.7k
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 515
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rust
-
Remove unnecessary parentheses when suggesting to remove '&' from a patternCó thể đã có người làm @BartSimpson001 đã nhận 1 ngày trước. Đang mởA-diagnostics D-invalid-suggestion T-compiler
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`Có thể đã có người làm @ChrisDenton đã nhận 11 ngày trước. Đang mởA-filesystem C-bug O-windows T-libs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
rust-lang/rust#165504 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
relnotes relnotes-tracking-issue T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rust
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
bytecodealliance/wrpc#1785 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
2 advisory ignore entries no longer match anything (`quick-xml` already patched in `Cargo.lock`)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
longbridge/nsh#2758 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
antithesishq/bombadil#473 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bench/api.sh exec test fails with curl exit 52, and --ignore-failure still records the timingsĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
libracoder/kiri#669 ·
Maintainer thường phản hồi trong vòng 1 ngày