@@ -61,7 +61,6 @@ static bool runtime_sym_gvs(jl_codectx_t &ctx, const char *f_lib, const char *f_
6161 bool runtime_lib = false ;
6262 GlobalVariable *libptrgv;
6363 jl_codegen_params_t ::SymMapGV *symMap;
64- #ifdef _OS_WINDOWS_
6564 if ((intptr_t )f_lib == (intptr_t )JL_EXE_LIBNAME) {
6665 libptrgv = prepare_global_in (M, jlexe_var);
6766 symMap = &ctx.emission_context .symMapExe ;
@@ -74,9 +73,7 @@ static bool runtime_sym_gvs(jl_codectx_t &ctx, const char *f_lib, const char *f_
7473 libptrgv = prepare_global_in (M, jldll_var);
7574 symMap = &ctx.emission_context .symMapDll ;
7675 }
77- else
78- #endif
79- if (f_lib == NULL ) {
76+ else if (f_lib == NULL ) {
8077 libptrgv = jl_emit_RTLD_DEFAULT_var (M);
8178 symMap = &ctx.emission_context .symMapDefault ;
8279 }
@@ -631,16 +628,12 @@ static void interpret_symbol_arg(jl_codectx_t &ctx, native_sym_arg_t &out, jl_va
631628 std::string iname (" i" );
632629 iname += f_name;
633630 if (jl_dlsym (jl_libjulia_internal_handle, iname.c_str (), &symaddr, 0 )) {
634- #ifdef _OS_WINDOWS_
635631 f_lib = JL_LIBJULIA_INTERNAL_DL_LIBNAME;
636- #endif
637632 f_name = jl_symbol_name (jl_symbol (iname.c_str ()));
638633 }
639- #ifdef _OS_WINDOWS_
640634 else {
641- f_lib = jl_dlfind_win32 (f_name);
635+ f_lib = jl_dlfind (f_name);
642636 }
643- #endif
644637 }
645638 }
646639 else if (jl_is_cpointer_type (jl_typeof (ptr))) {
@@ -726,7 +719,8 @@ static jl_cgval_t emit_cglobal(jl_codectx_t &ctx, jl_value_t **args, size_t narg
726719 void *symaddr;
727720
728721 void * libsym = jl_get_library_ (sym.f_lib , 0 );
729- if (!libsym || !jl_dlsym (libsym, sym.f_name , &symaddr, 0 )) {
722+ int symbol_found = jl_dlsym (libsym, sym.f_name , &symaddr, 0 );
723+ if (!libsym || !symbol_found) {
730724 // Error mode, either the library or the symbol couldn't be find during compiletime.
731725 // Fallback to a runtime symbol lookup.
732726 res = runtime_sym_lookup (ctx, cast<PointerType>(getInt8PtrTy (ctx.builder .getContext ())), sym.f_lib , NULL , sym.f_name , ctx.f );
@@ -1381,18 +1375,19 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
13811375 if ((uintptr_t )fptr == ptr)
13821376 return true ;
13831377 if (f_lib) {
1384- #ifdef _OS_WINDOWS_
13851378 if ((f_lib == JL_EXE_LIBNAME) || // preventing invalid pointer access
13861379 (f_lib == JL_LIBJULIA_INTERNAL_DL_LIBNAME) ||
1387- (f_lib == JL_LIBJULIA_DL_LIBNAME) ||
1388- (!strcmp (f_lib, jl_crtdll_basename))) {
1380+ (f_lib == JL_LIBJULIA_DL_LIBNAME)) {
1381+ // libjulia-like
1382+ }
1383+ else
1384+ #ifdef _OS_WINDOWS_
1385+ if (strcmp (f_lib, jl_crtdll_basename) == 0 ) {
13891386 // libjulia-like
13901387 }
13911388 else
1392- return false ;
1393- #else
1394- return false ;
13951389#endif
1390+ return false ;
13961391 }
13971392 return f_name && f_name == name;
13981393 };
@@ -2082,7 +2077,8 @@ jl_cgval_t function_sig_t::emit_a_ccall(
20822077 else {
20832078 void *symaddr;
20842079 void *libsym = jl_get_library_ (symarg.f_lib , 0 );
2085- if (!libsym || !jl_dlsym (libsym, symarg.f_name , &symaddr, 0 )) {
2080+ int symbol_found = jl_dlsym (libsym, symarg.f_name , &symaddr, 0 );
2081+ if (!libsym || !symbol_found) {
20862082 ++DeferredCCallLookups;
20872083 // either the library or the symbol could not be found, place a runtime
20882084 // lookup here instead.
0 commit comments