2024-09-05 17:25:31 +00:00
|
|
|
From 937b23ef51b1d2f3d12adc9bd90dfd27936326dd Mon Sep 17 00:00:00 2001
|
2023-09-29 21:56:44 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
---
|
2023-12-31 19:00:36 +00:00
|
|
|
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 +++++
|
2023-09-29 21:56:44 +00:00
|
|
|
4 files changed, 22 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/config.example.toml b/config.example.toml
|
2024-09-05 17:25:31 +00:00
|
|
|
index 26687bcfb370..381a23f9cead 100644
|
2023-09-29 21:56:44 +00:00
|
|
|
--- a/config.example.toml
|
|
|
|
+++ b/config.example.toml
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -872,6 +872,11 @@
|
2024-05-02 17:01:52 +00:00
|
|
|
# argument as the test binary.
|
|
|
|
#runner = <none> (string)
|
2023-09-29 21:56:44 +00:00
|
|
|
|
|
|
|
+# 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
|
|
|
|
#
|
2023-12-31 19:00:36 +00:00
|
|
|
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
|
2024-09-05 17:25:31 +00:00
|
|
|
index 3e79acad1c4b..525b6e956405 100644
|
2023-12-31 19:00:36 +00:00
|
|
|
--- a/src/bootstrap/src/core/build_steps/compile.rs
|
|
|
|
+++ b/src/bootstrap/src/core/build_steps/compile.rs
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -357,6 +357,10 @@ fn copy_self_contained_objects(
|
2023-09-29 21:56:44 +00:00
|
|
|
compiler: &Compiler,
|
|
|
|
target: TargetSelection,
|
|
|
|
) -> Vec<(PathBuf, DependencyType)> {
|
|
|
|
+ if builder.self_contained(target) != Some(true) {
|
|
|
|
+ return vec![];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
let libdir_self_contained = builder.sysroot_libdir(*compiler, target).join("self-contained");
|
|
|
|
t!(fs::create_dir_all(&libdir_self_contained));
|
|
|
|
let mut target_deps = vec![];
|
2023-12-31 19:00:36 +00:00
|
|
|
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
|
2024-09-05 17:25:31 +00:00
|
|
|
index 9d5aa795c6c0..720dc53514d3 100644
|
2023-12-31 19:00:36 +00:00
|
|
|
--- a/src/bootstrap/src/core/config/config.rs
|
|
|
|
+++ b/src/bootstrap/src/core/config/config.rs
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -565,6 +565,7 @@ pub struct Target {
|
2024-05-02 17:01:52 +00:00
|
|
|
pub runner: Option<String>,
|
2023-09-29 21:56:44 +00:00
|
|
|
pub no_std: bool,
|
2024-05-02 17:01:52 +00:00
|
|
|
pub codegen_backends: Option<Vec<String>>,
|
2023-09-29 21:56:44 +00:00
|
|
|
+ pub self_contained: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Target {
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -573,6 +574,9 @@ pub fn from_triple(triple: &str) -> Self {
|
2023-11-16 16:50:29 +00:00
|
|
|
if triple.contains("-none") || triple.contains("nvptx") || triple.contains("switch") {
|
2023-09-29 21:56:44 +00:00
|
|
|
target.no_std = true;
|
|
|
|
}
|
|
|
|
+ if triple.contains("-musl") || triple.contains("-wasi") || triple.contains("-windows-gnu") {
|
|
|
|
+ target.self_contained = true;
|
|
|
|
+ }
|
|
|
|
target
|
|
|
|
}
|
|
|
|
}
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -1140,6 +1144,7 @@ struct TomlTarget {
|
2023-09-29 21:56:44 +00:00
|
|
|
no_std: Option<bool> = "no-std",
|
2024-05-02 17:01:52 +00:00
|
|
|
codegen_backends: Option<Vec<String>> = "codegen-backends",
|
|
|
|
runner: Option<String> = "runner",
|
2023-09-29 21:56:44 +00:00
|
|
|
+ self_contained: Option<bool> = "self-contained",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -1900,6 +1905,9 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
2023-09-29 21:56:44 +00:00
|
|
|
if let Some(s) = cfg.no_std {
|
|
|
|
target.no_std = s;
|
|
|
|
}
|
|
|
|
+ if let Some(s) = cfg.self_contained {
|
|
|
|
+ target.self_contained = s;
|
|
|
|
+ }
|
2023-12-31 19:00:36 +00:00
|
|
|
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
|
2024-09-05 17:25:31 +00:00
|
|
|
index a8555b2c3673..70c41b51eb96 100644
|
2023-12-31 19:00:36 +00:00
|
|
|
--- a/src/bootstrap/src/lib.rs
|
|
|
|
+++ b/src/bootstrap/src/lib.rs
|
2024-09-05 17:25:31 +00:00
|
|
|
@@ -1361,6 +1361,11 @@ fn no_std(&self, target: TargetSelection) -> Option<bool> {
|
2023-09-29 21:56:44 +00:00
|
|
|
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 {
|
|
|
|
--
|
2024-09-05 17:25:31 +00:00
|
|
|
2.46.0
|
2023-09-29 21:56:44 +00:00
|
|
|
|