Skip to content

Commit 04d16b2

Browse files
committed
move enabling fast TLS from jl_load_repl to jl_load_libjulia_internal (#43655)
(cherry picked from commit f397b8b)
1 parent 3b7e9f0 commit 04d16b2

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
@@ -182,6 +182,21 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
182182
}
183183
(*jl_exported_func_addrs[symbol_idx]) = addr;
184184
}
185+
// Next, if we're on Linux/FreeBSD, set up fast TLS.
186+
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
187+
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
188+
if (jl_pgcstack_setkey == NULL) {
189+
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
190+
exit(1);
191+
}
192+
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
193+
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
194+
if (fptr == NULL || key == NULL) {
195+
jl_loader_print_stderr("ERROR: Cannot find jl_get_pgcstack_static(), must define this symbol within calling executable!\n");
196+
exit(1);
197+
}
198+
jl_pgcstack_setkey(fptr, key);
199+
#endif
185200

186201
// jl_options must be initialized very early, in case an embedder sets some
187202
// values there before calling jl_init
@@ -199,22 +214,6 @@ JL_DLLEXPORT int jl_load_repl(int argc, char * argv[]) {
199214
exit(1);
200215
}
201216
}
202-
// Next, if we're on Linux/FreeBSD, set up fast TLS.
203-
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
204-
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
205-
if (jl_pgcstack_setkey == NULL) {
206-
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
207-
exit(1);
208-
}
209-
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
210-
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
211-
if (fptr == NULL || key == NULL) {
212-
jl_loader_print_stderr("ERROR: Cannot find jl_get_pgcstack_static(), must define this symbol within calling executable!\n");
213-
exit(1);
214-
}
215-
jl_pgcstack_setkey(fptr, key);
216-
#endif
217-
218217
// Load the repl entrypoint symbol and jump into it!
219218
int (*entrypoint)(int, char **) = (int (*)(int, char **))lookup_symbol(libjulia_internal, "jl_repl_entrypoint");
220219
if (entrypoint == NULL) {

0 commit comments

Comments
 (0)