rust rebuild

This commit is contained in:
Rmys
2025-11-15 16:09:20 +03:00
parent ea848787a3
commit 30dd66d16d
11 changed files with 135 additions and 247 deletions
@@ -1,74 +0,0 @@
From 2bf05f208272cd58c57f4d7d8d0e10fdb22e8719 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 27 Sep 2019 12:33:08 -0700
Subject: [PATCH] [WIP] minimize the rust-std component
---
src/bootstrap/dist.rs | 45 +++++++++++++++----------------------------
1 file changed, 16 insertions(+), 29 deletions(-)
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 552965863d10..76fbd07f9fb5 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -667,41 +667,28 @@ impl Step for Std {
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
}
- // We want to package up as many target libraries as possible
- // for the `rust-std` package, so if this is a host target we
- // depend on librustc and otherwise we just depend on libtest.
- if builder.hosts.iter().any(|t| t == target) {
- builder.ensure(compile::Rustc { compiler, target });
- } else {
- if builder.no_std(target) == Some(true) {
- // the `test` doesn't compile for no-std targets
- builder.ensure(compile::Std { compiler, target });
- } else {
- builder.ensure(compile::Test { compiler, target });
- }
- }
+ builder.ensure(compile::Std { compiler, target });
+ builder.ensure(compile::Test { compiler, target });
let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
let _ = fs::remove_dir_all(&image);
- let dst = image.join("lib/rustlib").join(target);
+ let dst = image.join("lib/rustlib").join(target).join("lib");
t!(fs::create_dir_all(&dst));
- let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
- src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
- builder.cp_filtered(&src, &dst, &|path| {
- if let Some(name) = path.file_name().and_then(|s| s.to_str()) {
- if name == builder.config.rust_codegen_backends_dir.as_str() {
- return false
- }
- if name == "bin" {
- return false
- }
- if name.contains("LLVM") {
- return false
- }
+
+ let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
+ let stamp = dbg!(compile::libstd_stamp(builder, compiler_to_use, target));
+ for (path, host) in builder.read_stamp_file(&stamp) {
+ if !host {
+ builder.copy(&path, &dst.join(path.file_name().unwrap()));
}
- true
- });
+ }
+ let stamp = dbg!(compile::libtest_stamp(builder, compiler_to_use, target));
+ for (path, host) in builder.read_stamp_file(&stamp) {
+ if !host {
+ builder.copy(&path, &dst.join(path.file_name().unwrap()));
+ }
+ }
let mut cmd = rust_installer(builder);
cmd.arg("generate")
--
2.21.0
@@ -1,41 +0,0 @@
From 1f68002cb725c6a8fb5ca8425c1c86495a053f4f Mon Sep 17 00:00:00 2001
From: Michal Gorny <mgorny@gentoo.org>
Date: Thu, 4 Apr 2019 14:21:38 +0000
Subject: [PATCH] [llvm] [cmake] Add additional headers only if they exist
Modify the add_header_files_for_glob() function to only add files
that do exist, rather than all matches of the glob. This fixes CMake
error when one of the include directories (which happen to include
/usr/include) contain broken symlinks.
Differential Revision: https://reviews.llvm.org/D59632
llvm-svn: 357701
---
llvm/cmake/modules/LLVMProcessSources.cmake | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake
index 7cbd2863500..d0be0e8b3ba 100644
--- a/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
+++ b/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
@@ -30,7 +30,15 @@ endmacro(add_td_sources)
function(add_header_files_for_glob hdrs_out glob)
file(GLOB hds ${glob})
- set(${hdrs_out} ${hds} PARENT_SCOPE)
+ set(filtered)
+ foreach(file ${hds})
+ # Explicit existence check is necessary to filter dangling symlinks
+ # out. See https://bugs.gentoo.org/674662.
+ if(EXISTS ${file})
+ list(APPEND filtered ${file})
+ endif()
+ endforeach()
+ set(${hdrs_out} ${filtered} PARENT_SCOPE)
endfunction(add_header_files_for_glob)
function(find_all_header_files hdrs_out additional_headerdirs)
--
2.21.0
@@ -1,26 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Thu, 13 Jul 2023 21:16:53 +0200
Subject: [PATCH] bootstrap: Change bash-completion dir
---
src/bootstrap/dist.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 78a5faeae04b..4f4e4e508619 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -1079,7 +1079,11 @@ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
tarball.add_file(&cargo, "bin", 0o755);
tarball.add_file(etc.join("_cargo"), "share/zsh/site-functions", 0o644);
- tarball.add_renamed_file(etc.join("cargo.bashcomp.sh"), "etc/bash_completion.d", "cargo");
+ tarball.add_renamed_file(
+ etc.join("cargo.bashcomp.sh"),
+ "share/bash-completion/completions",
+ "cargo",
+ );
tarball.add_dir(etc.join("man"), "share/man/man1");
tarball.add_legal_and_readme_to("share/doc/cargo");
@@ -1,34 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Fri, 19 Sep 2025 17:42:45 +0200
Subject: [PATCH] bootstrap: Workaround for 1.90.0 stage0
See: https://github.com/rust-lang/rust/issues/143765
---
src/bootstrap/src/utils/helpers.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs
index eb00ed566c2d..86b3358a22b7 100644
--- a/src/bootstrap/src/utils/helpers.rs
+++ b/src/bootstrap/src/utils/helpers.rs
@@ -430,17 +430,17 @@ pub fn linker_flags(
// cfg(bootstrap) - remove the stage 0 check after updating the bootstrap compiler:
// `-Clinker-features` has been stabilized.
if stage == 0 {
- args.push("-Zlinker-features=+lld".to_string());
+ args.push("-Clinker-features=+lld".to_string());
} else {
args.push("-Clinker-features=+lld".to_string());
}
args.push("-Zunstable-options".to_string());
}
LldMode::SelfContained => {
// cfg(bootstrap) - remove the stage 0 check after updating the bootstrap compiler:
// `-Clinker-features` has been stabilized.
if stage == 0 {
- args.push("-Zlinker-features=+lld".to_string());
+ args.push("-Clinker-features=+lld".to_string());
} else {
args.push("-Clinker-features=+lld".to_string());
}
@@ -1,54 +0,0 @@
From a94fa896cc92d5e0678376cf5aa8b64af0899732 Mon Sep 17 00:00:00 2001
From: Nikita Popov <nikita.ppv@gmail.com>
Date: Tue, 4 Feb 2020 20:35:50 +0100
Subject: [PATCH 4/5] Fix timeTraceProfilerInitialize for LLVM 10
---
src/rustllvm/PassWrapper.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 90d24d20737db..9e8614e3b6d34 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -67,7 +67,11 @@ extern "C" void LLVMInitializePasses() {
}
extern "C" void LLVMTimeTraceProfilerInitialize() {
-#if LLVM_VERSION_GE(9, 0)
+#if LLVM_VERSION_GE(10, 0)
+ timeTraceProfilerInitialize(
+ /* TimeTraceGranularity */ 0,
+ /* ProcName */ "rustc");
+#elif LLVM_VERSION_GE(9, 0)
timeTraceProfilerInitialize();
#endif
}
From 497f879b1e24c369362bcd821959ffabc50a8a31 Mon Sep 17 00:00:00 2001
From: Nikita Popov <nikita.ppv@gmail.com>
Date: Mon, 2 Mar 2020 22:37:55 +0100
Subject: [PATCH 5/5] Update CreateMemSet() usage for LLVM 10
---
src/rustllvm/RustWrapper.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 25cfee3373dc4..799adb418822d 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -1333,8 +1333,13 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B,
LLVMValueRef Dst, unsigned DstAlign,
LLVMValueRef Val,
LLVMValueRef Size, bool IsVolatile) {
+#if LLVM_VERSION_GE(10, 0)
+ return wrap(unwrap(B)->CreateMemSet(
+ unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile));
+#else
return wrap(unwrap(B)->CreateMemSet(
unwrap(Dst), unwrap(Val), unwrap(Size), DstAlign, IsVolatile));
+#endif
}
extern "C" LLVMValueRef
@@ -9,10 +9,10 @@ See: https://github.com/rust-lang/rust/issues/143735
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 30cbcc05c429..0b5f1b55a43e 100644
index 82fd1119c7fe..0e1e2a2d39fd 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -796,7 +796,10 @@ fn run(self, builder: &Builder<'_>) {
@@ -794,7 +794,10 @@ fn run(self, builder: &Builder<'_>) {
let _ = fs::remove_dir_all(sysroot.join("lib/rustlib/src/rust"));
}
@@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Fri, 12 Mar 2021 17:31:56 +0100
Subject: [PATCH] compiler: Change LLVM targets
- Change x86_64-unknown-linux-gnu to use x86_64-pc-linux-gnu
- Change i686-unknown-linux-gnu to use i686-pc-linux-gnu
Reintroduce the aliasing that was removed in 1.52.0 and alias the -pc-
triples to the -unknown- triples. This avoids defining proper -pc-
targets, as things break when this is done:
- The crate ecosystem expects the -unknown- targets. Making -pc-
rustc's host triple (and thus default target) would break various
crates.
- Firefox's build breaks when the host triple (from
`rustc --version --verbose`) is different from the target triple
(from `rustc --print target-list`) that best matches autoconf.
---
compiler/rustc_session/src/config.rs | 6 ++++++
.../rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs | 2 +-
.../src/spec/targets/x86_64_unknown_linux_gnu.rs | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index 5e47559847e0..bd7965540560 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -2374,6 +2374,12 @@ pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches
early_dcx.early_fatal(format!("target file {path:?} does not exist"))
})
}
+ Some(target) if &target == "x86_64-pc-linux-gnu" => {
+ TargetTuple::from_tuple("x86_64-unknown-linux-gnu")
+ }
+ Some(target) if &target == "i686-pc-linux-gnu" => {
+ TargetTuple::from_tuple("i686-unknown-linux-gnu")
+ }
Some(target) => TargetTuple::TargetTuple(target),
_ => TargetTuple::from_tuple(host_tuple()),
}
diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs
index c70c026f9f71..5ffa2eb8eddb 100644
--- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs
@@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
base.stack_probes = StackProbeType::Inline;
Target {
- llvm_target: "i686-unknown-linux-gnu".into(),
+ llvm_target: "i686-pc-linux-gnu".into(),
metadata: TargetMetadata {
description: Some("32-bit Linux (kernel 3.2, glibc 2.17+)".into()),
tier: Some(1),
diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs
index 0c8353fad182..d2b414766d4d 100644
--- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs
@@ -28,7 +28,7 @@ pub(crate) fn target() -> Target {
}
Target {
- llvm_target: "x86_64-unknown-linux-gnu".into(),
+ llvm_target: "x86_64-pc-linux-gnu".into(),
metadata: TargetMetadata {
description: Some("64-bit Linux (kernel 3.2+, glibc 2.17+)".into()),
tier: Some(1),
@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Fri, 19 Sep 2025 17:11:42 +0200
Subject: [PATCH] compiler: Use ld.lld by default
Change the default linker flavor to use LLD. This avoids the self-
contained rust-lld, which can only be built when also building LLVM.
See: https://gitlab.archlinux.org/archlinux/packaging/packages/rust/-/issues/8
---
compiler/rustc_target/src/spec/mod.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 07fb1ce63f7c..fd5f0606e474 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -2472,7 +2472,7 @@ fn default() -> TargetOptions {
abi: "".into(),
vendor: "unknown".into(),
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()),
- linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::Yes),
linker_flavor_json: LinkerFlavorCli::Gcc,
lld_flavor_json: LldFlavor::Ld,
linker_is_gnu_json: true,
@@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Sat, 4 Jan 2025 06:52:13 +0100
Subject: [PATCH] compiler: Use aarch64-linux-gnu-gcc to link aarch64 targets
Otherwise it defaults to 'cc', which is inappropriate as we're
cross-compiling.
---
.../rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs | 1 +
.../rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs | 1 +
2 files changed, 2 insertions(+)
diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs
index 4220d74dfc89..f1aca6f68a17 100644
--- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs
@@ -32,6 +32,7 @@ pub(crate) fn target() -> Target {
| SanitizerSet::THREAD
| SanitizerSet::HWADDRESS,
supports_xray: true,
+ linker: Some("aarch64-linux-gnu-gcc".into()),
..base::linux_gnu::opts()
},
}
diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs
index 478726fbef69..e97bd41abc35 100644
--- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs
@@ -13,6 +13,7 @@ pub(crate) fn target() -> Target {
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::THREAD;
+ base.linker = Some("aarch64-linux-gnu-gcc".into());
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
base.crt_static_default = true;
@@ -1,13 +0,0 @@
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index e54c9360baec..9e4cd5ebca74 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -145,7 +145,7 @@ impl StepDescription {
only_hosts: S::ONLY_HOSTS,
should_run: S::should_run,
make_run: S::make_run,
- name: unsafe { ::std::intrinsics::type_name::<S>() },
+ name: std::any::type_name::<S>(),
}
}
+4 -3
View File
@@ -41,9 +41,10 @@
<Dependency>llvm-clang-devel</Dependency>
</BuildDependencies>
<Patches>
<!-- <Patch level="1">0008-bootstrap-Workaround-for-system-stage0.patch</Patch> -->
<!-- <Patch level="1">0009-bootstrap-Workaround-for-1.90.0-stage0.patch</Patch> -->
<!--<Patch level="1">0002-bootstrap-Change-bash-completion-dir.patch</Patch> -->
<Patch level="1">arch/0003-bootstrap-Workaround-for-system-stage0.patch</Patch>
<Patch level="1">arch/0004-compiler-Change-LLVM-targets.patch</Patch>
<Patch level="1">arch/0005-compiler-Use-ld.lld-by-default.patch</Patch>
<Patch level="1">arch/0006-compiler-Use-aarch64-linux-gnu-gcc-to-link-aarch64-t.patch</Patch>
</Patches>
</Source>