Skip to content

Add a codegen option to disable use of jlplts #51123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2023
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
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
20 changes: 13 additions & 7 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,17 +1351,23 @@ static const auto jl_new_opaque_closure_jlcall_func = new JuliaFunction<>{XSTR(j
static _Atomic(uint64_t) globalUniqueGeneratedNames{1};

// --- code generation ---

extern "C" {
jl_cgparams_t jl_default_cgparams = {1, 1, 0,
jl_cgparams_t jl_default_cgparams = {
/* track_allocations */ 1,
/* code_coverage */ 1,
/* prefer_specsig */ 0,
#ifdef _OS_WINDOWS_
0,
/* gnu_pubnames */ 0,
#else
1,
/* gnu_pubnames */ 1,
#endif
(int) DICompileUnit::DebugEmissionKind::FullDebug,
1,
1,
jl_rettype_inferred_addr, NULL };
/* 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