Skip to content

Commit

Permalink
Don't pass -fPIC by default on wasm (#1245)
Browse files Browse the repository at this point in the history
* Don't pass -fPIC by default on wasm

Fix #1240

* Fix cargo fmt
  • Loading branch information
NobodyXu authored Oct 11, 2024
1 parent 53a0b97 commit d0048ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d0048ab

Please sign in to comment.