Skip to content

Commit 5a1936f

Browse files
committed
Revert build_llvm_sysroot_for_triple back from reading the manifest to filtering
Reading the manifest doesn't work when running in the context of the rust build system.
1 parent cb49fe5 commit 5a1936f

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,35 @@ fn build_sysroot_for_triple(
161161
fn 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

178195
fn build_clif_sysroot_for_triple(

0 commit comments

Comments
 (0)