Skip to content

Commit

Permalink
Add a codegen option to disable use of jlplts
Browse files Browse the repository at this point in the history
Alternative to #51108.
  • Loading branch information
Keno committed Aug 31, 2023
1 parent a355403 commit e118207
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ struct CodegenParams
debug_info_kind::Cint
safepoint_on_entry::Cint
gcstack_arg::Cint
use_jlplt::Cint

lookup::Ptr{Cvoid}

Expand All @@ -1228,15 +1229,15 @@ struct CodegenParams
prefer_specsig::Bool=false,
gnu_pubnames=true, debug_info_kind::Cint = default_debug_info_kind(),
safepoint_on_entry::Bool=true,
gcstack_arg::Bool=true,
gcstack_arg::Bool=true, use_jlplt::Bool=true,
lookup::Ptr{Cvoid}=unsafe_load(cglobal(:jl_rettype_inferred_addr, Ptr{Cvoid})),
generic_context = nothing)
return new(
Cint(track_allocations), Cint(code_coverage),
Cint(prefer_specsig),
Cint(gnu_pubnames), debug_info_kind,
Cint(safepoint_on_entry),
Cint(gcstack_arg),
Cint(gcstack_arg), Cint(use_jlplt),
lookup, generic_context)
end
end
Expand Down
8 changes: 8 additions & 0 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,14 @@ jl_cgval_t function_sig_t::emit_a_ccall(
if (ctx.emission_context.imaging_mode)
jl_printf(JL_STDERR,"WARNING: literal address used in ccall for %s; code cannot be statically compiled\n", symarg.f_name);
}
else if (!ctx.params->use_jlplt) {
if ((symarg.f_lib && !((symarg.f_lib == JL_EXE_LIBNAME) ||
(symarg.f_lib == JL_LIBJULIA_INTERNAL_DL_LIBNAME) ||
(symarg.f_lib == JL_LIBJULIA_DL_LIBNAME))) || symarg.lib_expr) {
emit_error(ctx, "ccall: Had library expression, but symbol lookup was disabled");
}
llvmf = jl_Module->getOrInsertFunction(symarg.f_name, functype).getCallee();
}
else {
assert(symarg.f_name != NULL);
PointerType *funcptype = PointerType::get(functype, 0);
Expand Down
1 change: 1 addition & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ extern "C" {
/* debug_info_kind */ (int) DICompileUnit::DebugEmissionKind::FullDebug,
/* safepoint_on_entry */ 1,
/* gcstack_arg */ 1,
/* use_jlplt*/ 1,
/* lookup */ jl_rettype_inferred_addr,
/* generic_context */ NULL };
}
Expand Down
2 changes: 2 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -2354,6 +2354,8 @@ typedef struct {
int safepoint_on_entry; // Emit a safepoint on entry to each function
int gcstack_arg; // Pass the ptls value as an argument with swiftself

int use_jlplt; // Whether to use the Julia PLT mechanism or emit symbols directly

// Cache access. Default: jl_rettype_inferred.
jl_codeinstance_lookup_t lookup;

Expand Down

0 comments on commit e118207

Please sign in to comment.