@@ -2090,14 +2090,12 @@ pub fn run_cargo(
20902090 || filename. ends_with ( ".a" )
20912091 || is_debug_info ( & filename)
20922092 || is_dylib ( Path :: new ( & * filename) )
2093+ || filename. ends_with ( ".rmeta" )
20932094 {
2094- // Always keep native libraries, rust dylibs and debuginfo
2095+ // Always keep native libraries, rust dylibs, debuginfo and crate metadata
20952096 keep = true ;
20962097 }
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 {
21012099 if filename. contains ( "jemalloc_sys" )
21022100 || filename. contains ( "rustc_smir" )
21032101 || filename. contains ( "stable_mir" )
@@ -2109,7 +2107,6 @@ pub fn run_cargo(
21092107 // Distribute the rest of the rustc crates as rmeta files only to reduce
21102108 // the tarball sizes by about 50%. The object files are linked into
21112109 // librustc_driver.so, so it is still possible to link against them.
2112- keep |= filename. ends_with ( ".rmeta" ) ;
21132110 }
21142111 } else {
21152112 // In all other cases keep all rlibs
@@ -2155,7 +2152,12 @@ pub fn run_cargo(
21552152 let file_stem = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
21562153 let extension = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
21572154
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) ) ) ;
21592161 }
21602162 } ) ;
21612163
@@ -2176,7 +2178,7 @@ pub fn run_cargo(
21762178 . collect :: < Vec < _ > > ( ) ;
21772179 for ( prefix, extension, expected_len) in toplevel {
21782180 let candidates = contents. iter ( ) . filter ( |& ( _, filename, meta) | {
2179- meta. len ( ) == expected_len
2181+ expected_len . map_or ( true , |expected_len| meta. len ( ) == expected_len)
21802182 && filename
21812183 . strip_prefix ( & prefix[ ..] )
21822184 . map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
@@ -2187,6 +2189,7 @@ pub fn run_cargo(
21872189 } ) ;
21882190 let path_to_add = match max {
21892191 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
21902193 None => panic ! ( "no output generated for {prefix:?} {extension:?}" ) ,
21912194 } ;
21922195 if is_dylib ( Path :: new ( path_to_add) ) {
0 commit comments