Skip to content

[boring] Run the prebuilt Linux libraries on glibc 2.28, and detect other C libraries - #2894

Closed
mosuem wants to merge 1 commit into
boring-build-optionsfrom
boring-linux-glibc-floor
Closed

mosuem wants to merge 1 commit into
boring-build-optionsfrom
boring-linux-glibc-floor

Conversation

@mosuem

@mosuem mosuem commented Nov 17, 2026

Copy link
Copy Markdown
Member

Note

This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.

Important

Stacked on #2893, which is its base branch. The workflows only run for pull requests into main, so CI, including the precompile jobs that exercise the new containers, runs once #2893 lands and GitHub retargets this PR.

Third of a stack of three package:boring fixes:

  1. [boring] Bind BN_ULONG as UintPtr #2892: bind BN_ULONG as UintPtr
  2. [boring] Compile with OPENSSL_SMALL and the sanitizer of the Dart runtime #2893: compile with OPENSSL_SMALL and the sanitizer of the Dart runtime
  3. This PR: run the prebuilt Linux libraries on glibc 2.28, and detect other C libraries

The prebuilt Linux libraries are built on Ubuntu 22.04. objdump -T shows they require glibc 2.34, because pthread functions such as pthread_key_create moved into libc in that version. So they fail to load on Debian 11, Ubuntu 20.04, RHEL/Rocky 8, and other older distributions. They also fail to load on musl, such as on Alpine Linux, because the prebuilt library is picked by OS and architecture only. package:webcrypto compiled BoringSSL on the user's machine, so it worked on all of these.

Older glibc

  • The Linux precompile jobs run in quay.io/pypa/manylinux_2_28_{x86_64,aarch64} (AlmaLinux 8) containers. They provide GCC, CMake, and Make, and only unzip is installed for setup-dart. The Dart SDK only needs glibc 2.18.
  • The ABI check now requires the libraries to need at most glibc 2.28. That covers Debian 10+, Ubuntu 20.04+, and RHEL 8+.
  • Older glibc can't run the actions' Node.js in the container, so manylinux2014 (glibc 2.17) isn't an option without bigger changes.

Other C libraries

In the fetch build mode, when building for the Linux machine the hook runs on (dart run, dart test), the hook calls gnu_get_libc_version() through DynamicLibrary.process(). On musl, or on glibc older than 2.28, it fails with a BuildError and a hint to use buildMode: checkout, like for other targets without prebuilt libraries, instead of bundling a library that fails to load. When cross-compiling, the target's C library isn't known, so the hook doesn't check it.

Testing

test/hook_helpers_test.dart covers parsing, the version floor, musl, and the C library of the test machine. Locally on Linux x64, dart test passes (38 passed, 5 skipped).

This overlaps with #2866 and #2617, which rework how prebuilt libraries are fetched and built. Whichever lands second needs to move the libc check and the container setup.

…ther C libraries

The prebuilt Linux libraries were built on Ubuntu 22.04, so they required
glibc 2.34 (pthread functions that moved into libc), and failed to load on,
for example, Debian 11, Ubuntu 20.04, and RHEL 8. They also failed to load on
musl, such as on Alpine Linux, because the prebuilt library is picked by OS
and architecture only.

- Build the Linux libraries in manylinux_2_28 (AlmaLinux 8) containers, and
  check that they only require glibc 2.28. Older glibc can't run the actions'
  Node.js in the container.
- In the `fetch` build mode, when building for the Linux machine the hook runs
  on, check its C library with gnu_get_libc_version(), and fail with a hint to
  use `buildMode: checkout` on musl or glibc older than 2.28, instead of
  bundling a library that fails to load.
@mosuem
mosuem requested a review from a team as a code owner November 17, 2026 15:13
@github-actions github-actions Bot added type-infra A repository infrastructure change or enhancement package:boring labels Nov 17, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces glibc version detection on Linux to ensure that prebuilt BoringSSL libraries are only loaded on compatible systems (glibc 2.28 or later, excluding musl-based systems like Alpine Linux). It adds a new libc.dart helper, integrates compatibility checks into the prebuilt library fetch process, updates documentation, and adds corresponding unit tests. The review feedback recommends importing dart:ffi in the test file and dynamically checking for the presence of the gnu_get_libc_version symbol instead of assuming all Linux environments run glibc, which prevents test failures on non-glibc Linux distributions.

import 'package:boring/src/hook_helpers/build_options.dart';
import 'package:boring/src/hook_helpers/fetch.dart';
import 'package:boring/src/hook_helpers/hashes.dart';
import 'package:boring/src/hook_helpers/libc.dart';

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.

high

To use DynamicLibrary in the test to robustly detect glibc presence, we need to import dart:ffi.

Suggested change
import 'package:boring/src/hook_helpers/libc.dart';
import 'dart:ffi';
import 'package:boring/src/hook_helpers/libc.dart';

Comment on lines +163 to +172
test('finds the glibc of this process', () {
final version = currentGlibcVersion();
if (Platform.isLinux) {
// The CI runners use glibc.
expect(version, isNotNull);
expect(unsupportedLinuxLibcReason(version), isNull);
} else {
expect(version, isNull);
}
});

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.

high

The test currently assumes that any Linux platform runs glibc (Platform.isLinux implies version != null). However, on non-glibc Linux distributions (such as Alpine Linux which uses musl), currentGlibcVersion() will return null, causing this test to fail. Since this PR specifically aims to support and detect non-glibc environments, the test should be robust against them.

Instead of checking Platform.isLinux, we can check if the process actually provides the gnu_get_libc_version symbol.

Suggested change
test('finds the glibc of this process', () {
final version = currentGlibcVersion();
if (Platform.isLinux) {
// The CI runners use glibc.
expect(version, isNotNull);
expect(unsupportedLinuxLibcReason(version), isNull);
} else {
expect(version, isNull);
}
});
test('finds the glibc of this process', () {
final version = currentGlibcVersion();
final hasGlibc = DynamicLibrary.process().providesSymbol('gnu_get_libc_version');
if (hasGlibc) {
expect(version, isNotNull);
expect(unsupportedLinuxLibcReason(version), isNull);
} else {
expect(version, isNull);
}
});

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

Labels

package:boring type-infra A repository infrastructure change or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant