@@ -182,6 +182,18 @@ __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_pgcstack_setkey (fptr , key );
196+ #endif
185197
186198 // jl_options must be initialized very early, in case an embedder sets some
187199 // values there before calling jl_init
@@ -199,22 +211,6 @@ JL_DLLEXPORT int jl_load_repl(int argc, char * argv[]) {
199211 exit (1 );
200212 }
201213 }
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-
218214 // Load the repl entrypoint symbol and jump into it!
219215 int (* entrypoint )(int , char * * ) = (int (* )(int , char * * ))lookup_symbol (libjulia_internal , "jl_repl_entrypoint" );
220216 if (entrypoint == NULL ) {
0 commit comments