@@ -2050,14 +2050,12 @@ pub fn run_cargo(
2050
2050
|| filename. ends_with ( ".a" )
2051
2051
|| is_debug_info ( & filename)
2052
2052
|| is_dylib ( Path :: new ( & * filename) )
2053
+ || filename. ends_with ( ".rmeta" )
2053
2054
{
2054
- // Always keep native libraries, rust dylibs and debuginfo
2055
+ // Always keep native libraries, rust dylibs, debuginfo and crate metadata
2055
2056
keep = true ;
2056
2057
}
2057
- if is_check && filename. ends_with ( ".rmeta" ) {
2058
- // During check builds we need to keep crate metadata
2059
- keep = true ;
2060
- } else if rlib_only_metadata {
2058
+ if !is_check && rlib_only_metadata {
2061
2059
if filename. contains ( "jemalloc_sys" )
2062
2060
|| filename. contains ( "rustc_smir" )
2063
2061
|| filename. contains ( "stable_mir" )
@@ -2069,7 +2067,6 @@ pub fn run_cargo(
2069
2067
// Distribute the rest of the rustc crates as rmeta files only to reduce
2070
2068
// the tarball sizes by about 50%. The object files are linked into
2071
2069
// librustc_driver.so, so it is still possible to link against them.
2072
- keep |= filename. ends_with ( ".rmeta" ) ;
2073
2070
}
2074
2071
} else {
2075
2072
// In all other cases keep all rlibs
@@ -2115,7 +2112,12 @@ pub fn run_cargo(
2115
2112
let file_stem = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2116
2113
let extension = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2117
2114
2118
- toplevel. push ( ( file_stem, extension, expected_len) ) ;
2115
+ if extension == "so" || extension == "dylib" {
2116
+ // FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
2117
+ toplevel. push ( ( file_stem. clone ( ) , "rmeta" . to_owned ( ) , None ) ) ;
2118
+ }
2119
+
2120
+ toplevel. push ( ( file_stem, extension, Some ( expected_len) ) ) ;
2119
2121
}
2120
2122
} ) ;
2121
2123
@@ -2136,7 +2138,7 @@ pub fn run_cargo(
2136
2138
. collect :: < Vec < _ > > ( ) ;
2137
2139
for ( prefix, extension, expected_len) in toplevel {
2138
2140
let candidates = contents. iter ( ) . filter ( |& ( _, filename, meta) | {
2139
- meta. len ( ) == expected_len
2141
+ expected_len . is_none_or ( |expected_len| meta. len ( ) == expected_len)
2140
2142
&& filename
2141
2143
. strip_prefix ( & prefix[ ..] )
2142
2144
. map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
@@ -2147,6 +2149,7 @@ pub fn run_cargo(
2147
2149
} ) ;
2148
2150
let path_to_add = match max {
2149
2151
Some ( triple) => triple. 0 . to_str ( ) . unwrap ( ) ,
2152
+ None if extension == "rmeta" => continue , // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
2150
2153
None => panic ! ( "no output generated for {prefix:?} {extension:?}" ) ,
2151
2154
} ;
2152
2155
if is_dylib ( Path :: new ( path_to_add) ) {
0 commit comments