projects/aports·blob master · refs

462 lines · 17.9 KiB

1From 4a57da563f5da9501b3c7f9213b9cb40f9b6bf1e Mon Sep 17 00:00:00 2001
2From: q66 <[email protected]>
3Date: Fri, 30 May 2025 12:33:02 +0200
4Subject: [PATCH 02/16] remove a bunch of unused junk
5
6---
7 compiler/rustc_target/src/spec/crt_objects.rs | 22 ----
8 src/bootstrap/configure.py | 100 ------------------
9 src/bootstrap/src/core/build_steps/compile.rs | 58 +---------
10 src/bootstrap/src/core/build_steps/llvm.rs | 3 -
11 src/bootstrap/src/core/config/config.rs | 8 --
12 .../src/core/config/target_selection.rs | 4 -
13 src/bootstrap/src/core/config/toml/rust.rs | 2 -
14 src/bootstrap/src/core/config/toml/target.rs | 4 -
15 src/bootstrap/src/core/sanity.rs | 16 ---
16 src/bootstrap/src/lib.rs | 29 -----
17 src/bootstrap/src/utils/cc_detect.rs | 24 -----
18 11 files changed, 1 insertion(+), 269 deletions(-)
19
20diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs
21index 2d84e78f2..0e6cb0f42 100644
22--- a/compiler/rustc_target/src/spec/crt_objects.rs
23+++ b/compiler/rustc_target/src/spec/crt_objects.rs
24@@ -62,28 +62,6 @@ pub(super) fn all(obj: &'static str) -> CrtObjects {
25 ])
26 }
27
28-pub(super) fn pre_musl_self_contained() -> CrtObjects {
29- new(&[
30- (LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]),
31- (LinkOutputKind::DynamicPicExe, &["Scrt1.o", "crti.o", "crtbeginS.o"]),
32- (LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]),
33- (LinkOutputKind::StaticPicExe, &["rcrt1.o", "crti.o", "crtbeginS.o"]),
34- (LinkOutputKind::DynamicDylib, &["crti.o", "crtbeginS.o"]),
35- (LinkOutputKind::StaticDylib, &["crti.o", "crtbeginS.o"]),
36- ])
37-}
38-
39-pub(super) fn post_musl_self_contained() -> CrtObjects {
40- new(&[
41- (LinkOutputKind::DynamicNoPicExe, &["crtend.o", "crtn.o"]),
42- (LinkOutputKind::DynamicPicExe, &["crtendS.o", "crtn.o"]),
43- (LinkOutputKind::StaticNoPicExe, &["crtend.o", "crtn.o"]),
44- (LinkOutputKind::StaticPicExe, &["crtendS.o", "crtn.o"]),
45- (LinkOutputKind::DynamicDylib, &["crtendS.o", "crtn.o"]),
46- (LinkOutputKind::StaticDylib, &["crtendS.o", "crtn.o"]),
47- ])
48-}
49-
50 pub(super) fn pre_mingw_self_contained() -> CrtObjects {
51 new(&[
52 (LinkOutputKind::DynamicNoPicExe, &["crt2.o"]),
53diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
54index fda8f004e..3e7e828a0 100755
55--- a/src/bootstrap/configure.py
56+++ b/src/bootstrap/configure.py
57@@ -185,106 +185,6 @@ v("llvm-config", None, "set path to llvm-config")
58 v("llvm-filecheck", None, "set path to LLVM's FileCheck utility")
59 v("python", "build.python", "set path to python")
60 v("android-ndk", "build.android-ndk", "set path to Android NDK")
61-v(
62- "musl-root",
63- "target.x86_64-unknown-linux-musl.musl-root",
64- "MUSL root installation directory (deprecated)",
65-)
66-v(
67- "musl-root-x86_64",
68- "target.x86_64-unknown-linux-musl.musl-root",
69- "x86_64-unknown-linux-musl install directory",
70-)
71-v(
72- "musl-root-i586",
73- "target.i586-unknown-linux-musl.musl-root",
74- "i586-unknown-linux-musl install directory",
75-)
76-v(
77- "musl-root-i686",
78- "target.i686-unknown-linux-musl.musl-root",
79- "i686-unknown-linux-musl install directory",
80-)
81-v(
82- "musl-root-arm",
83- "target.arm-unknown-linux-musleabi.musl-root",
84- "arm-unknown-linux-musleabi install directory",
85-)
86-v(
87- "musl-root-armhf",
88- "target.arm-unknown-linux-musleabihf.musl-root",
89- "arm-unknown-linux-musleabihf install directory",
90-)
91-v(
92- "musl-root-armv5te",
93- "target.armv5te-unknown-linux-musleabi.musl-root",
94- "armv5te-unknown-linux-musleabi install directory",
95-)
96-v(
97- "musl-root-armv7",
98- "target.armv7-unknown-linux-musleabi.musl-root",
99- "armv7-unknown-linux-musleabi install directory",
100-)
101-v(
102- "musl-root-armv7hf",
103- "target.armv7-unknown-linux-musleabihf.musl-root",
104- "armv7-unknown-linux-musleabihf install directory",
105-)
106-v(
107- "musl-root-aarch64",
108- "target.aarch64-unknown-linux-musl.musl-root",
109- "aarch64-unknown-linux-musl install directory",
110-)
111-v(
112- "musl-root-mips",
113- "target.mips-unknown-linux-musl.musl-root",
114- "mips-unknown-linux-musl install directory",
115-)
116-v(
117- "musl-root-mipsel",
118- "target.mipsel-unknown-linux-musl.musl-root",
119- "mipsel-unknown-linux-musl install directory",
120-)
121-v(
122- "musl-root-mips64",
123- "target.mips64-unknown-linux-muslabi64.musl-root",
124- "mips64-unknown-linux-muslabi64 install directory",
125-)
126-v(
127- "musl-root-mips64el",
128- "target.mips64el-unknown-linux-muslabi64.musl-root",
129- "mips64el-unknown-linux-muslabi64 install directory",
130-)
131-v(
132- "musl-root-powerpc64",
133- "target.powerpc64-unknown-linux-musl.musl-root",
134- "powerpc64-unknown-linux-musl install directory",
135-)
136-v(
137- "musl-root-powerpc64le",
138- "target.powerpc64le-unknown-linux-musl.musl-root",
139- "powerpc64le-unknown-linux-musl install directory",
140-)
141-v(
142- "musl-root-riscv32gc",
143- "target.riscv32gc-unknown-linux-musl.musl-root",
144- "riscv32gc-unknown-linux-musl install directory",
145-)
146-v(
147- "musl-root-riscv64gc",
148- "target.riscv64gc-unknown-linux-musl.musl-root",
149- "riscv64gc-unknown-linux-musl install directory",
150-)
151-v(
152- "musl-root-loongarch64",
153- "target.loongarch64-unknown-linux-musl.musl-root",
154- "loongarch64-unknown-linux-musl install directory",
155-)
156-v(
157- "musl-root-wali-wasm32",
158- "target.wasm32-wali-linux-musl.musl-root",
159- "wasm32-wali-linux-musl install directory",
160-)
161 v(
162 "qemu-armhf-rootfs",
163 "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
164diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
165index 11f2a28bb..0270fafcc 100644
166--- a/src/bootstrap/src/core/build_steps/compile.rs
167+++ b/src/bootstrap/src/core/build_steps/compile.rs
168@@ -382,54 +382,7 @@ fn copy_self_contained_objects(
169 t!(fs::create_dir_all(&libdir_self_contained));
170 let mut target_deps = vec![];
171
172- // Copies the libc and CRT objects.
173- //
174- // rustc historically provides a more self-contained installation for musl targets
175- // not requiring the presence of a native musl toolchain. For example, it can fall back
176- // to using gcc from a glibc-targeting toolchain for linking.
177- // To do that we have to distribute musl startup objects as a part of Rust toolchain
178- // and link with them manually in the self-contained mode.
179- if target.needs_crt_begin_end() {
180- let srcdir = builder.musl_libdir(target).unwrap_or_else(|| {
181- panic!("Target {:?} does not have a \"musl-libdir\" key", target.triple)
182- });
183- if !target.starts_with("wasm32") {
184- for &obj in &["libc.a", "crt1.o", "Scrt1.o", "rcrt1.o", "crti.o", "crtn.o"] {
185- copy_and_stamp(
186- builder,
187- &libdir_self_contained,
188- &srcdir,
189- obj,
190- &mut target_deps,
191- DependencyType::TargetSelfContained,
192- );
193- }
194- let crt_path = builder.ensure(llvm::CrtBeginEnd { target });
195- for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] {
196- let src = crt_path.join(obj);
197- let target = libdir_self_contained.join(obj);
198- builder.copy_link(&src, &target, FileType::NativeLibrary);
199- target_deps.push((target, DependencyType::TargetSelfContained));
200- }
201- } else {
202- // For wasm32 targets, we need to copy the libc.a and crt1-command.o files from the
203- // musl-libdir, but we don't need the other files.
204- for &obj in &["libc.a", "crt1-command.o"] {
205- copy_and_stamp(
206- builder,
207- &libdir_self_contained,
208- &srcdir,
209- obj,
210- &mut target_deps,
211- DependencyType::TargetSelfContained,
212- );
213- }
214- }
215- if !target.starts_with("s390x") {
216- let libunwind_path = copy_llvm_libunwind(builder, target, &libdir_self_contained);
217- target_deps.push((libunwind_path, DependencyType::TargetSelfContained));
218- }
219- } else if target.contains("-wasi") {
220+ if target.contains("-wasi") {
221 let srcdir = builder.wasi_libdir(target).unwrap_or_else(|| {
222 panic!(
223 "Target {:?} does not have a \"wasi-root\" key in bootstrap.toml \
224@@ -670,15 +623,6 @@ pub fn std_cargo(
225 .arg("--manifest-path")
226 .arg(builder.src.join("library/sysroot/Cargo.toml"));
227
228- // Help the libc crate compile by assisting it in finding various
229- // sysroot native libraries.
230- if target.contains("musl")
231- && let Some(p) = builder.musl_libdir(target)
232- {
233- let root = format!("native={}", p.to_str().unwrap());
234- cargo.rustflag("-L").rustflag(&root);
235- }
236-
237 if target.contains("-wasi")
238 && let Some(dir) = builder.wasi_libdir(target)
239 {
240diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
241index c3935d981..509cba033 100644
242--- a/src/bootstrap/src/core/build_steps/llvm.rs
243+++ b/src/bootstrap/src/core/build_steps/llvm.rs
244@@ -1767,9 +1767,6 @@ impl Step for CrtBeginEnd {
245 }
246
247 fn make_run(run: RunConfig<'_>) {
248- if run.target.needs_crt_begin_end() {
249- run.builder.ensure(CrtBeginEnd { target: run.target });
250- }
251 }
252
253 /// Build crtbegin.o/crtend.o for musl target.
254diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
255index 07405a030..4e4c4f72e 100644
256--- a/src/bootstrap/src/core/config/config.rs
257+++ b/src/bootstrap/src/core/config/config.rs
258@@ -273,8 +273,6 @@ pub struct Config {
259 pub print_step_timings: bool,
260 pub print_step_rusage: bool,
261
262- // Fallback musl-root for all targets
263- pub musl_root: Option<PathBuf>,
264 pub prefix: Option<PathBuf>,
265 pub sysconfdir: Option<PathBuf>,
266 pub datadir: Option<PathBuf>,
267@@ -579,7 +577,6 @@ impl Config {
268 randomize_layout: rust_randomize_layout,
269 default_linker: rust_default_linker,
270 channel: rust_channel,
271- musl_root: rust_musl_root,
272 rpath: rust_rpath,
273 verbose_tests: rust_verbose_tests,
274 optimize_tests: rust_optimize_tests,
275@@ -970,8 +967,6 @@ impl Config {
276 rpath: target_rpath,
277 rustflags: target_rustflags,
278 crt_static: target_crt_static,
279- musl_root: target_musl_root,
280- musl_libdir: target_musl_libdir,
281 wasi_root: target_wasi_root,
282 qemu_rootfs: target_qemu_rootfs,
283 no_std: target_no_std,
284@@ -1045,8 +1040,6 @@ impl Config {
285 target.crt_static = target_crt_static;
286 target.default_linker = target_default_linker;
287 target.default_linker_linux_override = default_linker_linux_override;
288- target.musl_root = target_musl_root.map(PathBuf::from);
289- target.musl_libdir = target_musl_libdir.map(PathBuf::from);
290 target.wasi_root = target_wasi_root.map(PathBuf::from);
291 target.qemu_rootfs = target_qemu_rootfs.map(PathBuf::from);
292 target.runner = target_runner;
293@@ -1520,7 +1513,6 @@ impl Config {
294 low_priority: build_low_priority.unwrap_or(false),
295 mandir: install_mandir.map(PathBuf::from),
296 miri_info,
297- musl_root: rust_musl_root.map(PathBuf::from),
298 ninja_in_file: llvm_ninja.unwrap_or(true),
299 nodejs: build_nodejs.map(PathBuf::from),
300 omit_git_hash,
301diff --git a/src/bootstrap/src/core/config/target_selection.rs b/src/bootstrap/src/core/config/target_selection.rs
302index 47f6d6f38..a519b6655 100644
303--- a/src/bootstrap/src/core/config/target_selection.rs
304+++ b/src/bootstrap/src/core/config/target_selection.rs
305@@ -104,10 +104,6 @@ impl TargetSelection {
306 env::var("OSTYPE").is_ok_and(|v| v.to_lowercase().contains("cygwin"))
307 }
308
309- pub fn needs_crt_begin_end(&self) -> bool {
310- self.contains("musl") && !self.contains("unikraft")
311- }
312-
313 /// Path to the file defining the custom target, if any.
314 pub fn filepath(&self) -> Option<&Path> {
315 self.file.as_ref().map(Path::new)
316diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs
317index 48042ba56..083970f1b 100644
318--- a/src/bootstrap/src/core/config/toml/rust.rs
319+++ b/src/bootstrap/src/core/config/toml/rust.rs
320@@ -38,7 +38,6 @@ define_config! {
321 incremental: Option<bool> = "incremental",
322 default_linker: Option<String> = "default-linker",
323 channel: Option<String> = "channel",
324- musl_root: Option<String> = "musl-root",
325 rpath: Option<bool> = "rpath",
326 rustflags: Option<Vec<String>> = "rustflags",
327 strip: Option<bool> = "strip",
328@@ -368,7 +367,6 @@ pub fn check_incompatible_options_for_ci_rustc(
329 debuginfo_level_tools: _,
330 debuginfo_level_tests: _,
331 backtrace: _,
332- musl_root: _,
333 verbose_tests: _,
334 optimize_tests: _,
335 codegen_tests: _,
336diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs
337index 847b75e69..5ad42917a 100644
338--- a/src/bootstrap/src/core/config/toml/target.rs
339+++ b/src/bootstrap/src/core/config/toml/target.rs
340@@ -41,8 +41,6 @@ define_config! {
341 rpath: Option<bool> = "rpath",
342 rustflags: Option<Vec<String>> = "rustflags",
343 crt_static: Option<bool> = "crt-static",
344- musl_root: Option<String> = "musl-root",
345- musl_libdir: Option<String> = "musl-libdir",
346 wasi_root: Option<String> = "wasi-root",
347 qemu_rootfs: Option<String> = "qemu-rootfs",
348 no_std: Option<bool> = "no-std",
349@@ -77,8 +75,6 @@ pub struct Target {
350 pub rpath: Option<bool>,
351 pub rustflags: Vec<String>,
352 pub crt_static: Option<bool>,
353- pub musl_root: Option<PathBuf>,
354- pub musl_libdir: Option<PathBuf>,
355 pub wasi_root: Option<PathBuf>,
356 pub qemu_rootfs: Option<PathBuf>,
357 pub runner: Option<String>,
358diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs
359index 67f4eb37b..6f2cf48b0 100644
360--- a/src/bootstrap/src/core/sanity.rs
361+++ b/src/bootstrap/src/core/sanity.rs
362@@ -350,22 +350,6 @@ than building it.
363 continue;
364 }
365
366- // Make sure musl-root is valid.
367- if target.contains("musl") && !target.contains("unikraft") {
368- match build.musl_libdir(*target) {
369- Some(libdir) => {
370- if fs::metadata(libdir.join("libc.a")).is_err() {
371- panic!("couldn't find libc.a in musl libdir: {}", libdir.display());
372- }
373- }
374- None => panic!(
375- "when targeting MUSL either the rust.musl-root \
376- option or the target.$TARGET.musl-root option must \
377- be specified in bootstrap.toml"
378- ),
379- }
380- }
381-
382 if need_cmake && target.is_msvc() {
383 // There are three builds of cmake on windows: MSVC, MinGW, and
384 // Cygwin. The Cygwin build does not have generators for Visual
385diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
386index 857c0539e..ebe12d747 100644
387--- a/src/bootstrap/src/lib.rs
388+++ b/src/bootstrap/src/lib.rs
389@@ -1345,35 +1345,6 @@ impl Build {
390 }
391 }
392
393- /// Returns the "musl root" for this `target`, if defined.
394- ///
395- /// If this is a native target (host is also musl) and no musl-root is given,
396- /// it falls back to the system toolchain in /usr.
397- fn musl_root(&self, target: TargetSelection) -> Option<&Path> {
398- let configured_root = self
399- .config
400- .target_config
401- .get(&target)
402- .and_then(|t| t.musl_root.as_ref())
403- .or(self.config.musl_root.as_ref())
404- .map(|p| &**p);
405-
406- if self.config.is_host_target(target) && configured_root.is_none() {
407- Some(Path::new("/usr"))
408- } else {
409- configured_root
410- }
411- }
412-
413- /// Returns the "musl libdir" for this `target`.
414- fn musl_libdir(&self, target: TargetSelection) -> Option<PathBuf> {
415- self.config
416- .target_config
417- .get(&target)
418- .and_then(|t| t.musl_libdir.clone())
419- .or_else(|| self.musl_root(target).map(|root| root.join("lib")))
420- }
421-
422 /// Returns the `lib` directory for the WASI target specified, if
423 /// configured.
424 ///
425diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs
426index 0662ae304..f6373f44e 100644
427--- a/src/bootstrap/src/utils/cc_detect.rs
428+++ b/src/bootstrap/src/utils/cc_detect.rs
429@@ -205,30 +205,6 @@ fn default_compiler(
430 }
431 }
432
433- "mips-unknown-linux-musl" if compiler == Language::C => {
434- if cfg.get_compiler().path().to_str() == Some("gcc") {
435- Some(PathBuf::from("mips-linux-musl-gcc"))
436- } else {
437- None
438- }
439- }
440- "mipsel-unknown-linux-musl" if compiler == Language::C => {
441- if cfg.get_compiler().path().to_str() == Some("gcc") {
442- Some(PathBuf::from("mipsel-linux-musl-gcc"))
443- } else {
444- None
445- }
446- }
447-
448- t if t.contains("musl") && compiler == Language::C => {
449- if let Some(root) = build.musl_root(target) {
450- let guess = root.join("bin/musl-gcc");
451- if guess.exists() { Some(guess) } else { None }
452- } else {
453- None
454- }
455- }
456-
457 t if t.contains("-wasi") => {
458 let root = if let Some(path) = build.wasi_sdk_path.as_ref() {
459 path
460--
4612.52.0
462