Skip to content

[riscv64] test: rustc-main fails to run due to missing librustc_driver in stage2 runtime lib directory #158526

Description

@yuzibo

Running ./x test --stage 2 compiler/rustc on riscv64 directly, will get:

jenkins@bd64e4381fdb:~/rust$ ./x test --stage 2 compiler/rustc                                                                                                                                                                               
Building bootstrap                                                                                                                                                                                                                           
    Finished `dev` profile [unoptimized] target(s) in 0.54s                                                                                                                                                                                  
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.                                                                           NOTE: to silence this warning, add `change-id = 154587` or `change-id = "ignore"` at the top of `bootstrap.toml`                                                                                                                             
/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy                                                                                                                                    
Building stage1 compiler artifacts (stage0 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                           
    Finished `release` profile [optimized] target(s) in 2.10s                                                                                                                                                                                
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)                                                                                                                                                
Building stage1 library artifacts (stage1 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                            
    Finished `dist` profile [optimized] target(s) in 0.25s                                                            
Building stage1 library artifacts (stage1 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                            
    Finished `dist` profile [optimized] target(s) in 0.23s                                                            
Building stage1 rustdoc_tool_binary (stage0 -> stage1, riscv64gc-unknown-linux-gnu)                                   
    Finished `release` profile [optimized] target(s) in 1.28s                                                                                                                                                                                
Testing stage2 {rustc-main} (riscv64gc-unknown-linux-gnu)                                                                                                                                                                                    
    Finished `release` profile [optimized] target(s) in 1.97s                                                                                                                                                                                
     Running unittests src/main.rs (build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out/rustc_main-285c3215b182a82d)                                                    
/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out/rustc_main-285c3215b182a82d: error while loading shared libraries: librustc_driver-3be33d380cc114
b2.so: cannot open shared object file: No such file or directory                                                                                                                                                                             
error: test failed, to rerun pass `-p rustc-main --bin rustc-main`                                                                                                                                                                           
                                                                                                                                                                                                                                             
Caused by:                                                                                                                                                                                                                                   
  process didn't exit successfully: `/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out/rustc_main-285c3215b182a82d --quiet -Z unstable-options --fo
rmat json` (exit status: 127)                                                                                                                                                                                                                
note: test exited abnormally; to see the full output pass --no-capture to the harness.                                                                                                                                                       
Build completed unsuccessfully in 0:01:22                                                        

In fact, the reslut will be reproducied by running ./x test --stage 2 also.

At first, I kept wondering if there was an issue with our CI workflow which as below:

# based on one stage 1 Docker image, then
 ./x build --stage 2
 ./x check --stage 2
./x test --stage 2

I even try to ./x dist --stage 2 before check but it does not work. Here is I am missing something?

Back to the issue:

jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ ls
rustc_main-285c3215b182a82d  rustc_main-285c3215b182a82d.d
jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ ./rustc_main-285c3215b182a82d 
./rustc_main-285c3215b182a82d: error while loading shared libraries: librustc_driver-3be33d380cc114b2.so: cannot open shared object file: No such file or directory
jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ readelf -d rustc_main-285c3215b182a82d

Dynamic section at offset 0x5a888 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [librustc_driver-3be33d380cc114b2.so]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-riscv64-lp64d.so.1]
 0x000000000000001d (RUNPATH)           Library runpath: [$ORIGIN/../lib]
...

Obviuosly, the dynamic section display the libraqry runpatch is located in $ORIGIN/../lib, however, there is no corresponding relative directory or library for this executable program. If cp the *.so to the ../lib, the test will be okay.

jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ mkdir -p ../lib                                                                        
jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ ls ../                                                                                 
fingerprint  lib  out                                                                                                                                                                                                                        
jenkins@bd64e4381fdb:~/rust/build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out$ cd                                                                                     
jenkins@bd64e4381fdb:~$ cd rust/                                                                                                                                                                                                             
jenkins@bd64e4381fdb:~/rust$ cp build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc_driver/3be33d380cc114b2/out/librustc_driver-3be33d380cc114b2.so build/riscv64gc-unknown-linux-gnu/stage2-rustc
/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/lib/                                                                                                                                                                  
jenkins@bd64e4381fdb:~/rust$ ./x test --stage 2 compiler/rustc                                                                                                                                                                               
Building bootstrap                                                                                                                                                                                                                           
    Finished `dev` profile [unoptimized] target(s) in 0.39s                                                                                                                                                                                  
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.                                                                           
NOTE: to silence this warning, add `change-id = 154587` or `change-id = "ignore"` at the top of `bootstrap.toml`                                                                                                                             
/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy             
Building stage1 compiler artifacts (stage0 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                           
    Finished `release` profile [optimized] target(s) in 1.85s                                                         
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)                         
Building stage1 library artifacts (stage1 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                            
    Finished `dist` profile [optimized] target(s) in 0.21s                                                                                                                                                                                   
Building stage1 library artifacts (stage1 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                            
    Finished `dist` profile [optimized] target(s) in 0.21s                                                                                                                                                                                   
Building stage1 rustdoc_tool_binary (stage0 -> stage1, riscv64gc-unknown-linux-gnu)                                                                                                                                                          
    Finished `release` profile [optimized] target(s) in 1.15s                                                                                                                                                                                
Testing stage2 {rustc-main} (riscv64gc-unknown-linux-gnu)                                                                                                                                                                                    
    Finished `release` profile [optimized] target(s) in 1.79s                                                                                                                                                                                
     Running unittests src/main.rs (build/riscv64gc-unknown-linux-gnu/stage2-rustc/riscv64gc-unknown-linux-gnu/release/build/rustc-main/285c3215b182a82d/out/rustc_main-285c3215b182a82d)                                                    
                                                                                                                                                                                                                                             
running 0 tests                                                                                                                                                                                                                              
                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                             
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 226.44µs                                                                                                                                             
                                                                                                                                                                                                                                             
        finished in 2.149 seconds                                                                                                                                                                                                            
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.                                                                           
NOTE: to silence this warning, add `change-id = 154587` or `change-id = "ignore"` at the top of `bootstrap.toml`                                                                                                                             
NOTE: this message was printed twice to make it more likely to be seen                                                                                                                                                                       
Build completed successfully in 0:00:19                                                 

Even though there is no real test case to be executed, but the build has no problem from the log. But I am lacking confidence about the issue is true or is there a problem with our workflow?

Meta

rustc --version --verbose:

rustc 1.98.0-dev

Detected by ruyici, opening this to track.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions