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

Attempt to remove the RTLD_GLOBAL hack #197

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

project(heyoka.py VERSION 6.0.0 LANGUAGES CXX C)
project(heyoka.py VERSION 6.1.0 LANGUAGES CXX C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/yacma")

Expand Down Expand Up @@ -118,7 +118,7 @@ find_package(fmt REQUIRED CONFIG)
message(STATUS "fmt version: ${fmt_VERSION}")

# heyoka.
find_package(heyoka 6.0.0 REQUIRED CONFIG)
find_package(heyoka 6.1.0 REQUIRED CONFIG)

# Python.

Expand Down
2 changes: 1 addition & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Changelog
=========

6.0.1 (unreleased)
6.1.0 (unreleased)
------------------

Fix
Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Dependencies
heyoka.py has several Python and C++ dependencies. On the C++ side, heyoka.py depends on:

* the `heyoka C++ library <https://github.com/bluescarni/heyoka>`__,
version 6.0.x (**mandatory**),
version 6.1.x (**mandatory**),
* the `Boost <https://www.boost.org/>`__ C++ libraries (**mandatory**),
* the `{fmt} <https://fmt.dev/latest/index.html>`__ library (**mandatory**),
* the `TBB <https://github.com/oneapi-src/oneTBB>`__ library (**mandatory**),
Expand Down
38 changes: 2 additions & 36 deletions heyoka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,11 @@
# Version setup.
from ._version import __version__

import os as _os
import cloudpickle as _cloudpickle
from threading import Lock as _Lock

if _os.name == "posix":
# NOTE: on some platforms Python by default opens extensions
# with the RTLD_LOCAL flag, which creates problems because
# public symbols used by heyoka (e.g., sleef functions, quad
# precision math) are then not found by the LLVM jit machinery.
# Thus, before importing core, we temporarily flip on the
# RTLD_GLOBAL flag, which makes the symbols visible and
# solves these issues. Another possible approach suggested
# in the llvm discord is to manually and explicitly add
# libheyoka.so to the DL search path:
# DynamicLibrarySearchGenerator::Load(“/path/to/libheyoka.so”)
# See:
# https://docs.python.org/3/library/ctypes.html
import ctypes as _ctypes
import sys as _sys

_orig_dlopen_flags = _sys.getdlopenflags()
_sys.setdlopenflags(_orig_dlopen_flags | _ctypes.RTLD_GLOBAL)

try:
# We import the sub-modules into the root namespace.
from .core import *
finally:
# Restore the original dlopen flags whatever
# happens.
_sys.setdlopenflags(_orig_dlopen_flags)

del _ctypes
del _sys
del _orig_dlopen_flags
else:
# We import the sub-modules into the root namespace.
from .core import *

del _os
# We import the sub-modules into the root namespace.
from .core import *

# Explicitly import the submodules
# NOTE: it is *important* that the import is performed
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else
fi

# The heyoka version to be used for releases.
export HEYOKA_VERSION_RELEASE="6.0.0"
export HEYOKA_VERSION_RELEASE="6.1.0"

# Check if this is a release build.
if [[ "${GITHUB_REF}" == "refs/tags/v"* ]]; then
Expand Down
4 changes: 3 additions & 1 deletion tools/gha_osx_heyoka_head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
conda create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 'numpy<2' cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt skyfield spdlog sympy cloudpickle 'mppp=1.*'
conda create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 'numpy<2' \
cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt skyfield \
spdlog sympy cloudpickle 'mppp=1.*' 'clang<19' 'clangxx<19'
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
4 changes: 3 additions & 1 deletion tools/gha_osx_heyoka_head_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
conda create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 'numpy<2' cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt skyfield spdlog sympy cloudpickle 'mppp=1.*' numba
conda create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 'numpy<2' \
cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt skyfield \
spdlog sympy cloudpickle 'mppp=1.*' numba 'clang<19' 'clangxx<19'
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
Loading