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