diff --git a/src/lib.rs b/src/lib.rs index b64bff58a..14d8f0182 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 14e72ec46..62976d6d8 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();