mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-06-07 21:04:46 +02:00
Enable support for compiling for UEFI targets. This includes compiling binaries such as bootloaders, stubs for EFI bundles and similar utilities. Specifically, I used this functionality to finish work a minimal EFI stub, candyboot: https://git.sr.ht/~whynothugo/candyboot The UEFI target is only supported by LLVM. GCC cannot produce native EFI binaries. When compiling for a UEFI target, GCC produces ELF binaries and uses GNU-EFI as a stub loader to run them inside EFI environments. This approach does not work when compiling Rust. The profiler_builtins crate fails to build for the UEFI target; it is a C component which requires a UEFI specific sysroot to compile. During coordination with upstream, it came up these compiler built-ins could not be disabled on a per-target basis. This is now implemented upstream, and available in Rust stable since 1.86.0. See: https://github.com/rust-lang/rust/pull/135326/
24 lines
1.3 KiB
Diff
24 lines
1.3 KiB
Diff
diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs
|
|
index 9656024ddaa..787db13e382 100644
|
|
--- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs
|
|
+++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs
|
|
@@ -10,6 +10,7 @@ pub(crate) fn target() -> Target {
|
|
base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/machine:arm64"]);
|
|
base.features = "+v8a".into();
|
|
|
|
+ base.linker = Some("lld".into());
|
|
Target {
|
|
llvm_target: "aarch64-unknown-windows".into(),
|
|
metadata: crate::spec::TargetMetadata {
|
|
diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs
|
|
index a11a79ff41a..d4900fbf536 100644
|
|
--- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs
|
|
+++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs
|
|
@@ -27,6 +27,7 @@ pub(crate) fn target() -> Target {
|
|
// arguments, thus giving you access to full MMX/SSE acceleration.
|
|
base.features = "-mmx,-sse,+soft-float".into();
|
|
|
|
+ base.linker = Some("lld".into());
|
|
Target {
|
|
llvm_target: "x86_64-unknown-windows".into(),
|
|
metadata: crate::spec::TargetMetadata {
|