From d0048ab13679d2b6d60c63906df5246027be7dbd Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:11:19 +1100 Subject: [PATCH] Don't pass -fPIC by default on wasm (#1245) * Don't pass -fPIC by default on wasm Fix #1240 * Fix cargo fmt --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d69dcc07..dee607ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1996,12 +1996,13 @@ impl Build { cmd.push_cc_arg("-fdata-sections".into()); } // Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet - if self.pic.unwrap_or( + if self.pic.unwrap_or_else(|| { !target.contains("windows") && !target.contains("-none-") && !target.ends_with("-none") - && !target.contains("uefi"), - ) { + && !target.contains("uefi") + && !Build::is_wasi_target(target) + }) { cmd.push_cc_arg("-fPIC".into()); // PLT only applies if code is compiled with PIC support, // and only for ELF targets.