Python extension Linux: build RHEL9-portable (GCC 11 + static Boost/libstdc++) - #96
Merged
Merged
Conversation
SicongLiu2000
force-pushed
the
dev/sicongliu/exthost-v3-toolchain
branch
from
July 18, 2026 03:15
1fde6dd to
d8d3350
Compare
SicongLiu2000
marked this pull request as draft
July 20, 2026 19:43
…ibstdc++) Make libPythonExtension.so loadable on RHEL9 (glibc 2.34) as well as newer distros: - restore-packages.sh: GCC 13 -> GCC 11 (native on Ubuntu 22.04; GLIBCXX_3.4.29 / glibc 2.35). GCC 13 emitted GLIBCXX_3.4.32 + glibc 2.38 refs (_dl_find_object, arc4random, __isoc23_*) RHEL9 cannot satisfy, so the extension failed to load there. - python/src/CMakeLists.txt: static-link libstdc++/libgcc (-Wl,--exclude-libs,ALL) and Boost.Python/Boost.NumPy (.a via NO_DEFAULT_PATH) so the .so is self-contained. ELF-verified: DT_NEEDED = libpython3.12 + libc/ld only; no GLIBCXX; max GLIBC 2.34. PVS PythonExtension: Ubuntu2404 604/604, Rhel9 613/613, Rhel10 594/594.
SicongLiu2000
force-pushed
the
dev/sicongliu/exthost-v3-toolchain
branch
from
July 20, 2026 21:02
d8d3350 to
e9f2af8
Compare
SicongLiu2000
marked this pull request as ready for review
July 20, 2026 21:56
There was a problem hiding this comment.
Pull request overview
This PR updates the Linux build/link configuration for the SQL Server Python language extension (libPythonExtension.so) to improve binary portability down to the RHEL 9 baseline by lowering toolchain/libstdc++ symbol requirements and eliminating runtime Boost dependencies.
Changes:
- Switch the Linux build toolchain to GCC 11 via package restore/setup.
- Statically link
libstdc++/libgccinto the extension and hide those symbols from interposition. - Force static Boost.Python / Boost.NumPy linkage from the provided Boost build root to avoid external Boost
.sodependencies.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
restore-packages.sh |
Pins the build compiler to GCC 11 via apt + update-alternatives. |
language-extensions/python/src/CMakeLists.txt |
Updates Linux linker flags for static libstdc++/libgcc and switches Boost discovery to static archives. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SicongLiu2000
requested review from
Aniruddh Munde (Aniruddh25) and
MHN (monamaki)
July 21, 2026 18:51
Aniruddh Munde (Aniruddh25)
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The SQL Server Python language extension ships as a single Linux shared object (
libPythonExtension.so) that SQL Server loads at runtime across every supported distro. This PR makes that.soportable down to RHEL 9 — our oldest in-support Linux baseline — while keeping it loadable on all newer distros (RHEL 10, Ubuntu 22.04/24.04, Azure Linux 3). It does so by pinning the build toolchain and self-containing the extension's C++/Boost dependencies, with no change to extension behavior or its public surface.Background & motivation
A language extension is only useful if it loads on the customer's distro. Because a single artifact is shipped to all of them, it must reference only symbols present on the lowest common baseline (RHEL 9 — glibc 2.34). Built on the newer default image, the extension picked up newer
glibc/libstdc++symbol versions that RHEL 9 does not provide, so it failed to load there. The goal of this change is a single, self-contained.sowhose external contract is limited to the RHEL 9 baseline.Approach
Two complementary changes, both confined to the Python extension's Linux build:
Pin the compiler to GCC 11. We build the extension with GCC 11 because we need to support RHEL 9. GCC 11 is native to the Ubuntu 22.04 build image and produces a
libstdc++/glibcsymbol floor compatible with RHEL 9 and everything newer.Self-contain the C++/Boost dependencies. Statically link
libstdc++/libgccand Boost (Boost.Python / Boost.NumPy) into the extension so the shipped.socarries no externallibstdc++or Boost runtime dependency. This removes the whole class of "works on the build image, missing on the target distro" load failures rather than papering over one symbol.Changes
restore-packages.sh— install/use GCC 11 instead of GCC 13 for the extension build.language-extensions/python/src/CMakeLists.txtlibstdc++/libgcc:-static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL— the.sono longer requires a newer systemlibstdc++at load time..aviaNO_DEFAULT_PATH) so the.socarries no external Boost dependency.Net diff is small and localized to the Python extension's Linux link/toolchain; the extension's code, ABI to SQL Server, and Python 3.12 runtime are unchanged.
Verification
ELF (link-level, the contract we actually ship):
DT_NEEDED=libpython3.12+libc/ld-linuxonly — zero Boost, nolibstdc++.GLIBCXXversion dependency at all.GLIBC= 2.34 (the RHEL 9 baseline).End-to-end (PVS PythonExtension suite, per distro):
Risk / compatibility
libstdc++/libgcc/Boost slightly increases the.sosize but eliminates runtime dependency drift across distros — a net reliability win for shipping one artifact everywhere.