rust/0001-bootstrap-allow-disabling-target-self-contained.patch
Josh Stone d20ad927ef Update to Rust 1.89.0
Resolves: RHEL-111847
Resolves: RHEL-111867
2025-09-10 16:19:35 -07:00

103 lines
4.1 KiB
Diff

From 6af71d8ff0932bc14102cd9cbfbca16354c5cd2a Mon Sep 17 00:00:00 2001
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
Date: Mon, 7 Apr 2025 16:59:10 +0200
Subject: [PATCH 1/2] bootstrap: allow disabling target self-contained
---
bootstrap.example.toml | 5 +++++
src/bootstrap/src/core/build_steps/compile.rs | 4 ++++
src/bootstrap/src/core/config/toml/target.rs | 8 ++++++++
src/bootstrap/src/lib.rs | 5 +++++
4 files changed, 22 insertions(+)
diff --git a/bootstrap.example.toml b/bootstrap.example.toml
index 19cf360b0fb..916bae8dc7d 100644
--- a/bootstrap.example.toml
+++ b/bootstrap.example.toml
@@ -974,6 +974,11 @@
# This overrides the global `rust.jemalloc` option. See that option for more info.
#jemalloc = rust.jemalloc (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 f6efb23e8d8..4d0ae54e1ef 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -374,6 +374,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/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs
index b9f6780ca3f..41a4a815d31 100644
--- a/src/bootstrap/src/core/config/toml/target.rs
+++ b/src/bootstrap/src/core/config/toml/target.rs
@@ -47,6 +47,7 @@ struct TomlTarget {
runner: Option<String> = "runner",
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
jemalloc: Option<bool> = "jemalloc",
+ self_contained: Option<bool> = "self-contained",
}
}
@@ -79,6 +80,7 @@ pub struct Target {
pub codegen_backends: Option<Vec<String>>,
pub optimized_compiler_builtins: Option<bool>,
pub jemalloc: Option<bool>,
+ pub self_contained: bool,
}
impl Target {
@@ -90,6 +92,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
}
}
@@ -126,6 +131,9 @@ pub fn apply_target_config(&mut self, toml_target: Option<HashMap<String, TomlTa
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 f44fe4548a1..8ce9f09efb1 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -1331,6 +1331,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.49.0