Skip to content
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
11 changes: 3 additions & 8 deletions language-extensions/python/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ if (${PLATFORM} STREQUAL linux)

target_compile_options(PythonExtension PRIVATE -Wall -Wextra -g -O2 -fPIC -Werror -std=c++17 -Wno-unused-parameter -Wno-maybe-uninitialized -fshort-wchar)

# Static-link libstdc++/libgcc so libPythonExtension.so does not require a newer system
# GLIBCXX at load time (RHEL9 ships libstdc++ without GLIBCXX_3.4.32). --exclude-libs,ALL
# localizes the statically-linked symbols so they do not interpose the C++ host runtime.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed -Wl,--export-dynamic -fopenmp -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed -Wl,--export-dynamic -fopenmp")

# Prefer shared libraries over static libraries
set(CMAKE_FIND_LIBRARY_SUFFIXES .so .so.1.0 ${CMAKE_FIND_LIBRARY_SUFFIXES})
Expand All @@ -75,10 +72,8 @@ if (${PLATFORM} STREQUAL linux)
message(STATUS "Shared Python library not found in standard locations, trying system default search")
find_library(PYTHON_LIB python${PYTHON_VERSION})
endif()
# Static-link Boost.Python/Boost.NumPy from the from-source boost root so
# libPythonExtension.so is self-contained (no external boost .so; portable across distros).
find_library(BOOST_PYTHON_LIB NAMES libboost_python${PYTHON_VERSION_NO_DOT}.a PATHS ${BOOST_PYTHON_ROOT} NO_DEFAULT_PATH)
find_library(BOOST_NUMPY_LIB NAMES libboost_numpy${PYTHON_VERSION_NO_DOT}.a PATHS ${BOOST_PYTHON_ROOT} NO_DEFAULT_PATH)
find_library(BOOST_PYTHON_LIB boost_python${PYTHON_VERSION_NO_DOT} ${BOOST_PYTHON_ROOT})
find_library(BOOST_NUMPY_LIB boost_numpy${PYTHON_VERSION_NO_DOT} ${BOOST_PYTHON_ROOT})

file(TO_CMAKE_PATH ${INCLUDE_ROOT}/python${PYTHON_VERSION} PYTHON_INCLUDE)
file(TO_CMAKE_PATH ${INCLUDE_ROOT}/boost BOOST_INCLUDE)
Expand Down
8 changes: 2 additions & 6 deletions restore-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ apt-get -q -y install unixodbc-dev

apt-get update -y
apt-get install build-essential software-properties-common -y
# Use GCC 11 (native on the Ubuntu 22.04 build image) so the extension links against
# GLIBCXX_3.4.29 / glibc 2.35 and stays loadable on RHEL9 (glibc 2.34). GCC 13 emitted
# GLIBCXX_3.4.32 and glibc 2.38 symbol references (_dl_find_object, arc4random,
# __isoc23_*) that RHEL9 cannot satisfy, so libPythonExtension.so failed to load there.
apt-get install gcc-11 g++-11 -y
apt-get install gcc-13 g++-13 -y
apt-get install cmake -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 70 --slave /usr/bin/g++ g++ /usr/bin/g++-11
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 70 --slave /usr/bin/g++ g++ /usr/bin/g++-13

exit $?