diff --git a/src/codegen.cpp b/src/codegen.cpp index 28d69354c0309..53609659b017a 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6915,7 +6915,6 @@ extern "C" void *jl_init_llvm(void) jl_page_size = jl_getpagesize(); imaging_mode = jl_generating_output(); jl_init_debuginfo(); - jl_init_runtime_ccall(); #ifdef USE_POLLY PassRegistry &Registry = *PassRegistry::getPassRegistry(); diff --git a/src/dlload.c b/src/dlload.c index d7232408f268c..4709ba1c14c42 100644 --- a/src/dlload.c +++ b/src/dlload.c @@ -191,15 +191,6 @@ static void *jl_load_dynamic_library_(const char *modname, unsigned flags, int t goto done; } -#if defined(__linux__) || defined(__FreeBSD__) - // check map of versioned libs from "libX" to full soname "libX.so.ver" - if (!abspath && n_extensions > 1) { // soname map only works for libX - handle = jl_dlopen_soname(modname, strlen(modname), flags); - if (handle) - goto done; - } -#endif - notfound: if (throw_err) jl_dlerror("could not load library \"%s\"\n%s", modname); diff --git a/src/julia.h b/src/julia.h index 155bc23c15c6f..14392861c2b1d 100644 --- a/src/julia.h +++ b/src/julia.h @@ -1393,10 +1393,6 @@ JL_DLLEXPORT int jl_dlclose(jl_uv_libhandle handle); JL_DLLEXPORT void *jl_dlsym_e(jl_uv_libhandle handle, const char *symbol); JL_DLLEXPORT void *jl_dlsym(jl_uv_libhandle handle, const char *symbol); -#if defined(__linux__) || defined(__FreeBSD__) -JL_DLLEXPORT const char *jl_lookup_soname(const char *pfx, size_t n); -#endif - // compiler JL_DLLEXPORT jl_value_t *jl_toplevel_eval(jl_module_t *m, jl_value_t *v); JL_DLLEXPORT jl_value_t *jl_toplevel_eval_in(jl_module_t *m, jl_value_t *ex); diff --git a/src/julia_internal.h b/src/julia_internal.h index 5066922872d2e..2f914ae13dbd2 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -543,7 +543,6 @@ void jl_init_serializer(void); void jl_gc_init(void); void jl_init_signal_async(void); void jl_init_debuginfo(void); -void jl_init_runtime_ccall(void); void jl_init_thread_heap(jl_ptls_t ptls); void _julia_init(JL_IMAGE_SEARCH rel); @@ -729,7 +728,6 @@ JL_DLLEXPORT void *jl_load_and_lookup(const char *f_lib, const char *f_name, #define JL_EXE_LIBNAME ((const char*)1) #define JL_DL_LIBNAME ((const char*)2) const char *jl_dlfind_win32(const char *name); -void *jl_dlopen_soname(const char *pfx, size_t n, unsigned flags); // libuv wrappers: JL_DLLEXPORT int jl_fs_rename(const char *src_path, const char *dst_path); diff --git a/src/runtime_ccall.cpp b/src/runtime_ccall.cpp index 142ecd5b4620e..e78e998324670 100644 --- a/src/runtime_ccall.cpp +++ b/src/runtime_ccall.cpp @@ -12,126 +12,6 @@ using namespace llvm; // --- library symbol lookup --- -// map from "libX" to full soname "libX.so.ver" -#if defined(__linux__) || defined(__FreeBSD__) -static uv_rwlock_t soname_lock; -static std::map sonameMap; -static bool got_sonames = false; - -extern "C" void jl_init_runtime_ccall(void) -{ - uv_rwlock_init(&soname_lock); -} - -// This reloads the sonames, necessary after system upgrade. -// Keep this DLLEXPORTed, this is used by `BinDeps.jl` to make sure -// newly installed libraries can be found. -extern "C" JL_DLLEXPORT void jl_read_sonames(void) -{ - char *line=NULL; - size_t sz=0; -#if defined(__linux__) - FILE *ldc = popen("/sbin/ldconfig -p", "r"); -#else - FILE *ldc = popen("/sbin/ldconfig -r", "r"); -#endif - if (ldc == NULL) return; // ignore errors in running ldconfig (other than whatever might have been printed to stderr) - - // This loop is not allowed to call julia GC while holding the lock - uv_rwlock_wrlock(&soname_lock); - sonameMap.clear(); - while (!feof(ldc)) { - ssize_t n = getline(&line, &sz, ldc); - if (n == -1) - break; - if (n > 2 && isspace((unsigned char)line[0])) { -#ifdef __linux__ - int i = 0; - while (isspace((unsigned char)line[++i])) ; - char *name = &line[i]; - char *dot = strstr(name, ".so"); - i = 0; -#else - char *name = strstr(line, ":-l"); - if (name == NULL) continue; - strncpy(name, "lib", 3); - char *dot = strchr(name, '.'); -#endif - - if (NULL == dot) - continue; - -#ifdef __linux__ - // Detect if this entry is for the current architecture - while (!isspace((unsigned char)dot[++i])) ; - while (isspace((unsigned char)dot[++i])) ; - int j = i; - while (!isspace((unsigned char)dot[++j])) ; - char *arch = strstr(dot+i,"x86-64"); - if (arch != NULL && arch < dot + j) { -#ifdef _P32 - continue; -#endif - } - else { -#ifdef _P64 - continue; -#endif - } -#endif // __linux__ - - char *abslibpath = strrchr(line, ' '); - if (dot != NULL && abslibpath != NULL) { - std::string pfx(name, dot - name); - // Do not include ' ' in front and '\n' at the end - std::string soname(abslibpath+1, line+n-(abslibpath+1)-1); - sonameMap[pfx] = soname; - } - } - } - - free(line); - pclose(ldc); - uv_rwlock_wrunlock(&soname_lock); -} - -// This API is not thread safe. The return value can be free'd if -// `jl_read_sonames()` is called on another thread. -extern "C" JL_DLLEXPORT const char *jl_lookup_soname(const char *pfx, size_t n) -{ - if (!got_sonames) { - jl_read_sonames(); - got_sonames = true; - } - const char *res = nullptr; - uv_rwlock_rdlock(&soname_lock); - auto search = sonameMap.find(std::string(pfx, n)); - if (search != sonameMap.end()) - res = search->second.c_str(); - uv_rwlock_rdunlock(&soname_lock); - return res; -} - -extern "C" void *jl_dlopen_soname(const char *pfx, size_t n, unsigned flags) -{ - if (!got_sonames) { - jl_read_sonames(); - got_sonames = true; - } - void *res = nullptr; - uv_rwlock_rdlock(&soname_lock); - auto search = sonameMap.find(std::string(pfx, n)); - if (search != sonameMap.end()) - res = jl_dlopen(search->second.c_str(), flags); - uv_rwlock_rdunlock(&soname_lock); - return res; -} -#else -extern "C" void jl_init_runtime_ccall(void) -{ -} -#endif - // map from user-specified lib names to handles static std::map libMap; static jl_mutex_t libmap_lock; diff --git a/test/libdl.jl b/test/libdl.jl index ffeeed83f45b6..c189616013516 100644 --- a/test/libdl.jl +++ b/test/libdl.jl @@ -183,8 +183,4 @@ let dl = C_NULL end end -if Sys.KERNEL in (:Linux, :FreeBSD) - ccall(:jl_read_sonames, Void, ()) -end - end