summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/bin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/bootstrap/bin
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/bootstrap/bin')
-rw-r--r--src/bootstrap/bin/llvm-config-wrapper.rs24
-rw-r--r--src/bootstrap/bin/rustc.rs35
2 files changed, 35 insertions, 24 deletions
diff --git a/src/bootstrap/bin/llvm-config-wrapper.rs b/src/bootstrap/bin/llvm-config-wrapper.rs
deleted file mode 100644
index 89984bb55..000000000
--- a/src/bootstrap/bin/llvm-config-wrapper.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// The sheer existence of this file is an awful hack. See the comments in
-// `src/bootstrap/native.rs` for why this is needed when compiling LLD.
-
-use std::env;
-use std::io::{self, Write};
-use std::process::{self, Command, Stdio};
-
-fn main() {
- let real_llvm_config = env::var_os("LLVM_CONFIG_REAL").unwrap();
- let mut cmd = Command::new(real_llvm_config);
- cmd.args(env::args().skip(1)).stderr(Stdio::piped());
- let output = cmd.output().expect("failed to spawn llvm-config");
- let mut stdout = String::from_utf8_lossy(&output.stdout);
-
- if let Ok(to_replace) = env::var("LLVM_CONFIG_SHIM_REPLACE") {
- if let Ok(replace_with) = env::var("LLVM_CONFIG_SHIM_REPLACE_WITH") {
- stdout = stdout.replace(&to_replace, &replace_with).into();
- }
- }
-
- print!("{}", stdout.replace("\\", "/"));
- io::stdout().flush().unwrap();
- process::exit(output.status.code().unwrap_or(1));
-}
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 1d5260228..9611c866d 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -154,6 +154,41 @@ fn main() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}
+ // allow-features is handled from within this rustc wrapper because of
+ // issues with build scripts. Some packages use build scripts to
+ // dynamically detect if certain nightly features are available.
+ // There are different ways this causes problems:
+ //
+ // * rustix runs `rustc` on a small test program to see if the feature is
+ // available (and sets a `cfg` if it is). It does not honor
+ // CARGO_ENCODED_RUSTFLAGS.
+ // * proc-macro2 detects if `rustc -vV` says "nighty" or "dev" and enables
+ // nightly features. It will scan CARGO_ENCODED_RUSTFLAGS for
+ // -Zallow-features. Unfortunately CARGO_ENCODED_RUSTFLAGS is not set
+ // for build-dependencies when --target is used.
+ //
+ // The issues above means we can't just use RUSTFLAGS, and we can't use
+ // `cargo -Zallow-features=…`. Passing it through here ensures that it
+ // always gets set. Unfortunately that also means we need to enable more
+ // features than we really want (like those for proc-macro2), but there
+ // isn't much of a way around it.
+ //
+ // I think it is unfortunate that build scripts are doing this at all,
+ // since changes to nightly features can cause crates to break even if the
+ // user didn't want or care about the use of the nightly features. I think
+ // nightly features should be opt-in only. Unfortunately the dynamic
+ // checks are now too wide spread that we just need to deal with it.
+ //
+ // If you want to try to remove this, I suggest working with the crate
+ // authors to remove the dynamic checking. Another option is to pursue
+ // https://github.com/rust-lang/cargo/issues/11244 and
+ // https://github.com/rust-lang/cargo/issues/4423, which will likely be
+ // very difficult, but could help expose -Zallow-features into build
+ // scripts so they could try to honor them.
+ if let Ok(allow_features) = env::var("RUSTC_ALLOW_FEATURES") {
+ cmd.arg(format!("-Zallow-features={allow_features}"));
+ }
+
if let Ok(flags) = env::var("MAGIC_EXTRA_RUSTFLAGS") {
for flag in flags.split(' ') {
cmd.arg(flag);