rust/0001-bootstrap-allow-disabling-target-self-contained.patch
Josh Stone 58707b2b7d Update to Rust 1.86.0
Resolves: RHEL-81600
Resolves: RHEL-81606
2025-04-08 13:26:56 -07:00

103 lines
4.0 KiB
Diff

From c3307f4e1826cabd8e7e4a54636b0e79afb97835 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 28 Sep 2023 18:14:28 -0700
Subject: [PATCH 1/2] bootstrap: allow disabling target self-contained
---
config.example.toml | 5 +++++
src/bootstrap/src/core/build_steps/compile.rs | 4 ++++
src/bootstrap/src/core/config/config.rs | 8 ++++++++
src/bootstrap/src/lib.rs | 5 +++++
4 files changed, 22 insertions(+)
diff --git a/config.example.toml b/config.example.toml
index f5395375afe4..a96368ae4ef2 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -927,6 +927,11 @@
# order to run `x check`.
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool)
+# Copy libc and CRT objects into the target lib/self-contained/ directory.
+# Enabled by default on `musl`, `wasi`, and `windows-gnu` targets. Other
+# targets may ignore this setting if they have nothing to be contained.
+#self-contained = <platform-specific> (bool)
+
# =============================================================================
# Distribution options
#
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 479327d63695..97d2bf2df8bb 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -327,6 +327,10 @@ fn copy_self_contained_objects(
compiler: &Compiler,
target: TargetSelection,
) -> Vec<(PathBuf, DependencyType)> {
+ if builder.self_contained(target) != Some(true) {
+ return vec![];
+ }
+
let libdir_self_contained =
builder.sysroot_target_libdir(*compiler, target).join("self-contained");
t!(fs::create_dir_all(&libdir_self_contained));
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 65f286a05bd5..dc4d6f741bcf 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -643,6 +643,7 @@ pub struct Target {
pub no_std: bool,
pub codegen_backends: Option<Vec<String>>,
pub optimized_compiler_builtins: Option<bool>,
+ pub self_contained: bool,
}
impl Target {
@@ -654,6 +655,9 @@ pub fn from_triple(triple: &str) -> Self {
if triple.contains("emscripten") {
target.runner = Some("node".into());
}
+ if triple.contains("-musl") || triple.contains("-wasi") || triple.contains("-windows-gnu") {
+ target.self_contained = true;
+ }
target
}
}
@@ -1234,6 +1238,7 @@ struct TomlTarget {
codegen_backends: Option<Vec<String>> = "codegen-backends",
runner: Option<String> = "runner",
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
+ self_contained: Option<bool> = "self-contained",
}
}
@@ -2146,6 +2151,9 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
if let Some(s) = cfg.no_std {
target.no_std = s;
}
+ if let Some(s) = cfg.self_contained {
+ target.self_contained = s;
+ }
target.cc = cfg.cc.map(PathBuf::from);
target.cxx = cfg.cxx.map(PathBuf::from);
target.ar = cfg.ar.map(PathBuf::from);
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 21b02a3b541a..6b98c67457e8 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -1366,6 +1366,11 @@ fn no_std(&self, target: TargetSelection) -> Option<bool> {
self.config.target_config.get(&target).map(|t| t.no_std)
}
+ /// Returns `true` if this is a self-contained `target`, if defined
+ fn self_contained(&self, target: TargetSelection) -> Option<bool> {
+ self.config.target_config.get(&target).map(|t| t.self_contained)
+ }
+
/// Returns `true` if the target will be tested using the `remote-test-client`
/// and `remote-test-server` binaries.
fn remote_tested(&self, target: TargetSelection) -> bool {
--
2.48.1