about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Bishop <nbishop@nbishop.net>2022-09-04 12:42:03 -0400
committerNicholas Bishop <nicholasbishop@google.com>2022-09-09 15:26:19 -0400
commit54d9ba8239f12db556426db19fca4c4a6e9730e8 (patch)
treec8555a6f55fe815a7ce3ae7bfab44031676083f8
parent98f3001eecbe4cbd091c10ffab45b4c164bb507b (diff)
downloadrust-54d9ba8239f12db556426db19fca4c4a6e9730e8.tar.gz
rust-54d9ba8239f12db556426db19fca4c4a6e9730e8.zip
Use RelocModel::Pic for UEFI targets
In https://github.com/rust-lang/rust/pull/100537, the relocation model
for UEFI targets was changed from PIC (the default value) to
static. There was some dicussion of this change here:
https://github.com/rust-lang/rust/pull/100537#discussion_r952363012

It turns out that this can cause compilation to fail as described in
https://github.com/rust-lang/rust/issues/101377, so switch back to PIC.

Fixes https://github.com/rust-lang/rust/issues/101377
-rw-r--r--compiler/rustc_target/src/spec/tests/tests_impl.rs3
-rw-r--r--compiler/rustc_target/src/spec/uefi_msvc_base.rs3
-rw-r--r--src/test/codegen/abi-efiapi.rs2
3 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs
index d03f959076d..0af599916a9 100644
--- a/compiler/rustc_target/src/spec/tests/tests_impl.rs
+++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs
@@ -146,7 +146,8 @@ impl Target {
         if self.position_independent_executables && !triple.ends_with("-linuxkernel") {
             assert_eq!(self.relocation_model, RelocModel::Pic);
         }
-        if self.relocation_model == RelocModel::Pic {
+        // The UEFI targets do not support dynamic linking but still require PIC (#101377).
+        if self.relocation_model == RelocModel::Pic && self.os != "uefi" {
             assert!(self.dynamic_linking || self.position_independent_executables);
         }
         if self.static_position_independent_executables {
diff --git a/compiler/rustc_target/src/spec/uefi_msvc_base.rs b/compiler/rustc_target/src/spec/uefi_msvc_base.rs
index 250da03cbd2..99af7d85e1d 100644
--- a/compiler/rustc_target/src/spec/uefi_msvc_base.rs
+++ b/compiler/rustc_target/src/spec/uefi_msvc_base.rs
@@ -10,7 +10,7 @@
 // code runs in the same environment, no process separation is supported.
 
 use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy};
-use crate::spec::{RelocModel, StackProbeType, TargetOptions};
+use crate::spec::{StackProbeType, TargetOptions};
 
 pub fn opts() -> TargetOptions {
     let mut base = super::msvc_base::opts();
@@ -47,7 +47,6 @@ pub fn opts() -> TargetOptions {
         stack_probes: StackProbeType::Call,
         singlethread: true,
         linker: Some("rust-lld".into()),
-        relocation_model: RelocModel::Static,
         ..base
     }
 }
diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs
index 4dc9d183b0b..b4fda5f8c84 100644
--- a/src/test/codegen/abi-efiapi.rs
+++ b/src/test/codegen/abi-efiapi.rs
@@ -24,7 +24,7 @@ trait Freeze { }
 #[lang="copy"]
 trait Copy { }
 
-//x86_64: define dso_local win64cc void @has_efiapi
+//x86_64: define win64cc void @has_efiapi
 //i686: define void @has_efiapi
 //aarch64: define dso_local void @has_efiapi
 //arm: define dso_local void @has_efiapi