From 450a3e3179096c09cb473956386940a212f9a1d2 Mon Sep 17 00:00:00 2001 From: genotrance Date: Tue, 21 Jul 2020 12:14:36 -0500 Subject: [PATCH] Fix #2408 - add -d:globalSymbols (#14904) --- doc/nimc.rst | 3 +++ lib/system/dyncalls.nim | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/nimc.rst b/doc/nimc.rst index bd5e897c3..379d8b559 100644 --- a/doc/nimc.rst +++ b/doc/nimc.rst @@ -454,6 +454,9 @@ Define Effect path for the ``sh`` binary, in cases where it is not located in the default location ``/bin/sh``. ``noSignalHandler`` Disable the crash handler from ``system.nim``. +``globalSymbols`` Load all ``{.dynlib.}`` libraries with the ``RTLD_GLOBAL`` + flag on Posix systems to resolve symbols in subsequently + loaded libraries. ====================== ========================================================= diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim index fe4797c5f..a15d9267f 100644 --- a/lib/system/dyncalls.nim +++ b/lib/system/dyncalls.nim @@ -91,7 +91,10 @@ when defined(posix): dlclose(lib) proc nimLoadLibrary(path: string): LibHandle = - result = dlopen(path, RTLD_NOW) + let flags = + when defined(globalSymbols): RTLD_NOW or RTLD_GLOBAL + else: RTLD_NOW + result = dlopen(path, flags) when defined(nimDebugDlOpen): let error = dlerror() if error != nil: