Skip to content

Commit

Permalink
Lookup libraries in libjulia-* before jl_exe_handle
Browse files Browse the repository at this point in the history
We do not use `dlvsym` to separate the symbols between multiple copies
of libjulia, instead preferring to resolve symbols directly against the
appropriate internal library handle.

During bootstrapping, many internal symbols (e.g. `jl_fl_parse`) are
available in the global EXE namespace, so we need to adapt our search
order to resolve symbols in internal libraries first.

With this fix, no sysimage symbols are resolved to `jl_exe_handle`
(which is generally broken in Julia-in-Julia scenarios):
```
$ cat objdump_after.txt | grep libjulia_internal_handle | wc
   1131   14703  145899
$ cat objdump_after.txt | grep jl_exe_handle | wc
      0       0       0
```

versus before:
```
$ cat objdump_before.txt | grep libjulia_internal_handle | wc
    577    7501   74433
$ cat objdump_before.txt | grep jl_exe_handle | wc
    554    7202   63710
```
  • Loading branch information
topolarity committed Jun 13, 2023
1 parent df09f67 commit 82c89c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int t
JL_DLLEXPORT const char *jl_dlfind(const char *f_name)
{
void * dummy;
if (jl_dlsym(jl_exe_handle, f_name, &dummy, 0))
return JL_EXE_LIBNAME;
if (jl_dlsym(jl_libjulia_internal_handle, f_name, &dummy, 0))
return JL_LIBJULIA_INTERNAL_DL_LIBNAME;
if (jl_dlsym(jl_libjulia_handle, f_name, &dummy, 0))
return JL_LIBJULIA_DL_LIBNAME;
if (jl_dlsym(jl_exe_handle, f_name, &dummy, 0))
return JL_EXE_LIBNAME;
#ifdef _OS_WINDOWS_
if (jl_dlsym(jl_kernel32_handle, f_name, &dummy, 0))
return "kernel32";
Expand Down

0 comments on commit 82c89c6

Please sign in to comment.