@@ -1742,17 +1742,19 @@ fn copy_codegen_backends_to_sysroot(
1742
1742
}
1743
1743
1744
1744
let stamp = build_stamp:: codegen_backend_stamp ( builder, compiler, target, backend) ;
1745
- let dylib = t ! ( fs:: read_to_string( stamp. path( ) ) ) ;
1746
- let file = Path :: new ( & dylib) ;
1747
- let filename = file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1748
- // change `librustc_codegen_cranelift-xxxxxx.so` to
1749
- // `librustc_codegen_cranelift-release.so`
1750
- let target_filename = {
1751
- let dash = filename. find ( '-' ) . unwrap ( ) ;
1752
- let dot = filename. find ( '.' ) . unwrap ( ) ;
1753
- format ! ( "{}-{}{}" , & filename[ ..dash] , builder. rust_release( ) , & filename[ dot..] )
1754
- } ;
1755
- builder. copy_link ( file, & dst. join ( target_filename) , FileType :: NativeLibrary ) ;
1745
+ if stamp. path ( ) . exists ( ) {
1746
+ let dylib = t ! ( fs:: read_to_string( stamp. path( ) ) ) ;
1747
+ let file = Path :: new ( & dylib) ;
1748
+ let filename = file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1749
+ // change `librustc_codegen_cranelift-xxxxxx.so` to
1750
+ // `librustc_codegen_cranelift-release.so`
1751
+ let target_filename = {
1752
+ let dash = filename. find ( '-' ) . unwrap ( ) ;
1753
+ let dot = filename. find ( '.' ) . unwrap ( ) ;
1754
+ format ! ( "{}-{}{}" , & filename[ ..dash] , builder. rust_release( ) , & filename[ dot..] )
1755
+ } ;
1756
+ builder. copy_link ( file, & dst. join ( target_filename) , FileType :: NativeLibrary ) ;
1757
+ }
1756
1758
}
1757
1759
}
1758
1760
@@ -2163,6 +2165,25 @@ impl Step for Assemble {
2163
2165
continue ; // Already built as part of rustc
2164
2166
}
2165
2167
2168
+ // FIXME: this is a horrible hack used to make `x check` work when other codegen
2169
+ // backends are enabled.
2170
+ // `x check` will check stage 1 rustc, which copies its rmetas to the stage0 sysroot.
2171
+ // Then it checks codegen backends, which correctly use these rmetas.
2172
+ // Then it needs to check std, but for that it needs to build stage 1 rustc.
2173
+ // This copies the build rmetas into the stage0 sysroot, effectively poisoning it,
2174
+ // because we then have both check and build rmetas in the same sysroot.
2175
+ // That would be fine on its own. However, when another codegen backend is enabled,
2176
+ // then building stage 1 rustc implies also building stage 1 codegen backend (even if
2177
+ // it isn't used for anything). And since that tries to use the poisoned
2178
+ // rmetas, it fails to build.
2179
+ // We don't actually need to build rustc-private codegen backends for checking std,
2180
+ // so instead we skip that.
2181
+ // Note: this would be also an issue for other rustc-private tools, but that is "solved"
2182
+ // by check::Std being last in the list of checked things (see
2183
+ // `Builder::get_step_descriptions`).
2184
+ if builder. kind == Kind :: Check && builder. top_stage == 1 {
2185
+ continue ;
2186
+ }
2166
2187
builder. ensure ( CodegenBackend {
2167
2188
compiler : build_compiler,
2168
2189
target : target_compiler. host ,
0 commit comments