Skip to content

ui/feature-gates/version_check.rs broken with rpath=false #141579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Fabian-Gruenbichler opened this issue May 26, 2025 · 4 comments · Fixed by #141640
Closed

ui/feature-gates/version_check.rs broken with rpath=false #141579

Fabian-Gruenbichler opened this issue May 26, 2025 · 4 comments · Fixed by #141640
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Fabian-Gruenbichler
Copy link
Contributor

Summary

this test case is only executed on x86 (not x86_64 or other targets, which already seems wrong, but might be the reason this was not caught/reported yet?).

it tries to execute the stage2 rustc binary without setting LD_LIBRARY_LOAD_PATH correctly, at least for rpath=false:

Command used

RUST_BACKTRACE=1 python3 src/bootstrap/bootstrap.py -j XXX --stage 2 --config debian/config.toml --on-fail env test --no-fail-fast --exclude src/tools/tidy

Expected behaviour

the test should pass :)

Actual behaviour

failures:

---- [ui] tests/ui/feature-gates/version_check.rs stdout ----


executing env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/stage2/bin/rustc" "/build/reproducible-path/rustc-1.86.0+dfsg1/tests/ui/feature-gates/version_check.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/build/reproducible-path/rustc-1.86.0+dfsg1/debian/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/build/reproducible-path/rustc-1.86.0+dfsg1/vendor" "--sysroot" "/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/stage2" "--target=i686-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/test/ui/feature-gates/version_check/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=i686-linux-gnu-gcc"
------rustc stdout------------------------------

------rustc stderr------------------------------

------------------------------------------
executing cd "/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/test/ui/feature-gates/version_check" && RUSTC="/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="6" "/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/test/ui/feature-gates/version_check/a"
------a stdout------------------------------

------a stderr------------------------------

thread 'main' panicked at /build/reproducible-path/rustc-1.86.0+dfsg1/tests/ui/feature-gates/version_check.rs:15:81:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /usr/src/rustc-1.86.0/library/std/src/panicking.rs:695:5
   1: core::panicking::panic_fmt
             at /usr/src/rustc-1.86.0/library/core/src/panicking.rs:75:14
   2: core::panicking::panic
             at /usr/src/rustc-1.86.0/library/core/src/panicking.rs:145:5
   3: core::option::unwrap_failed
             at /usr/src/rustc-1.86.0/library/core/src/option.rs:2015:5
   4: version_check::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

------------------------------------------

error: test run failed!
status: exit status: 101

adding some debug code shows that version is Ok("") (i.e., stdout is empty), and the executed rustc binary is /build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/stage2/bin/rustc". dumping the test commands stderr instead of stdout, we get the actual error:

/build/reproducible-path/rustc-1.86.0+dfsg1/build/i686-unknown-linux-gnu/stage2/bin/rustc: error while loading shared libraries: librustc_driver-b27aa4671471dea1.so: cannot open shared object file: No such file or directory\n"

Bootstrap configuration (bootstrap.toml)

this happened during the Debian package build.

the config is heavily modified to suite distro purposes, but we don't carry any bootstrap or compiletest patches that should cause this:

change-id = 133207

[build]
submodules = false
vendor = true
locked-deps = false
verbose = 2
profiler = true

rustc = "/usr/bin/rustc"
cargo = "/usr/bin/cargo"

build = "i686-unknown-linux-gnu"
host = ["i686-unknown-linux-gnu"]
target = ["i686-unknown-linux-gnu"]

#full-bootstrap = true
# originally needed to work around #45317 but no longer necessary
# currently we have to omit it because it breaks #48319

# this might get changed later by override_dh_auto_configure-indep
# we do it this way to avoid spurious rebuilds
docs = false

extended = true
tools = [
  "cargo",
  "clippy",
  "rust-analyzer",
  "rust-analyzer-proc-macro-srv",
  "rustdoc",
  "rustfmt",
  "wasm-component-ld",
]

# we use pre-built LLVM, so can't optimize compiler-rt
optimized-compiler-builtins = false

[install]
prefix = "/usr"

[target.i686-unknown-linux-gnu]
llvm-config = "/usr/lib/llvm-19/bin/llvm-config"
linker = "i686-linux-gnu-gcc"
profiler = "/usr/lib/llvm-19/lib/clang/19/lib/linux/libclang_rt.profile-i386.a"

[target.wasm32-wasip1]
wasi-root = "/usr"
profiler = false
[target.wasm32-wasip2]
wasi-root = "/usr"
profiler = false
[target.wasm32-unknown-unknown]
profiler = false

[target.i686-pc-windows-gnu]
profiler = false

[llvm]
link-shared = true
download-ci-llvm = false
ninja = false

[rust]
download-rustc = false
jemalloc = false
optimize = true
dist-src = false
lld = false

channel = "stable"

# parallel codegen interferes with reproducibility, see
# https://github.com/rust-lang/rust/issues/34902#issuecomment-319463586
#codegen-units = 0
debuginfo-level = 0
debuginfo-level-std = 2
rpath = false
# see also d-custom-debuginfo-path.patch
remap-debuginfo = true

omit-git-hash = true
verbose-tests = true
backtrace-on-ice = true

deny-warnings = false

minimizing this config when testing from git 1.86 or master to just:

# See bootstrap.example.toml for documentation of available options
#
profile = "compiler"  # Includes one of the default files in src/bootstrap/defaults
change-id = 140732

[build]
verbose = 2
[rust]
verbose-tests = true
rpath = false

with the following diff to run on 64-bit x86:

diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs
index e212dc74fd1..76621317b2c 100644
--- a/tests/ui/feature-gates/version_check.rs
+++ b/tests/ui/feature-gates/version_check.rs
@@ -1,6 +1,6 @@
 //@ run-pass
 //@ only-linux
-//@ only-x86
+//@ only-x86_64
 // FIXME: this should be more like //@ needs-subprocesses
 use std::process::Command;
 

and the following command:

./x --stage 2 test tests/ui/feature-gates/version_check.rs

reproduces the issue as well. without rpath=false it works.

Operating system

Debian experimental

HEAD

1.86 tarball

Additional context

Build Log

<log>

@Fabian-Gruenbichler Fabian-Gruenbichler added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. labels May 26, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 26, 2025
@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 26, 2025
@jieyouxu
Copy link
Member

jieyouxu commented May 26, 2025

That test invokes raw RUSTC through env var, which performs no rpath-less handling

let version = Command::new(std::env::var_os("RUSTC").unwrap())

@jieyouxu
Copy link
Member

jieyouxu commented May 26, 2025

That should be converted to a run-make test and fixed like #140843

let mut rustc = bare_rustc(); // <- handles host rpath libs
// do the version check logic
// ...

@jieyouxu jieyouxu added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label May 26, 2025
@Fabian-Gruenbichler
Copy link
Contributor Author

sounds like the right approach - should I prepare an MR or will you? :)

@jieyouxu
Copy link
Member

sounds like the right approach - should I prepare an MR or will you? :)

I won't get to this super soon, PRs welcomed :)

@bors bors closed this as completed in 09e643f May 27, 2025
rust-timer added a commit that referenced this issue May 27, 2025
Rollup merge of #141640 - Fabian-Gruenbichler:mr/test-version-check-rpath-false, r=jieyouxu

test: convert version_check ui test to run-make

else it breaks with `rpath=false`.

Fixes: #141579
github-actions bot pushed a commit to rust-lang/miri that referenced this issue May 28, 2025
…path-false, r=jieyouxu

test: convert version_check ui test to run-make

else it breaks with `rpath=false`.

Fixes: rust-lang/rust#141579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants