Skip to content
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

Only add symbols that are explicit entrypoints when building juliac image #56681

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
6 changes: 2 additions & 4 deletions src/precompile_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,8 @@ static void *jl_precompile_trimmed(size_t world)
jl_value_t *ccallable = NULL;
JL_GC_PUSH2(&m, &ccallable);
jl_method_instance_t *mi;
while (1)
{
mi = (jl_method_instance_t*)arraylist_pop(jl_entrypoint_mis);
for (size_t i = 0; i < jl_entrypoint_mis->len ; i++) {
mi = (jl_method_instance_t*)jl_entrypoint_mis->items[i];
topolarity marked this conversation as resolved.
Show resolved Hide resolved
if (mi == NULL)
break;
assert(jl_is_method_instance(mi));
Expand All @@ -386,7 +385,6 @@ static void *jl_precompile_trimmed(size_t world)
if (ccallable)
jl_array_ptr_1d_push(m, ccallable);
}

jl_cgparams_t params = jl_default_cgparams;
params.trim = jl_options.trim;
void *native_code = jl_create_native(m, NULL, &params, 0, /* imaging */ 1, 0,
Expand Down
16 changes: 14 additions & 2 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1741,8 +1741,20 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
else {
newm->nroots_sysimg = m->roots ? jl_array_len(m->roots) : 0;
}
if (m->ccallable)
arraylist_push(&s->ccallable_list, (void*)reloc_offset);
if (m->ccallable) {
int should_push = !jl_options.trim;
for (size_t i = 0; !should_push && i < jl_entrypoint_mis->len ; i++) {
jl_method_instance_t* mi = (jl_method_instance_t*)jl_entrypoint_mis->items[i];
assert(jl_is_method_instance(mi));
jl_method_t *ccallable = mi->def.method;
if (ccallable == m) {
topolarity marked this conversation as resolved.
Show resolved Hide resolved
should_push = 1;
break;
}
}
if (should_push)
arraylist_push(&s->ccallable_list, (void*)reloc_offset);
}
}
else if (jl_is_method_instance(v)) {
assert(f == s->s);
Expand Down