From c1f07fcc2c17bfc041982476aed9cf02987ef580 Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:03:13 +1100 Subject: [PATCH] Don't pass -fPIC by default on wasm Fix #1240 --- src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d69dcc07..2f3fb87c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1996,11 +1996,14 @@ 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( - !target.contains("windows") - && !target.contains("-none-") - && !target.ends_with("-none") - && !target.contains("uefi"), + if self.pic.unwrap_or_else( + || { + !target.contains("windows") + && !target.contains("-none-") + && !target.ends_with("-none") + && !target.contains("uefi") + && !Build::is_wasi_target(target) + } ) { cmd.push_cc_arg("-fPIC".into()); // PLT only applies if code is compiled with PIC support,