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