fix(bootstrap): set dylib path for rustc tests#158530
Conversation
|
|
Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
bfc9c00 to
581cf99
Compare
|
I'm not entirely sure if this is the best approach, and I'd appreciate any feedback or suggestions. |
| if mode == Mode::Rustc { | ||
| // Build the test binaries before preparing the command that runs them. Some rustc | ||
| // dylibs are emitted into Cargo's build directory, and the run command needs to add | ||
| // those freshly-created directories to the dynamic library lookup path. |
There was a problem hiding this comment.
I'm curious why cargo doesn't already add those dylibs. It should in principle do so for all dylibs that are dependencies of an executable. Or maybe that logic is broken in cargo with the new build dir layout?
|
I looked into Cargo a bit more, and I think this is likely related to the new build-dir layout indeed. For compilation, Cargo does recursively add dependency dirs through For running test binaries, however, This PR works around that in bootstrap by doing |
Fixes #158526
compiler/rustcbuilds temporary test binaries when running./x test --stage 2 compiler/rustc. With Cargo's new build-dir layout, dylibs such asrustc_drivercan be emitted under Cargo'sbuild/*/*/outdirectories rather than a directory that is already present in the test command's dynamic library lookup path.Build the rustc test binaries once with
cargo test --no-run, then scan the Cargo build directory foroutdirectories containing dylibs and add them to the dynamic library lookup path used by the actual test run. This avoids target-specific rpath handling and uses the platform-specific lookup variable selected by bootstrap (LD_LIBRARY_PATH,DYLD_LIBRARY_PATH,PATH, etc.).Tests:
./x fmt --allgit diff --check./x check src/bootstrap./x test src/bootstrapr? @bjorn3