Building Rust with rpath disabled causes ~3k test failures in Cargo #140299
Labels
C-bug
Category: This is a bug.
T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Summary
When building Rust with rpath disabled (using
--disable-rpath
), the majority of Cargo tests fail due to a missing librustc_driver:Fedora disables rpath in its builds, and this has not been an issue up to Rust 1.86.0, since the bootstrap process correctly passed the appropriate
LD_LIBRARY_PATH
. We started encountering failures while preparing builds for the 1.87.0 beta.I was able to reproduce and bisect the issue using a clean repository with the following script:
Using this, I traced the regression to the following PR: #137215
From inspecting the output of
x.py test -vv
, it seems the issue is related to the combination of howLD_LIBRARY_PATH
is set by bootstrap and possibly some cleanup logic. I wasn't able to fully trace the exact logic, but here are my observations.Before that PR, Cargo tests were run using the stage 2 compiler, and the library path passed by bootstrap was:
This directory does include the librustc_driver dynamic library.
After the PR, the compiler being used is now stage 1, as indicated by bootstrap logs such as:
The library path passed now is:
But in this case, the test errors with:
If I search for that library, I can find it in several locations, but not in the path that bootstrap passes:
As a workaround, the tests can be run successfully using:
However, I believe this behavior deserves closer attention from the bootstrap team. It's possible that the stage 1 switch introduced an unintended change in how the dynamic libraries are located, especially when rpath is disabled.
Let me know if you need help reproducing the issue in a clean environment.
When building Rust with
--disable-rpath
, most Cargo tests fail due to missing dynamic libraries, notably librustc_driver. This started happening after PR #137215, which changed Cargo to use the stage1 compiler instead of stage2 during tests. The bootstrap no longer passes the correct LD_LIBRARY_PATH for the dynamic libraries in this configuration, breaking Fedora builds (which disable rpath).Command used
Expected behaviour
Cargo tests are run without rustc reporting any missing dynamic libraries
Actual behaviour
+3000 cargo test failures due to missing rustc_driver dynamic library
Bootstrap configuration (bootstrap.toml)
Operating system
Fedora 43 Rawhide (reproducible on a clean environment)
HEAD
bb2cc59
Also reproducible on current beta (386abeb) and master(7f69523) branches.
Additional context
Build Log
The text was updated successfully, but these errors were encountered: