1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Description: Workaround libm.so being a linker script these days
It's a hack, just hardcoding libm.so.6 (which is a shared library) for now.
Fixes tests in _rawffi.
Author: Armin Rigo <arigo@tunes.org>
Origin: upstream,
https://bitbucket.org/pypy/pypy/commits/3f56c9ee1d6e146682dae538bfb0cd3093662654
https://bitbucket.org/pypy/pypy/commits/e075b4dfeb37a8bbc0f0002a779afd450cfbc507
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -98,8 +98,15 @@
try:
ctypes.CDLL(name)
except OSError as e:
+ # common case: ctypes fails too, with the real dlerror()
+ # message in str(e). Return that error message.
return str(e)
else:
+ # uncommon case: may happen if 'name' is a linker script
+ # (which the C-level dlopen() can't handle) and we are
+ # directly running on pypy (whose implementation of ctypes
+ # or cffi will resolve linker scripts). In that case,
+ # unsure what we can do.
return ("opening %r with ctypes.CDLL() works, "
"but not with c_dlopen()??" % (name,))
@@ -160,6 +167,13 @@
mode = _dlopen_default_mode()
elif (mode & (RTLD_LAZY | RTLD_NOW)) == 0:
mode |= RTLD_NOW
+ #
+ # haaaack for 'pypy py.test -A' if libm.so is a linker script
+ # (see reason in _dlerror_on_dlopen_untranslated())
+ if not we_are_translated() and platform.name == "linux":
+ if name and rffi.charp2str(name) == 'libm.so':
+ name = rffi.str2charp('libm.so.6', track_allocation=False)
+ #
res = c_dlopen(name, rffi.cast(rffi.INT, mode))
if not res:
if not we_are_translated():
|