Skip to content

Commit

Permalink
Use default JIT code model with JITLink
Browse files Browse the repository at this point in the history
While the small code model would be enough if we created a new JITDylib
per Module, Cling adds multiple modules to the same library. This causes
problems because weak symbols are merged and may end up more than 2 GB
apart. This is especially visible for DW.ref.__gxx_personality_v0
related to exception handling.
  • Loading branch information
hahnjo authored and jenkins committed Sep 12, 2024
1 parent ee4eb4d commit 535417b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/Interpreter/IncrementalJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,13 @@ CreateTargetMachine(const clang::CompilerInstance& CI, bool JITLink) {
// Set up the TargetMachine as otherwise done by
// LLJITBuilderState::prepareForConstruction.
JTMB.setRelocationModel(Reloc::PIC_);
// Set the small code except for macOS on AArch64 - it results in relocation
// targets that are out-of-range.
// TODO: Investigate / report upstream and re-evaluate after a future LLVM
// upgrade.
if (!(TT.isOSBinFormatMachO() && TT.getArch() == Triple::aarch64))
JTMB.setCodeModel(CodeModel::Small);
// However, do not change the code model: While the small code model would
// be enough if we created a new JITDylib per Module, Cling adds multiple
// modules to the same library. This causes problems because weak symbols
// are merged and may end up more than 2 GB apart. This is especially
// visible for DW.ref.__gxx_personality_v0 related to exception handling.
// TODO: Investigate if we can use one JITDylib per Module as recommended
// by upstream.
}

return cantFail(JTMB.createTargetMachine());
Expand Down

0 comments on commit 535417b

Please sign in to comment.