diff --git a/src/jloptions.c b/src/jloptions.c index b54b02b32d18d..12e1f067b58f5 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; @@ -380,6 +380,11 @@ static const char opts_hidden[] = JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp) { + // ensure the defaults are in place before parsing over them; a no-op when + // the loader (or a previous call) already initialized the options, but a + // static build may parse options (e.g. from a constructor) before any + // other runtime entry point has run + jl_init_options(); enum { opt_machinefile = 300, opt_color, opt_history_file, diff --git a/src/julia_internal.h b/src/julia_internal.h index d89d070bab17d..5519da6da44e6 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); 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; }