[R] dyn.load(now = FALSE) not actually lazy?

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Feb 1 11:05:46 CET 2023

В Wed, 1 Feb 2023 14:16:54 +1100
Michael Milton <ttmigueltt using gmail.com> пишет:

> Is this a bug in the `dyn.load` implementation for R? If not, why is
> it behaving like this? What should I do about it?

On Unix-like systems, dyn.load forwards its arguments to dlopen(). It
should be possible to confirm with a debugger that R passes RTLD_NOW to
dlopen() when calling dyn.load(now = TRUE) and RTLD_LAZY when calling
dyn.load(now = FALSE).

I don't know for sure why the symbols are being resolved despite you
asked the linker not to. Did something in the system set the
LD_BIND_NOW environment variable? Do any of the libraries in the
dependency tree have any constructors (C++ or
__attribute__((constructor)) or otherwise mentioned in .ini* sections)
that rely on MKL being available at initialisation time?

If you launch R with the environment variable LD_DEBUG=libs set, the
debugging output may shine some light on the problem.

Best regards,

More information about the R-help mailing list