Skip to content

Commit f397b8b

Browse files
authored
move enabling fast TLS from jl_load_repl to jl_load_libjulia_internal (#43655)
1 parent 754ce5d commit f397b8b

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

cli/loader_lib.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,21 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
230230
}
231231
(*jl_codegen_exported_func_addrs[symbol_idx]) = addr;
232232
}
233+
// Next, if we're on Linux/FreeBSD, set up fast TLS.
234+
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
235+
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
236+
if (jl_pgcstack_setkey == NULL) {
237+
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
238+
exit(1);
239+
}
240+
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
241+
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
242+
if (fptr == NULL || key == NULL) {
243+
jl_loader_print_stderr("ERROR: Cannot find jl_get_pgcstack_static(), must define this symbol within calling executable!\n");
244+
exit(1);
245+
}
246+
jl_pgcstack_setkey(fptr, key);
247+
#endif
233248

234249
// jl_options must be initialized very early, in case an embedder sets some
235250
// values there before calling jl_init
@@ -247,22 +262,6 @@ JL_DLLEXPORT int jl_load_repl(int argc, char * argv[]) {
247262
exit(1);
248263
}
249264
}
250-
// Next, if we're on Linux/FreeBSD, set up fast TLS.
251-
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
252-
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
253-
if (jl_pgcstack_setkey == NULL) {
254-
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
255-
exit(1);
256-
}
257-
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
258-
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
259-
if (fptr == NULL || key == NULL) {
260-
jl_loader_print_stderr("ERROR: Cannot find jl_get_pgcstack_static(), must define this symbol within calling executable!\n");
261-
exit(1);
262-
}
263-
jl_pgcstack_setkey(fptr, key);
264-
#endif
265-
266265
// Load the repl entrypoint symbol and jump into it!
267266
int (*entrypoint)(int, char **) = (int (*)(int, char **))lookup_symbol(libjulia_internal, "jl_repl_entrypoint");
268267
if (entrypoint == NULL) {

0 commit comments

Comments
 (0)