Skip to content

Commit e118207

Browse files
committed
Add a codegen option to disable use of jlplts
Alternative to #51108.
1 parent a355403 commit e118207

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

base/reflection.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ struct CodegenParams
12191219
debug_info_kind::Cint
12201220
safepoint_on_entry::Cint
12211221
gcstack_arg::Cint
1222+
use_jlplt::Cint
12221223

12231224
lookup::Ptr{Cvoid}
12241225

@@ -1228,15 +1229,15 @@ struct CodegenParams
12281229
prefer_specsig::Bool=false,
12291230
gnu_pubnames=true, debug_info_kind::Cint = default_debug_info_kind(),
12301231
safepoint_on_entry::Bool=true,
1231-
gcstack_arg::Bool=true,
1232+
gcstack_arg::Bool=true, use_jlplt::Bool=true,
12321233
lookup::Ptr{Cvoid}=unsafe_load(cglobal(:jl_rettype_inferred_addr, Ptr{Cvoid})),
12331234
generic_context = nothing)
12341235
return new(
12351236
Cint(track_allocations), Cint(code_coverage),
12361237
Cint(prefer_specsig),
12371238
Cint(gnu_pubnames), debug_info_kind,
12381239
Cint(safepoint_on_entry),
1239-
Cint(gcstack_arg),
1240+
Cint(gcstack_arg), Cint(use_jlplt),
12401241
lookup, generic_context)
12411242
end
12421243
end

src/ccall.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,14 @@ jl_cgval_t function_sig_t::emit_a_ccall(
20772077
if (ctx.emission_context.imaging_mode)
20782078
jl_printf(JL_STDERR,"WARNING: literal address used in ccall for %s; code cannot be statically compiled\n", symarg.f_name);
20792079
}
2080+
else if (!ctx.params->use_jlplt) {
2081+
if ((symarg.f_lib && !((symarg.f_lib == JL_EXE_LIBNAME) ||
2082+
(symarg.f_lib == JL_LIBJULIA_INTERNAL_DL_LIBNAME) ||
2083+
(symarg.f_lib == JL_LIBJULIA_DL_LIBNAME))) || symarg.lib_expr) {
2084+
emit_error(ctx, "ccall: Had library expression, but symbol lookup was disabled");
2085+
}
2086+
llvmf = jl_Module->getOrInsertFunction(symarg.f_name, functype).getCallee();
2087+
}
20802088
else {
20812089
assert(symarg.f_name != NULL);
20822090
PointerType *funcptype = PointerType::get(functype, 0);

src/codegen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ extern "C" {
13651365
/* debug_info_kind */ (int) DICompileUnit::DebugEmissionKind::FullDebug,
13661366
/* safepoint_on_entry */ 1,
13671367
/* gcstack_arg */ 1,
1368+
/* use_jlplt*/ 1,
13681369
/* lookup */ jl_rettype_inferred_addr,
13691370
/* generic_context */ NULL };
13701371
}

src/julia.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,8 @@ typedef struct {
23542354
int safepoint_on_entry; // Emit a safepoint on entry to each function
23552355
int gcstack_arg; // Pass the ptls value as an argument with swiftself
23562356

2357+
int use_jlplt; // Whether to use the Julia PLT mechanism or emit symbols directly
2358+
23572359
// Cache access. Default: jl_rettype_inferred.
23582360
jl_codeinstance_lookup_t lookup;
23592361

0 commit comments

Comments
 (0)