initial commit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
--- a/src/bootstrap/src/core/config/config.rs
|
||||
+++ b/src/bootstrap/src/core/config/config.rs
|
||||
@@ -628,7 +628,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
- let bootstrap_override_lld =
|
||||
+ let mut bootstrap_override_lld =
|
||||
rust_bootstrap_override_lld.or(rust_bootstrap_override_lld_legacy).unwrap_or_default();
|
||||
|
||||
if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) {
|
||||
@@ -978,6 +978,20 @@
|
||||
let is_host_system_llvm =
|
||||
is_system_llvm(&target_config, llvm_from_ci, host_target, host_target);
|
||||
|
||||
+ // Self-contained bootstrap LLD comes from the stage0 sysroot (`rust-lld`), whose LLVM
|
||||
+ // version may differ from an externally configured host LLVM. In that case, linking LLVM
|
||||
+ // bitcode objects can fail with "Unknown attribute kind".
|
||||
+ if is_host_system_llvm
|
||||
+ && matches!(bootstrap_override_lld, BootstrapOverrideLld::SelfContained)
|
||||
+ {
|
||||
+ eprintln!(
|
||||
+ "WARNING: `rust.bootstrap-override-lld = \"self-contained\"` with external host \
|
||||
+ `llvm-config` can cause LLVM bitcode version mismatches; falling back to \
|
||||
+ `rust.bootstrap-override-lld = \"external\"` for bootstrap linking."
|
||||
+ );
|
||||
+ bootstrap_override_lld = BootstrapOverrideLld::External;
|
||||
+ }
|
||||
+
|
||||
if llvm_from_ci {
|
||||
let warn = |option: &str| {
|
||||
println!(
|
||||
@@ -1042,21 +1056,27 @@
|
||||
let default_linux_linker_override = match linker_override {
|
||||
DefaultLinuxLinkerOverride::Off => continue,
|
||||
DefaultLinuxLinkerOverride::SelfContainedLldCc => {
|
||||
- // If we automatically default to the self-contained LLD linker,
|
||||
- // we also need to handle the rust.lld option.
|
||||
- match rust_lld_enabled {
|
||||
- // If LLD was not enabled explicitly, we enable it, unless LLVM config has
|
||||
- // been set
|
||||
- None if !is_host_system_llvm => {
|
||||
- lld_enabled = true;
|
||||
- Some(DefaultLinuxLinkerOverride::SelfContainedLldCc)
|
||||
+ // If bootstrap is explicitly using an external `lld` binary, do not also
|
||||
+ // embed a self-contained rust-lld default into rustc's Linux target spec.
|
||||
+ if matches!(bootstrap_override_lld, BootstrapOverrideLld::External) {
|
||||
+ None
|
||||
+ } else {
|
||||
+ // If we automatically default to the self-contained LLD linker,
|
||||
+ // we also need to handle the rust.lld option.
|
||||
+ match rust_lld_enabled {
|
||||
+ // If LLD was not enabled explicitly, we enable it, unless LLVM config has
|
||||
+ // been set
|
||||
+ None if !is_host_system_llvm => {
|
||||
+ lld_enabled = true;
|
||||
+ Some(DefaultLinuxLinkerOverride::SelfContainedLldCc)
|
||||
+ }
|
||||
+ None => None,
|
||||
+ // If it was enabled already, we don't need to do anything
|
||||
+ Some(true) => Some(DefaultLinuxLinkerOverride::SelfContainedLldCc),
|
||||
+ // If it was explicitly disabled, we do not apply the
|
||||
+ // linker override
|
||||
+ Some(false) => None,
|
||||
}
|
||||
- None => None,
|
||||
- // If it was enabled already, we don't need to do anything
|
||||
- Some(true) => Some(DefaultLinuxLinkerOverride::SelfContainedLldCc),
|
||||
- // If it was explicitly disabled, we do not apply the
|
||||
- // linker override
|
||||
- Some(false) => None,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
|
||||
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
|
||||
@@ -23,7 +23,11 @@
|
||||
#include "llvm/MC/TargetRegistry.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
#include "llvm/Passes/PassBuilder.h"
|
||||
+#if LLVM_VERSION_GE(22, 0)
|
||||
+#include "llvm/Plugins/PassPlugin.h"
|
||||
+#else
|
||||
#include "llvm/Passes/PassPlugin.h"
|
||||
+#endif
|
||||
#include "llvm/Passes/StandardInstrumentations.h"
|
||||
#include "llvm/Support/CBindingWrapping.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/compiler/rustc_target/src/spec/base/uefi_msvc.rs
|
||||
+++ b/compiler/rustc_target/src/spec/base/uefi_msvc.rs
|
||||
@@ -45,7 +45,9 @@
|
||||
// "Windows".
|
||||
stack_probes: StackProbeType::Call,
|
||||
singlethread: true,
|
||||
- linker: Some("rust-lld".into()),
|
||||
+ // Use the system LLD frontend name. Distro/toolchain builds that use an external LLVM
|
||||
+ // often do not ship a `rust-lld` wrapper binary.
|
||||
+ linker: Some("lld-link".into()),
|
||||
entry_name: "efi_main".into(),
|
||||
..base
|
||||
}
|
||||
Reference in New Issue
Block a user