Skip to content

Commit

Permalink
Merge pull request #5644 from roc-lang/aarch64-code-model-fix
Browse files Browse the repository at this point in the history
aarch64 linux error fix
  • Loading branch information
rtfeldman authored Jul 11, 2023
2 parents 8b79606 + b92bc49 commit 19fc777
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions crates/compiler/build/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,17 @@ pub fn target_machine(

init_arch(target);

let code_model = match target.architecture {
// LLVM 12 will not compile our programs without a large code model.
// The reason is not totally clear to me, but my guess is a few special-cases in
// llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (instructions)
// llvm/lib/Target/AArch64/AArch64Subtarget.cpp (GoT tables)
// Revisit when upgrading to LLVM 13.
Architecture::Aarch64(..) => CodeModel::Large,
_ => CodeModel::Default,
};
// workaround for issue:
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
let code_model = CodeModel::Large;

#[cfg(not(all(target_arch = "aarch64", target_os = "macos")))]
let code_model = CodeModel::Default;

Target::from_name(arch).unwrap().create_target_machine(
&TargetTriple::create(target_triple_str(target)),
"generic",
"", // TODO: this probably should be TargetMachine::get_host_cpu_features() to enable all features.
"",
opt,
reloc,
code_model,
Expand Down

0 comments on commit 19fc777

Please sign in to comment.