@@ -2090,14 +2090,12 @@ pub fn run_cargo(
2090
2090
|| filename. ends_with ( ".a" )
2091
2091
|| is_debug_info ( & filename)
2092
2092
|| is_dylib ( Path :: new ( & * filename) )
2093
+ || filename. ends_with ( ".rmeta" )
2093
2094
{
2094
- // Always keep native libraries, rust dylibs and debuginfo
2095
+ // Always keep native libraries, rust dylibs, debuginfo and crate metadata
2095
2096
keep = true ;
2096
2097
}
2097
- if is_check && filename. ends_with ( ".rmeta" ) {
2098
- // During check builds we need to keep crate metadata
2099
- keep = true ;
2100
- } else if rlib_only_metadata {
2098
+ if !is_check && rlib_only_metadata {
2101
2099
if filename. contains ( "jemalloc_sys" )
2102
2100
|| filename. contains ( "rustc_smir" )
2103
2101
|| filename. contains ( "stable_mir" )
@@ -2109,7 +2107,6 @@ pub fn run_cargo(
2109
2107
// Distribute the rest of the rustc crates as rmeta files only to reduce
2110
2108
// the tarball sizes by about 50%. The object files are linked into
2111
2109
// librustc_driver.so, so it is still possible to link against them.
2112
- keep |= filename. ends_with ( ".rmeta" ) ;
2113
2110
}
2114
2111
} else {
2115
2112
// In all other cases keep all rlibs
@@ -2155,7 +2152,12 @@ pub fn run_cargo(
2155
2152
let file_stem = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2156
2153
let extension = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2157
2154
2158
- toplevel. push ( ( file_stem, extension, expected_len) ) ;
2155
+ if extension == "so" || extension == "dylib" {
2156
+ // FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
2157
+ toplevel. push ( ( file_stem. clone ( ) , "rmeta" . to_owned ( ) , None ) ) ;
2158
+ }
2159
+
2160
+ toplevel. push ( ( file_stem, extension, Some ( expected_len) ) ) ;
2159
2161
}
2160
2162
} ) ;
2161
2163
@@ -2176,7 +2178,7 @@ pub fn run_cargo(
2176
2178
. collect :: < Vec < _ > > ( ) ;
2177
2179
for ( prefix, extension, expected_len) in toplevel {
2178
2180
let candidates = contents. iter ( ) . filter ( |& ( _, filename, meta) | {
2179
- meta. len ( ) == expected_len
2181
+ expected_len . map_or ( true , |expected_len| meta. len ( ) == expected_len)
2180
2182
&& filename
2181
2183
. strip_prefix ( & prefix[ ..] )
2182
2184
. map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
@@ -2187,6 +2189,7 @@ pub fn run_cargo(
2187
2189
} ) ;
2188
2190
let path_to_add = match max {
2189
2191
Some ( triple) => triple. 0 . to_str ( ) . unwrap ( ) ,
2192
+ None if extension == "rmeta" => continue , // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
2190
2193
None => panic ! ( "no output generated for {prefix:?} {extension:?}" ) ,
2191
2194
} ;
2192
2195
if is_dylib ( Path :: new ( path_to_add) ) {
0 commit comments