diff --git a/lib/compiler-llvm/src/config.rs b/lib/compiler-llvm/src/config.rs index 3c6803a02..10c022ca4 100644 --- a/lib/compiler-llvm/src/config.rs +++ b/lib/compiler-llvm/src/config.rs @@ -95,7 +95,11 @@ impl LLVM { } fn code_model(&self) -> CodeModel { - CodeModel::Large + if self.is_pic { + CodeModel::Small + } else { + CodeModel::Large + } } fn target_triple(&self, target: &Target) -> TargetTriple { @@ -106,18 +110,20 @@ impl LLVM { } else { target_lexicon::BinaryFormat::Elf }; - let operating_system = - if target.triple().operating_system == wasmer_compiler::OperatingSystem::Darwin { - // LLVM detects static relocation + darwin + 64-bit and - // force-enables PIC because MachO doesn't support that - // combination. They don't check whether they're targeting - // MachO, they check whether the OS is set to Darwin. - // - // Since both linux and darwin use SysV ABI, this should work. - wasmer_compiler::OperatingSystem::Linux - } else { - target.triple().operating_system - }; + let operating_system = if target.triple().operating_system + == wasmer_compiler::OperatingSystem::Darwin + && !self.is_pic + { + // LLVM detects static relocation + darwin + 64-bit and + // force-enables PIC because MachO doesn't support that + // combination. They don't check whether they're targeting + // MachO, they check whether the OS is set to Darwin. + // + // Since both linux and darwin use SysV ABI, this should work. + wasmer_compiler::OperatingSystem::Linux + } else { + target.triple().operating_system + }; let triple = Triple { architecture: target.triple().architecture, vendor: target.triple().vendor.clone(),