Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to add -lgomp to LDFLAGS to avoid "undefined symbol: GOMP_critical_name_end" errors when using o2sclpy #40

Open
badshah400 opened this issue Jul 12, 2024 · 1 comment

Comments

@badshah400
Copy link
Contributor

Having build O₂SCL 0.929, and then o₂sclpy 0.929, I tried to run the test suite of the latter using pytest. Most tests failed with errors complaining "OSError: undefined symbol: GOMP_critical_name_end":

[   54s] ../../BUILDROOT/python-o2sclpy-0.929-0.x86_64/usr/lib/python3.10/site-packages/o2sclpy/link_o2scl.py:214: in link_o2scl
[   54s]     self.o2scl=ctypes.CDLL(find_library("o2scl"),
[   54s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   54s] 
[   54s] self = <CDLL 'libo2scl.so.0', handle 0 at 0x7fdfc8fabc40>
[   54s] name = 'libo2scl.so.0', mode = 256, handle = None, use_errno = False
[   54s] use_last_error = False, winmode = None
[   54s] 
[   54s]     def __init__(self, name, mode=DEFAULT_MODE, handle=None,
[   54s]                  use_errno=False,
[   54s]                  use_last_error=False,
[   54s]                  winmode=None):
[   54s]         self._name = name
[   54s]         flags = self._func_flags_
[   54s]         if use_errno:
[   54s]             flags |= _FUNCFLAG_USE_ERRNO
[   54s]         if use_last_error:
[   54s]             flags |= _FUNCFLAG_USE_LASTERROR
[   54s]         if _sys.platform.startswith("aix"):
[   54s]             """When the name contains ".a(" and ends with ")",
[   54s]                e.g., "libFOO.a(libFOO.so)" - this is taken to be an
[   54s]                archive(member) syntax for dlopen(), and the mode is adjusted.
[   54s]                Otherwise, name is presented to dlopen() as a file argument.
[   54s]             """
[   54s]             if name and name.endswith(")") and ".a(" in name:
[   54s]                 mode |= ( _os.RTLD_MEMBER | _os.RTLD_NOW )
[   54s]         if _os.name == "nt":
[   54s]             if winmode is not None:
[   54s]                 mode = winmode
[   54s]             else:
[   54s]                 import nt
[   54s]                 mode = nt._LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
[   54s]                 if '/' in name or '\\' in name:
[   54s]                     self._name = nt._getfullpathname(self._name)
[   54s]                     mode |= nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
[   54s]     
[   54s]         class _FuncPtr(_CFuncPtr):
[   54s]             _flags_ = flags
[   54s]             _restype_ = self._func_restype_
[   54s]         self._FuncPtr = _FuncPtr
[   54s]     
[   54s]         if handle is None:
[   54s] >           self._handle = _dlopen(self._name, mode)
[   54s] E           OSError: /lib64/libo2scl.so.0: undefined symbol: GOMP_critical_name_end
[   54s] 
[   54s] /usr/lib64/python3.10/ctypes/__init__.py:374: OSError
[   54s] =========================== short test summary info ============================
[   54s] FAILED o2sclpy/test/test_cpp_class.py::test_all - OSError: /lib64/libo2scl.so...
[   54s] FAILED o2sclpy/test/test_den_plot.py::test_all - OSError: /lib64/libo2scl.so....
[   54s] FAILED o2sclpy/test/test_lib_settings.py::test_all - OSError: /lib64/libo2scl...
[   54s] FAILED o2sclpy/test/test_table.py::test_all - OSError: /lib64/libo2scl.so.0: ...
[   54s] FAILED o2sclpy/test/test_table3d.py::test_all - OSError: /lib64/libo2scl.so.0...
[   54s] FAILED o2sclpy/test/test_table_units.py::test_all - OSError: /lib64/libo2scl....
[   54s] FAILED o2sclpy/test/test_tensor.py::test_all - OSError: /lib64/libo2scl.so.0:...
[   54s] FAILED o2sclpy/test/test_tensor_grid.py::test_all - OSError: /lib64/libo2scl....
[   54s] FAILED o2sclpy/test/test_ug.py::test_all - OSError: /lib64/libo2scl.so.0: und...
[   54s] ================== 9 failed, 8 passed, 1 deselected in 3.82s ===================
[   54s] error: Bad exit status from /var/tmp/rpm-tmp.5bV0PQ (%check)

The full build log is attached at the end.

I managed to workaround the issue by building O₂SCL with "-lgomp" added to the configured LDFLAGS. We build O₂SCL with openmp enabled and this automatically adds -fopenmp to the GCC compile/linking flags but apparently that is not enough when ld is used as the linker to link external code against the thus built libo2scl.so. There is some discussion about the openmp issue here: https://stackoverflow.com/questions/25795944/python-ctypes-error-gomp-critical-end-when-loading-library.

Perhaps, the configure script should add the -lgomp to the linker list for Linux OS when openmp is enabled?

Thanks in advance.

o2sclpy-gomp-error.log.zip

@awsteiner
Copy link
Owner

I think this can be alleviated by setting the environment variable O2SCL_ADDL_LIBS to /usr/lib64/libgomp.so.1 . I don't know why python ctypes DLL doesn't automatically detect libgomp as well as it does other system libraries. I'm making progress at https://github.com/awsteiner/o2scl/blob/dev/docker/v0.929_ot_py . However, I'm still having trouble with tensorflow and h5py. On my Ubuntu docker file, I fixed this by installing hdf5 from source, but this is obviously not a good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants