When we're building PIC we don't need the large code model. Try small.

Only mangle darwin to linux when PIC is disabled (the reason we do it is to avoid LLVM forcably enabling PIC for us).
This commit is contained in:
Nick Lewycky
2020-08-07 18:13:56 -07:00
parent 8daeff8bc8
commit 45dcee1282

View File

@@ -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(),