Skip to content

Commit 270ec65

Browse files
authored
disable pic for targets that end in -none (#1212)
This fixes #1211
1 parent 92a5e28 commit 270ec65

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,7 @@ impl Build {
19831983
if self.pic.unwrap_or(
19841984
!target.contains("windows")
19851985
&& !target.contains("-none-")
1986+
&& !target.ends_with("-none")
19861987
&& !target.contains("uefi"),
19871988
) {
19881989
cmd.push_cc_arg("-fPIC".into());

tests/test.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,20 @@ fn gnu_x86_64_no_plt() {
269269
test.cmd(0).must_have("-fno-plt");
270270
}
271271

272+
#[test]
273+
fn gnu_aarch64_none_no_pic() {
274+
for target in &["aarch64-unknown-none-gnu", "aarch64-unknown-none"] {
275+
let test = Test::gnu();
276+
test.gcc()
277+
.target(&target)
278+
.host(&target)
279+
.file("foo.c")
280+
.compile("foo");
281+
282+
test.cmd(0).must_not_have("-fPIC");
283+
}
284+
}
285+
272286
#[test]
273287
fn gnu_set_stdlib() {
274288
reset_env();

0 commit comments

Comments
 (0)