@@ -2002,14 +2002,12 @@ pub fn run_cargo(
2002
2002
|| filename. ends_with ( ".a" )
2003
2003
|| is_debug_info ( & filename)
2004
2004
|| is_dylib ( & filename)
2005
+ || filename. ends_with ( ".rmeta" )
2005
2006
{
2006
- // Always keep native libraries, rust dylibs and debuginfo
2007
+ // Always keep native libraries, rust dylibs, debuginfo and crate metadata
2007
2008
keep = true ;
2008
2009
}
2009
- if is_check && filename. ends_with ( ".rmeta" ) {
2010
- // During check builds we need to keep crate metadata
2011
- keep = true ;
2012
- } else if rlib_only_metadata {
2010
+ if !is_check && rlib_only_metadata {
2013
2011
if filename. contains ( "jemalloc_sys" )
2014
2012
|| filename. contains ( "rustc_smir" )
2015
2013
|| filename. contains ( "stable_mir" )
@@ -2021,7 +2019,6 @@ pub fn run_cargo(
2021
2019
// Distribute the rest of the rustc crates as rmeta files only to reduce
2022
2020
// the tarball sizes by about 50%. The object files are linked into
2023
2021
// librustc_driver.so, so it is still possible to link against them.
2024
- keep |= filename. ends_with ( ".rmeta" ) ;
2025
2022
}
2026
2023
} else {
2027
2024
// In all other cases keep all rlibs
@@ -2067,7 +2064,12 @@ pub fn run_cargo(
2067
2064
let file_stem = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2068
2065
let extension = parts. next ( ) . unwrap ( ) . to_owned ( ) ;
2069
2066
2070
- toplevel. push ( ( file_stem, extension, expected_len) ) ;
2067
+ if extension == "so" || extension == "dylib" {
2068
+ // FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
2069
+ toplevel. push ( ( file_stem. clone ( ) , "rmeta" . to_owned ( ) , None ) ) ;
2070
+ }
2071
+
2072
+ toplevel. push ( ( file_stem, extension, Some ( expected_len) ) ) ;
2071
2073
}
2072
2074
} ) ;
2073
2075
@@ -2088,7 +2090,7 @@ pub fn run_cargo(
2088
2090
. collect :: < Vec < _ > > ( ) ;
2089
2091
for ( prefix, extension, expected_len) in toplevel {
2090
2092
let candidates = contents. iter ( ) . filter ( |& ( _, filename, meta) | {
2091
- meta. len ( ) == expected_len
2093
+ expected_len . map_or ( true , |expected_len| meta. len ( ) == expected_len)
2092
2094
&& filename
2093
2095
. strip_prefix ( & prefix[ ..] )
2094
2096
. map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
@@ -2099,6 +2101,7 @@ pub fn run_cargo(
2099
2101
} ) ;
2100
2102
let path_to_add = match max {
2101
2103
Some ( triple) => triple. 0 . to_str ( ) . unwrap ( ) ,
2104
+ None if extension == "rmeta" => continue , // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
2102
2105
None => panic ! ( "no output generated for {prefix:?} {extension:?}" ) ,
2103
2106
} ;
2104
2107
if is_dylib ( path_to_add) {
0 commit comments