Skip to content

Commit

Permalink
disable pic for targets that end in -none (#1212)
Browse files Browse the repository at this point in the history
This fixes #1211
  • Loading branch information
schultetwin1 committed Sep 18, 2024
1 parent 92a5e28 commit 270ec65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,7 @@ impl Build {
if self.pic.unwrap_or(
!target.contains("windows")
&& !target.contains("-none-")
&& !target.ends_with("-none")
&& !target.contains("uefi"),
) {
cmd.push_cc_arg("-fPIC".into());
Expand Down
14 changes: 14 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ fn gnu_x86_64_no_plt() {
test.cmd(0).must_have("-fno-plt");
}

#[test]
fn gnu_aarch64_none_no_pic() {
for target in &["aarch64-unknown-none-gnu", "aarch64-unknown-none"] {
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 270ec65

Please sign in to comment.