diff --git a/src/lib.rs b/src/lib.rs index e9638286..2a7e3a11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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()); diff --git a/tests/test.rs b/tests/test.rs index 5f31f3eb..9d5ce508 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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();