From ecea93eaf03b27d7f1b876a46d8268ce81331e6f Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 3 Nov 2024 20:41:51 -0500 Subject: [PATCH] Do not add -fPIC by default on UEFI targets (#1263) This fixes a regression caused by 290a6293c5e061a8a1d91a6521ff4ffc66d93a2a. --- src/lib.rs | 2 +- tests/test.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b64bff58..14d8f018 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1997,7 +1997,7 @@ impl Build { if self.pic.unwrap_or( target.os != "windows" && target.os != "none" - && target.env != "uefi" + && target.os != "uefi" && target.os != "wasi", ) { cmd.push_cc_arg("-fPIC".into()); diff --git a/tests/test.rs b/tests/test.rs index 14e72ec4..62976d6d 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -283,6 +283,23 @@ fn gnu_aarch64_none_no_pic() { } } +#[test] +fn gnu_uefi_no_pic() { + reset_env(); + + for arch in &["aarch64", "i686", "x86_64"] { + let target = format!("{}-unknown-uefi", arch); + let test = Test::gnu(); + test.gcc() + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_not_have("-fPIC"); + } +} + #[test] fn gnu_set_stdlib() { reset_env();