Skip to content

Build Linux releases against glibc 2.27 baseline for compatibility - #5332

Open
Gabriel Dufresne (GabrielDuf) wants to merge 1 commit into
mainfrom
fix/linux-glibc-baseline
Open

Build Linux releases against glibc 2.27 baseline for compatibility#5332
Gabriel Dufresne (GabrielDuf) wants to merge 1 commit into
mainfrom
fix/linux-glibc-baseline

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request introduces significant improvements to the Linux build and packaging process, primarily to ensure compatibility with older distributions by enforcing a minimum glibc version requirement. It adds a verification step for glibc dependencies, updates the packaging scripts to record the required glibc version, and transitions Linux builds to use cross-compilation containers for more reliable and reproducible results. Documentation has also been updated to inform users of the new glibc baseline.

Build process improvements:

  • Added an environment variable LINUX_GLIBC_BASELINE (set to 2.27) to .github/workflows/build-release.yml to define the minimum supported glibc version for Linux builds.
  • Replaced the manual installation of cross-compilation toolchains with Docker-based cross-build images for both x64 and arm64 Linux targets, improving consistency and reducing complexity.
  • Modified the build workflow to run Linux publish steps inside the cross-build container, while non-Linux runners continue to use the existing process.

glibc compatibility verification:

  • Added a new script scripts/check-linux-glibc.ps1 that inspects built binaries to determine the highest required glibc version, and integrated it into the build workflow to verify that the glibc requirement does not exceed the baseline.
  • Updated scripts/package-linux.ps1 to detect the minimum required glibc version from the built binaries and record it in the .deb package's dependencies, ensuring package managers enforce the requirement.

Documentation update:

  • Updated the Linux section of README.md to clearly state that binaries require glibc 2.27 or newer, listing compatible distributions and describing the error shown on older systems.

NativeAOT binaries inherit the glibc symbol versions of the machine that
links them. Both Linux legs built on ubuntu-latest (glibc 2.39), so RyuJIT's
direct fmod/fmodf references (dotnet/runtime@503970c) bound to GLIBC_2.38 and
the app died at startup with "libm.so.6: version `GLIBC_2.38' not found" on
Ubuntu 22.04, Debian 12, RHEL 8/9, Amazon Linux 2023 and Fedora <= 38. Those
two symbols were the only references above 2.34 on either architecture.

Publish the Linux legs inside .NET's official cross-build image, whose
/crossrootfs is built from Ubuntu 18.04, so every reference resolves against
glibc 2.27. This also replaces the hand-rolled ubuntu-ports arm64 toolchain
setup, since the image carries the arm64 rootfs. The SDK tag is read from
global.json so the container does not drift off the pinned 10.0.103 the way
mcr.microsoft.com/dotnet/sdk:10.0 (now 10.0.400) would, and the Android and
GHC toolchains are reclaimed to leave room for the ~6 GB image.

check-linux-glibc.ps1 fails the build when any shipped binary requires more
than LINUX_GLIBC_BASELINE, so a future runner-image bump cannot silently
raise the floor again. package-linux.ps1 feeds the same detection into a
Depends: libc6 (>= x.y) field, so apt refuses to install a package the system
cannot run instead of installing one that dies on launch; rpm already derived
this from its automatic ELF requires.

Fixes #5250

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Builds Linux releases against a glibc 2.27 baseline and verifies/package-records compatibility.

Changes:

  • Uses reproducible x64/arm64 cross-build containers.
  • Adds glibc requirement verification and Debian dependency metadata.
  • Documents supported Linux distributions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
.github/workflows/build-release.yml Cross-builds and verifies Linux artifacts.
scripts/check-linux-glibc.ps1 Detects and validates required glibc versions.
scripts/package-linux.ps1 Adds the detected libc6 dependency.
README.md Documents the glibc baseline.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants