Skip to content

Commit

Permalink
Do not add -fPIC by default on UEFI targets (#1263)
Browse files Browse the repository at this point in the history
This fixes a regression caused by 290a629.
  • Loading branch information
nicholasbishop authored Nov 4, 2024
1 parent 140f595 commit ecea93e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
17 changes: 17 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ecea93e

Please sign in to comment.