Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,17 @@ static void jl_compile_codeinst_now(jl_code_instance_t *codeinst)
if (!decls.specFunctionObject.empty())
NewDefs.push_back(decls.specFunctionObject);
}
auto Addrs = jl_ExecutionEngine->findSymbols(NewDefs);

// Split batches to avoid stack overflow in the JIT linker.
// FIXME: Patch ORCJITs InPlaceTaskDispatcher to not recurse on task dispatches but
// push the tasks to a queue to be drained later. This avoids the stackoverflow caused by recursion
// in the linker when compiling a large number of functions at once.
SmallVector<uint64_t, 0> Addrs;
for (size_t i = 0; i < NewDefs.size(); i += 1000) {
auto end = std::min(i + 1000, NewDefs.size());
SmallVector<StringRef> batch(NewDefs.begin() + i, NewDefs.begin() + end);
auto AddrsBatch = jl_ExecutionEngine->findSymbols(batch);
Addrs.append(AddrsBatch);
}
size_t nextaddr = 0;
for (auto &this_code : linkready) {
auto it = invokenames.find(this_code);
Expand Down
3 changes: 3 additions & 0 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1268,3 +1268,6 @@ end
end
end
end

# https://github.com/JuliaLang/julia/issues/58229 Recursion in jitlinking with inline=no
@test success(`$(Base.julia_cmd()) --inline=no -e 'Base.compilecache(Base.identify_package("Pkg"))'`)