@@ -2072,14 +2072,12 @@ pub fn run_cargo(
2072
2072
|| filename. ends_with ( ".a" )
2073
2073
|| is_debug_info ( & filename)
2074
2074
|| is_dylib ( Path :: new ( & * filename) )
2075
+ || filename. ends_with ( ".rmeta" )
2075
2076
{
2076
- // Always keep native libraries, rust dylibs and debuginfo
2077
+ // Always keep native libraries, rust dylibs, debuginfo and crate metadata
2077
2078
keep = true ;
2078
2079
}
2079
- if is_check && filename. ends_with ( ".rmeta" ) {
2080
- // During check builds we need to keep crate metadata
2081
- keep = true ;
2082
- } else if rlib_only_metadata {
2080
+ if !is_check && rlib_only_metadata {
2083
2081
if filename. contains ( "jemalloc_sys" )
2084
2082
|| filename. contains ( "rustc_smir" )
2085
2083
|| filename. contains ( "stable_mir" )
@@ -2091,7 +2089,6 @@ pub fn run_cargo(
2091
2089
// Distribute the rest of the rustc crates as rmeta files only to reduce
2092
2090
// the tarball sizes by about 50%. The object files are linked into
2093
2091
// librustc_driver.so, so it is still possible to link against them.
2094
- keep |= filename. ends_with ( ".rmeta" ) ;
2095
2092
}
2096
2093
} else {
2097
2094
// In all other cases keep all rlibs
@@ -2137,7 +2134,12 @@ pub fn run_cargo(
2137
2134
let file_stem = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2138
2135
let extension = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2139
2136
2140
- toplevel. push ( ( file_stem, extension, expected_len) ) ;
2137
+ if extension == "so" || extension == "dylib" {
2138
+ // FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
2139
+ toplevel. push ( ( file_stem. clone ( ) , "rmeta" . to_owned ( ) , None ) ) ;
2140
+ }
2141
+
2142
+ toplevel. push ( ( file_stem, extension, Some ( expected_len) ) ) ;
2141
2143
}
2142
2144
} ) ;
2143
2145
@@ -2158,7 +2160,7 @@ pub fn run_cargo(
2158
2160
. collect :: < Vec < _ > > ( ) ;
2159
2161
for ( prefix, extension, expected_len) in toplevel {
2160
2162
let candidates = contents. iter ( ) . filter ( |& ( _, filename, meta) | {
2161
- meta. len ( ) == expected_len
2163
+ expected_len . map_or ( true , |expected_len| meta. len ( ) == expected_len)
2162
2164
&& filename
2163
2165
. strip_prefix ( & prefix[ ..] )
2164
2166
. map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
@@ -2169,6 +2171,7 @@ pub fn run_cargo(
2169
2171
} ) ;
2170
2172
let path_to_add = match max {
2171
2173
Some ( triple) => triple. 0 . to_str ( ) . unwrap ( ) ,
2174
+ None if extension == "rmeta" => continue , // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
2172
2175
None => panic ! ( "no output generated for {prefix:?} {extension:?}" ) ,
2173
2176
} ;
2174
2177
if is_dylib ( Path :: new ( path_to_add) ) {
0 commit comments