Skip to content

Commit f7e1a7b

Browse files
vtjnashtecosaur
authored andcommitted
fix sysimage-native-code=no option with pkgimages (JuliaLang#53373)
Loading pkgimages would try to access the sysimage native code, which will fail. Ensure that no code tries to load if the sysimage native code is not available, as it may try to link against it. Fixes JuliaLang#53147
1 parent 69ac114 commit f7e1a7b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/staticdata.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,8 @@ extern void * JL_WEAK_SYMBOL_OR_ALIAS_DEFAULT(system_image_data_unavailable) jl_
607607
extern void * JL_WEAK_SYMBOL_OR_ALIAS_DEFAULT(system_image_data_unavailable) jl_system_image_size;
608608
static void jl_load_sysimg_so(void)
609609
{
610-
int imaging_mode = jl_generating_output() && !jl_options.incremental;
611-
// in --build mode only use sysimg data, not precompiled native code
612-
if (!imaging_mode && jl_options.use_sysimage_native_code==JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES) {
613-
assert(sysimage.fptrs.ptrs);
614-
}
615-
else {
616-
memset(&sysimage.fptrs, 0, sizeof(sysimage.fptrs));
617-
}
618610
const char *sysimg_data;
611+
assert(sysimage.fptrs.ptrs); // jl_init_processor_sysimg should already be run
619612
if (jl_sysimg_handle == jl_exe_handle &&
620613
&jl_system_image_data != JL_WEAK_SYMBOL_DEFAULT(system_image_data_unavailable))
621614
sysimg_data = (const char*)&jl_system_image_data;
@@ -3097,6 +3090,17 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
30973090
htable_new(&new_dt_objs, 0);
30983091
arraylist_new(&deser_sym, 0);
30993092

3093+
// in --build mode only use sysimg data, not precompiled native code
3094+
int imaging_mode = jl_generating_output() && !jl_options.incremental;
3095+
if (!imaging_mode && jl_options.use_sysimage_native_code == JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES) {
3096+
if (image->gvars_base)
3097+
assert(image->fptrs.ptrs);
3098+
}
3099+
else {
3100+
memset(&image->fptrs, 0, sizeof(image->fptrs));
3101+
image->gvars_base = NULL;
3102+
}
3103+
31003104
// step 1: read section map
31013105
assert(ios_pos(f) == 0 && f->bm == bm_mem);
31023106
size_t sizeof_sysdata = read_uint(f);

0 commit comments

Comments
 (0)