@@ -161,18 +161,35 @@ fn build_sysroot_for_triple(
161161fn build_llvm_sysroot_for_triple ( compiler : Compiler ) -> SysrootTarget {
162162 let default_sysroot = crate :: rustc_info:: get_default_sysroot ( & compiler. rustc ) ;
163163
164- let std_manifest_path = default_sysroot
165- . join ( "lib" )
166- . join ( "rustlib" )
167- . join ( format ! ( "manifest-rust-std-{}" , compiler. triple) ) ;
168-
169- let libs = fs:: read_to_string ( std_manifest_path)
170- . unwrap ( )
171- . lines ( )
172- . map ( |entry| default_sysroot. join ( entry. strip_prefix ( "file:" ) . unwrap ( ) ) )
173- . collect ( ) ;
174-
175- SysrootTarget { triple : compiler. triple , libs }
164+ let mut target_libs = SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ;
165+
166+ for entry in fs:: read_dir (
167+ default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_libs. triple ) . join ( "lib" ) ,
168+ )
169+ . unwrap ( )
170+ {
171+ let entry = entry. unwrap ( ) ;
172+ if entry. file_type ( ) . unwrap ( ) . is_dir ( ) {
173+ continue ;
174+ }
175+ let file = entry. path ( ) ;
176+ let file_name_str = file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
177+ if ( file_name_str. contains ( "rustc_" )
178+ && !file_name_str. contains ( "rustc_std_workspace_" )
179+ && !file_name_str. contains ( "rustc_demangle" )
180+ && !file_name_str. contains ( "rustc_literal_escaper" ) )
181+ || file_name_str. contains ( "chalk" )
182+ || file_name_str. contains ( "tracing" )
183+ || file_name_str. contains ( "regex" )
184+ {
185+ // These are large crates that are part of the rustc-dev component and are not
186+ // necessary to run regular programs.
187+ continue ;
188+ }
189+ target_libs. libs . push ( file) ;
190+ }
191+
192+ target_libs
176193}
177194
178195fn build_clif_sysroot_for_triple (
0 commit comments