Skip to content

Commit

Permalink
Try to fix Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Mar 9, 2022
1 parent 263d418 commit 22124da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const char *jl_crtdll_name = CRTDLL_BASENAME ".dll";
#define JL_RTLD(flags, FLAG) (flags & JL_RTLD_ ## FLAG ? RTLD_ ## FLAG : 0)

#ifdef _OS_WINDOWS_
static void win32_formatmessage(DWORD code, char *reason, int len) JL_NOTSAFEPOINT
void win32_formatmessage(DWORD code, char *reason, int len) JL_NOTSAFEPOINT
{
DWORD res;
LPWSTR errmsg;
Expand Down
1 change: 1 addition & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ extern void *jl_ntdll_handle;
extern void *jl_kernel32_handle;
extern void *jl_crtdll_handle;
extern void *jl_winsock_handle;
void win32_formatmessage(DWORD code, char *reason, int len) JL_NOTSAFEPOINT;
#endif

JL_DLLEXPORT void *jl_get_library_(const char *f_lib, int throw_err);
Expand Down
15 changes: 12 additions & 3 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2473,9 +2473,18 @@ JL_DLLEXPORT jl_value_t *jl_restore_system_image_data(const char *buf, size_t le

JL_DLLEXPORT jl_value_t *jl_restore_package_image_from_file(const char *fname)
{
void *pkgimg_handle = dlopen(fname, RTLD_LAZY);
if (!pkgimg_handle)
jl_errorf("Error opening package file %s: %s\n", fname, dlerror());
void *pkgimg_handle = jl_dlopen(fname, JL_RTLD_LAZY);
if (!pkgimg_handle) {
#ifdef _OS_WINDOWS_
int err;
char reason[256];
err = GetLastError();
win32_formatmessage(err, reason, sizeof(reason));
#else
const char *reason = dlerror();
#endif
jl_errorf("Error opening package file %s: %s\n", fname, reason);
}
const char *pkgimg_data;
jl_dlsym(pkgimg_handle, "jl_system_image_data", (void **)&pkgimg_data, 1);
size_t *plen;
Expand Down

0 comments on commit 22124da

Please sign in to comment.