Skip to content

Rust building and testing fails while bootstrapping it in poky #115642

@Yashinde145

Description

@Yashinde145

Getting error while building & testing rust 1.72 via the src/bootstrap/bootstrap.py file in poky (cmd- bitbake rust and then python3 src/bootstrap/bootstrap.py test test_suites_names --target x86_64-poky-linux-gnu)in poky environment. Until rust 1.70 I was able to build & test the rust sources successfully.
But after updating to rust 1.72, there's an assertion failure causing the problem. The rust build fails as follows-

Note that not all variants of mir-opt tests are going to be blessed, as no mapping between a 
32bit and a 64bit target was found for x86_64-poky-linux-gnu.
You can add that mapping by changing MIR_OPT_BLESS_TARGET_MAPPING in src/bootstrap/test.rs
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `x86_64-unknown-linux-gnu`,
 right: `x86_64-poky-linux-gnu`: Cannot obtain compiler for non-native build triple at stage 0', compile.rs:1474:13

The code at compile.rs:1474

1470     fn run(self, builder: &Builder<'_>) -> Compiler {
1471         let target_compiler = self.target_compiler;
1472 
1473         if target_compiler.stage == 0 {
1474             assert_eq!(
1475                 builder.config.build, target_compiler.host,
1476                 "Cannot obtain compiler for non-native build triple at stage 0"
1477             );
1478             // The stage 0 compiler for the build triple is always pre-built.
1479             return target_compiler;
1480         }

Build terminates as follows-

test [mir-opt] tests/mir-opt/reference_prop.rs ... ok
test [mir-opt] tests/mir-opt/inline/polymorphic_recursion.rs ... ok
test result: ok. 249 passed; 0 failed; 13 ignored; 0 measured; 0 filtered out; finished in 1.39s

error: the option `Z` is only accepted on the nightly compiler
note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>
help: consider switching to a nightly toolchain: `rustup default nightly`
note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>
thread 'main' panicked at 'failed to gather the target spec for i686-unknown-linux-gnu', synthetic_targets.rs:66:9
Build completed unsuccessfully in 0:05:27

Version it worked on

It most recently worked on Rust 1.70 and earlier versions

Version with regression

Rust 1.72

Backtrace

Backtrace

stack backtrace:                                                                                                                                                                                                
   0: rust_begin_unwind                                                                                                                                                                                         
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5                                                                                                              
   1: core::panicking::panic_fmt                                                                                                                                                                                
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14                                                                                                             
   2: core::panicking::assert_failed_inner                                                                                                                                                                      
   3: core::panicking::assert_failed                                                                                                                                                                            
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:228:5                                                                                                             
   4: <bootstrap::compile::Assemble as bootstrap::builder::Step>::run                                                                                                                                           
             at ./src/bootstrap/compile.rs:1474:13                                                                                                                                                              
   5: bootstrap::builder::Builder::ensure                                                                                                                                                                       
             at ./src/bootstrap/builder.rs:2055:23                                                                                                                                                              
   6: bootstrap::builder::Builder::compiler                                                                                                                                                                     
             at ./src/bootstrap/builder.rs:943:9                                                                                                                                                                
   7: <bootstrap::test::Compiletest as bootstrap::builder::Step>::run                                                                                                                                           
             at ./src/bootstrap/test.rs:1462:24                                                                                                                                                                 
   8: bootstrap::builder::Builder::ensure                                                                                                                                                                       
             at ./src/bootstrap/builder.rs:2055:23                                                                                                                                                              
   9: <bootstrap::test::UiFullDeps as bootstrap::builder::Step>::run                                                                                                                                            
             at ./src/bootstrap/test.rs:1260:17                                                                                                                                                                 
  10: bootstrap::builder::Builder::ensure                                                                                                                                                                       
             at ./src/bootstrap/builder.rs:2055:23                                                                                                                                                              
  11: <bootstrap::test::UiFullDeps as bootstrap::builder::Step>::make_run                                                                                                                                       
             at ./src/bootstrap/test.rs:1256:17                                                                                                                                                                 
  12: bootstrap::builder::StepDescription::maybe_run                                                                                                                                                            
             at ./src/bootstrap/builder.rs:278:13                                                                                                                                                               
  13: bootstrap::builder::StepDescription::run                                                                                                                                                                  
             at ./src/bootstrap/builder.rs:315:21                                                                                                                                                               
  14: bootstrap::builder::Builder::run_step_descriptions                                                                                                                                                        
             at ./src/bootstrap/builder.rs:935:9                                                                                                                                                                
  15: bootstrap::builder::Builder::execute_cli                                                                                                                                                                  
             at ./src/bootstrap/builder.rs:916:9                                                                                                                                                                
  16: bootstrap::Build::build                                                                                                                                                                                   
             at ./src/bootstrap/lib.rs:697:17                                                                                                                                                                   
  17: bootstrap::main                                                                                                                                                                                           
             at ./src/bootstrap/bin/main.rs:74:5                                                                                                                                                                
  18: core::ops::function::FnOnce::call_once                                                                                                                                                                    
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/ops/function.rs:250:5                                                                                                          
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.                                                                                                                         
Build completed unsuccessfully in 0:00:20


<!--
@rustbot modify labels: +regression-from-stable-to-{stable} -regression-untriaged 

Activity

added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 7, 2023
Noratrieb

Noratrieb commented on Sep 7, 2023

@Noratrieb
Member

I believe MIR_OPT_BLESS_TARGET_MAPPING is unrelated to the issue you're seeing, but I'm not sure.

Yashinde145

Yashinde145 commented on Sep 8, 2023

@Yashinde145
Author

Yeah, I guess the assertion failure is main cause.
Why the two strings are different though? Until rust 1.70, I didn't faced this assertion failure(diff in builder.config.build i.e left: x86_64-unknown-linux-gnu, and target_compiler.host i.e right: x86_64-poky-linux-gnu). When did git blame for these lines, found that this code was present (from 5 years i.e 2018)even in the earlier rust versions.

apiraino

apiraino commented on Sep 12, 2023

@apiraino
Contributor

Adding useful labels for triaging

@rustbot label -I-prioritize +T-bootstrap -needs-triage

added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 12, 2023
onur-ozkan

onur-ozkan commented on Sep 13, 2023

@onur-ozkan
Contributor

I couldn't reproduce this problem from the e39976f HEAD.

The assertation passes as expected(on `./x test bootstrap --target=..), I also printed them out.
image

The diff:
image

Sorry for sharing the the outputs in the image format; the attempt was done inside of QEMU(Debian 11).

Yashinde145

Yashinde145 commented on Sep 14, 2023

@Yashinde145
Author

Thanks for checking @onur-ozkan,
But, my build shows following-
Note- The targets are printed 3 times and the assertion fails in the 3rd call

Compiling clap v4.2.4
   Compiling clap_complete v4.2.2
    Finished dev [unoptimized] target(s) in 20.26s

builder.config.build = x86_64-unknown-linux-gnu
target_compiler.host = x86_64-unknown-linux-gnu
builder.config.build = x86_64-unknown-linux-gnu
target_compiler.host = x86_64-unknown-linux-gnu
builder.config.build = x86_64-unknown-linux-gnu
target_compiler.host = x86_64-poky-linux-gnu

Moreover, if I bypass the assertion check and then build, why do the compiler asks to switch to nightly channel instead of continuing to stable? I am wondering how does it gets the Z option during the build since I did not not provide any such options.

test [mir-opt] tests/mir-opt/reference_prop.rs ... ok
test [mir-opt] tests/mir-opt/inline/polymorphic_recursion.rs ... ok
test result: ok. 249 passed; 0 failed; 13 ignored; 0 measured; 0 filtered out; finished in 1.39s

error: the option `Z` is only accepted on the nightly compiler
note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>
help: consider switching to a nightly toolchain: `rustup default nightly`
note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>
thread 'main' panicked at 'failed to gather the target spec for i686-unknown-linux-gnu', synthetic_targets.rs:66:9
Build completed unsuccessfully in 0:05:27

Let me know if I am missing something

onur-ozkan

onur-ozkan commented on Sep 14, 2023

@onur-ozkan
Contributor

Do you have a custom config.toml?

Yashinde145

Yashinde145 commented on Sep 14, 2023

@Yashinde145
Author

The config.toml generated during the rust build is as follows-

build_dir is the directory where I am building rust (using cmd bitbake rust in yocto poky sources)

[target.x86_64-poky-linux-gnu]                                                                                                                                                                                  
llvm-config = "build_dir/recipe-sysroot/usr/lib/llvm-rust/bin/llvm-config"                                                                         
cxx = "build_dir/wrapper/target-rust-cxx"                                                                                                          
cc = "build_dir/wrapper/target-rust-cc"                                                                                                            
linker = "build_dir/wrapper/target-rust-ccld"                                                                                                      
                                                                                                                                                                                                                
[target.x86_64-unknown-linux-gnu]                                                                                                                                                                               
llvm-config = "build_dir/recipe-sysroot-native/usr/lib/llvm-rust/bin/llvm-config"                                                                  
cxx = "build_dir/wrapper/build-rust-cxx"                                                                                                           
cc = "build_dir/wrapper/build-rust-cc"                                                                                                             
linker = "build_dir/wrapper/build-rust-ccld"                                                                                                       
                                                                                                                                                                                                                
[llvm]                                                                                                                                                                                                          
static-libstdcpp = false                                                                                                                                                                                        
                                                                                                                                                                                                                
[rust]                                                                                                                                                                                                          
rpath = true                                                                                                                                                                                                    
channel = "stable"                                                                                                                                                                                              
optimize = true                                                                                                                                                                                                 
verbose-tests = true                                                                                                                                                                                            
                                                                                                                                                                                                                
[build]                                                                                                                                                                                                         
submodules = false                                                                                                                                                                                              
docs = false                                                                                                                                                                                                    
rustc = "build_dir/rust-snapshot/bin/rustc"                                                                                                        
profiler = true                                                                                                                                                                                                 
cargo = "build_dir/rust-snapshot/bin/cargo"                                                                                                        
vendor = true                                                                                                                                                                                                   
target = ["x86_64-poky-linux-gnu"]                                                                                                                                                                              
host = ["x86_64-poky-linux-gnu"]                                                                                                                                                                                
build = "x86_64-unknown-linux-gnu"                                                                                                                                                                              
                                                                                                                                                                                                                
[install]                                                                                                                                                                                                       
prefix = "build_dir/image/usr"                                                                                                                     
bindir = "build_dir/image/usr/bin"                                                                                                                 
libdir = "build_dir/image/usr/lib"                                                                                                                 
datadir = "build_dir/image/usr/share"                                                                                                              
mandir = "build_dir/image/usr/share/man"
onur-ozkan

onur-ozkan commented on Sep 14, 2023

@onur-ozkan
Contributor

iirc bitbake rust will give you the stable 1.68 compiler. If so, please remove build.cargo and build.rust from your configuration, and use the beta compiler which will be downloaded from CI automatically during the bootstrapping.

75 remaining items

onur-ozkan

onur-ozkan commented on Jan 15, 2024

@onur-ozkan
Contributor

I meant sending tests and running in the qemu environment

I tested with the two commits and the errors of using nightly flag and custom target specs were not seen. Testing was completed for the test suites like ui, run-pass-valgrind, coverage, mir-opt, codegen, assembly, incremental.

But, after that while coping libs to qemu emulator(we run the test suite on qemu), following io::copy panic was observed:

 REMOTE copy libs to emulator (x86_64-poky-linux-gnu)                                                                          
 Building stage0 tool remote-test-server (x86_64-unknown-linux-gnu -> x86_64-poky-linux-gnu)
 
                        
 done pushing "/home/build-st/tmp/work/core2-64-poky-linux/rust/1.75.0/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-poky-linux-gnu/lib/libcstr-d49e684941d617ce.so"                                   
 done pushing "/home/build-st/tmp/work/core2-64-poky-linux/rust/1.75.0/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-poky-linux-gnu/lib/libzerovec_derive-52a1b6c914833752.so"                         
 done pushing "/home/build-st/tmp/work/core2-64-poky-linux/rust/1.75.0/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-poky-linux-gnu/lib/librustc_fluent_macro-4b4331439c3bd942.so"
 
thread 'main' panicked at src/tools/remote-test-client/src/main.rs:353:5: 
io::copy(&mut file, dst) failed with Connection reset by peer (os error 104)                                                  
 stack backtrace:                                                                                                              
    0: rust_begin_unwind                                                                                                       
              at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5                            
    1: core::panicking::panic_fmt                                                                                              
              at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14                           
    2: remote_test_client::send                                                                                                
    3: remote_test_client::main                                                                                                
 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.                                       
 Build completed unsuccessfully in 0:09:27

Is the error always the same, like this?

Yashinde145

Yashinde145 commented on Jan 15, 2024

@Yashinde145
Author

Yes, the error is always same.

onur-ozkan

onur-ozkan commented on Jan 15, 2024

@onur-ozkan
Contributor

Can you try this patch onur-ozkan@43183f7 and tell me if it fixes the problem?

Yashinde145

Yashinde145 commented on Jan 15, 2024

@Yashinde145
Author

The onur-ozkan@43183f7 patch does not fix the problem. Still, the same error is seen.

onur-ozkan

onur-ozkan commented on Jan 15, 2024

@onur-ozkan
Contributor

I was able to repreduce the io::copy(&mut file, dst) failed with Connection reset by peer (os error 104) error, but only by sending large files (and the patch I linked fixes it).

Unfortunately I don't know your use case, and I can't invest time on #115642 (comment) for debugging or trying to reproduce the error. If you can't debug and fix the problem you get, I suggest you to give more context about your use case (configurations, commands, etc.) under the #97669 issue.

Yashinde145

Yashinde145 commented on Jan 16, 2024

@Yashinde145
Author

I got some work around for this,
by excluding ui-fulldeps test suite and src/tools/replace-version-placeholder, src/tools/jsondoclint tests and it works for x86_64-poky-linux-gnu.

But, when I check for other cross-compiled targets(x86 32 bit, arm 32 & 64 bits and mips64), the following lib failure is seen

error: linking with `cc` failed: exit status: 1

build-st/tmp/hosttools/ld:  build-st/tmp/work/core2-32-poky-linux/rust/1.74.1/rustc-1.74.1-src/build/x86_64-unknown-linux-gnu/stage1-std/i686-poky-linux-gnu-synthetic-miropt-abort/release/deps/std-55f86614dec482ec.3j457j23godxdmvr.rcgu.o: file class ELFCLASS32 incompatible with ELFCLASS64
build-st/tmp/hosttools/ld: final link failed: file in wrong format

collect2: error: ld returned 1 exit status
error: could not compile `std` (lib) due to previous error

I am investigating the problem and will let you know if there are any updates.

onur-ozkan

onur-ozkan commented on Jan 16, 2024

@onur-ozkan
Contributor

That seems to be related with MirOptPanicAbortSyntheticTarget tests

let panic_abort_target = builder.ensure(MirOptPanicAbortSyntheticTarget {
compiler: self.compiler,
base: target,
});
run(panic_abort_target);

Yashinde145

Yashinde145 commented on Jan 16, 2024

@Yashinde145
Author

Yes, the log says the same and the error was seen after MirOptPanicAbortSyntheticTarget test cases while building stage1 library artifacts.

Meanwhile, I came across the following and have a doubt,
As mentioned in #40049 (comment), do we have to pass the -C linker= flag to RUSTFLAGS explicitly for the linker error in #115642 (comment)?

Earlier it was working without passing the flag explicitly.

onur-ozkan

onur-ozkan commented on Jan 16, 2024

@onur-ozkan
Contributor

Earlier we didn't have those tests, so they might require passing -C linker=. You can try and see if that solves the problem.

Yashinde145

Yashinde145 commented on Jan 17, 2024

@Yashinde145
Author

That seems to be related with MirOptPanicAbortSyntheticTarget tests

let panic_abort_target = builder.ensure(MirOptPanicAbortSyntheticTarget {
compiler: self.compiler,
base: target,
});
run(panic_abort_target);

Is there any way to handle this panic failure and make the tests run successfully?

onur-ozkan

onur-ozkan commented on Jan 17, 2024

@onur-ozkan
Contributor

You can add --skip mir-opt to your command to exclude mir-opt tests, then run x test mir-opt to run mir-opt tests without MirOptPanicAbortSyntheticTarget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @apiraino@onur-ozkan@rustbot@Noratrieb@Yashinde145

      Issue actions

        Rust building and testing fails while bootstrapping it in poky · Issue #115642 · rust-lang/rust