Skip to content

Commit

Permalink
[mac] Use ObjectLinkingLayer instead of RTDyldObjectLinkingLayer for …
Browse files Browse the repository at this point in the history
…aarch64 mac (#7201)

Issue: #

### Brief Summary
We sometimes hit `Assertion failed: (isInt<33>(Addend) && "Invalid page
reloc value."), function encodeAddend, file RuntimeDyldMachOAArch64.h,
line 210.` on m1 ci job and this PR tries to fix it.
Example failed ci jobs:
https://github.com/taichi-dev/taichi/actions/runs/3936953922
  • Loading branch information
ailzhang authored Jan 17, 2023
1 parent e894f79 commit c2d20ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion taichi/runtime/cpu/jit_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
// From https://github.com/JuliaLang/julia/pull/43664
#if defined(__APPLE__) && defined(__aarch64__)
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#else
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#endif
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
Expand Down Expand Up @@ -50,6 +55,11 @@ namespace taichi::lang {
#ifdef TI_WITH_LLVM
using namespace llvm;
using namespace llvm::orc;
#if defined(__APPLE__) && defined(__aarch64__)
typedef orc::ObjectLinkingLayer ObjLayerT;
#else
typedef orc::RTDyldObjectLinkingLayer ObjLayerT;
#endif
#endif

std::pair<JITTargetMachineBuilder, llvm::DataLayout> get_host_target_info() {
Expand Down Expand Up @@ -87,7 +97,7 @@ class JITModuleCPU : public JITModule {
class JITSessionCPU : public JITSession {
private:
ExecutionSession es_;
RTDyldObjectLinkingLayer object_layer_;
ObjLayerT object_layer_;
IRCompileLayer compile_layer_;
DataLayout dl_;
MangleAndInterner mangle_;
Expand All @@ -104,12 +114,16 @@ class JITSessionCPU : public JITSession {
DataLayout DL)
: JITSession(tlctx, config),
es_(std::move(EPC)),
#if defined(__APPLE__) && defined(__aarch64__)
object_layer_(es_),
#else
object_layer_(es_,
[&]() {
auto smgr = std::make_unique<SectionMemoryManager>();
memory_manager_ = smgr.get();
return smgr;
}),
#endif
compile_layer_(es_,
object_layer_,
std::make_unique<ConcurrentIRCompiler>(JTMB)),
Expand Down

0 comments on commit c2d20ba

Please sign in to comment.