Skip to content

Commit 941ff01

Browse files
authored
Allow linking a system image with jl_image_unpack with libjulia (#59498)
After #59227 changed the way we load system images, the symbols in `null_sysimg.c` are no longer correct. Replace them with `jl_image_unpack` so linking a system image with libjulia is possible again.
1 parent d3cc67a commit 941ff01

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/null_sysimage.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
* These symbols support statically linking the sysimage with libjulia-internal.
88
*
99
* Here we provide dummy definitions that are used when these are not linked
10-
* together (the default build configuration). The 0 value of jl_system_image_size
10+
* together (the default build configuration). The 0 value of jl_image_unpack
1111
* is used as a sentinel to indicate that the sysimage should be loaded externally.
1212
**/
13-
char jl_system_image_data = 0;
14-
size_t jl_system_image_size = 0;
15-
jl_image_pointers_t jl_image_pointers = { 0 };
13+
jl_image_unpack_func_t *jl_image_unpack = NULL;

src/processor.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,8 @@ JL_DLLEXPORT int32_t jl_get_default_nans(void);
240240
* libjulia-* and the sysimage together (see null_sysimage.c), in which
241241
* case they allow accessing the local copy of the sysimage.
242242
**/
243-
extern char jl_system_image_data;
244-
extern size_t jl_system_image_size;
245-
extern jl_image_pointers_t jl_image_pointers;
243+
typedef void jl_image_unpack_func_t(void *handle, jl_image_buf_t *image);
244+
extern jl_image_unpack_func_t *jl_image_unpack;
246245

247246
#ifdef __cplusplus
248247
}

src/staticdata.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,6 @@ JL_DLLEXPORT jl_image_buf_t jl_preload_sysimg(const char *fname)
36353635
}
36363636
}
36373637

3638-
typedef void jl_image_unpack_func_t(void *handle, jl_image_buf_t *image);
36393638

36403639
static void jl_prefetch_system_image(const char *data, size_t size)
36413640
{
@@ -3722,19 +3721,17 @@ static jl_image_buf_t get_image_buf(void *handle, int is_pkgimage)
37223721
};
37233722

37243723
// verification passed, lookup the buffer pointers
3725-
if (jl_system_image_size == 0 || is_pkgimage) {
3724+
if (jl_image_unpack == NULL || is_pkgimage) {
37263725
// in the usual case, the sysimage was not statically linked to libjulia-internal
37273726
// look up the external sysimage symbols via the dynamic linker
37283727
jl_dlsym(handle, "jl_image_unpack", (void **)&unpack, 1);
3729-
(*unpack)(handle, &image);
37303728
}
37313729
else {
37323730
// the sysimage was statically linked directly against libjulia-internal
37333731
// use the internal symbols
3734-
image.size = jl_system_image_size;
3735-
image.pointers = &jl_image_pointers;
3736-
image.data = &jl_system_image_data;
3732+
unpack = &jl_image_unpack;
37373733
}
3734+
(*unpack)(handle, &image);
37383735

37393736
#ifdef _OS_WINDOWS_
37403737
image.base = (intptr_t)handle;

0 commit comments

Comments
 (0)