Skip to content

Python extension Linux: build RHEL9-portable (GCC 11 + static Boost/libstdc++) - #96

Merged
SicongLiu2000 merged 1 commit into
mainfrom
dev/sicongliu/exthost-v3-toolchain
Jul 21, 2026
Merged

SicongLiu2000 merged 1 commit into
mainfrom
dev/sicongliu/exthost-v3-toolchain

Conversation

@SicongLiu2000

@SicongLiu2000 SicongLiu2000 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

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 .so portable 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 .so whose external contract is limited to the RHEL 9 baseline.

Approach

Two complementary changes, both confined to the Python extension's Linux build:

  1. 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++/glibc symbol floor compatible with RHEL 9 and everything newer.

  2. Self-contain the C++/Boost dependencies. Statically link libstdc++/libgcc and Boost (Boost.Python / Boost.NumPy) into the extension so the shipped .so carries no external libstdc++ 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.txt
    • Static-link libstdc++ / libgcc: -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL — the .so no longer requires a newer system libstdc++ at load time.
    • Static-link Boost (.a via NO_DEFAULT_PATH) so the .so carries 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-linux only — zero Boost, no libstdc++.
  • No GLIBCXX version dependency at all.
  • Max referenced GLIBC = 2.34 (the RHEL 9 baseline).

End-to-end (PVS PythonExtension suite, per distro):

  • Ubuntu 22.04/24.04, RHEL 9, RHEL 10 — all green, full pass counts, 0 causality fail-warnings.

Risk / compatibility

  • No functional or API change — same extension, same Python 3.12, same behavior; only the link/toolchain baseline moves down.
  • Static-linking libstdc++/libgcc/Boost slightly increases the .so size but eliminates runtime dependency drift across distros — a net reliability win for shipping one artifact everywhere.

@SicongLiu2000
SicongLiu2000 force-pushed the dev/sicongliu/exthost-v3-toolchain branch from 1fde6dd to d8d3350 Compare July 18, 2026 03:15
@SicongLiu2000
SicongLiu2000 changed the base branch from dev/sicongliu/linuxTest to main July 18, 2026 03:15
@SicongLiu2000
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
SicongLiu2000 force-pushed the dev/sicongliu/exthost-v3-toolchain branch from d8d3350 to e9f2af8 Compare July 20, 2026 21:02
@SicongLiu2000
SicongLiu2000 marked this pull request as ready for review July 20, 2026 21:56
Copilot AI review requested due to automatic review settings July 20, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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++/libgcc into 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 .so dependencies.

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.

Comment thread restore-packages.sh
Comment thread language-extensions/python/src/CMakeLists.txt
Comment thread language-extensions/python/src/CMakeLists.txt
@SicongLiu2000
SicongLiu2000 added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 049f13c Jul 21, 2026
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants