From ebc845a6a22dc35b718a5183c317e0e3ec8c01f1 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Wed, 26 Aug 2026 18:56:06 +0000 Subject: [PATCH 1/2] Call jl_init_options from jl_autoinit_and_adopt_thread `jl_init_options` is normally invoked by the libjulia loader (cli/loader_lib.c) before anything else runs. When the runtime is linked statically into an image there is no loader, and the auto-initialization trampoline is the first runtime entry point, so make it initialize `jl_options` itself. `jl_init_options` is idempotent, so this is a no-op for the shared build. Co-Authored-By: Claude Fable 5 --- src/threading.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/threading.c b/src/threading.c index 3f1e2a7fef7c2..4506bd4b5ca40 100644 --- a/src/threading.c +++ b/src/threading.c @@ -487,6 +487,9 @@ JL_DLLEXPORT jl_gcframe_t **jl_autoinit_and_adopt_thread(void) JL_CANSAFEPOINT_E " (this should not happen, please file a bug report)\n"); exit(1); } + // normally done by the libjulia loader, but there is none when the + // runtime is linked statically into the image + jl_init_options(); jl_init_with_image_handle(handle); return &jl_get_current_task()->gcstack; } From 3e720dd9c526ef3b0eabf5e60af588d3f4d2a67d Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 31 Aug 2026 15:52:51 +0000 Subject: [PATCH 2/2] Annotate jl_init_options as JL_NOTSAFEPOINT It only initializes the jl_options struct (plus getenv/strtol), and is now called from the JL_NOTSAFEPOINT path of jl_autoinit_and_adopt_thread, which the GC analyzer rejects without the annotation. Co-Authored-By: Claude Fable 5 --- src/jloptions.c | 2 +- src/julia_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jloptions.c b/src/jloptions.c index b54b02b32d18d..fe85a77f08638 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -86,7 +86,7 @@ uint64_t parse_heap_size_option(const char *optarg, const char *option_name, int static int jl_options_initialized = 0; -JL_DLLEXPORT void jl_init_options(void) +JL_DLLEXPORT void jl_init_options(void) JL_NOTSAFEPOINT { if (jl_options_initialized) return; diff --git a/src/julia_internal.h b/src/julia_internal.h index 398539bd4f7f6..860b5c700e205 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -1357,7 +1357,7 @@ jl_task_t *jl_init_root_task(jl_ptls_t ptls, void *stack_lo, void *stack_hi) JL_ void jl_init_serializer(void) JL_CANSAFEPOINT; void jl_init_uv(void) JL_NOTSAFEPOINT; void jl_init_box_caches(void) JL_NOTSAFEPOINT; -JL_DLLEXPORT void jl_init_options(void); +JL_DLLEXPORT void jl_init_options(void) JL_NOTSAFEPOINT; void jl_set_base_ctx(char *__stk);