Repository navigation
Conversation
…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.
There was a problem hiding this comment.
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'; |
| 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); | ||
| } | ||
| }); |
There was a problem hiding this comment.
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.
| 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); | |
| } | |
| }); |
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 theprecompilejobs that exercise the new containers, runs once #2893 lands and GitHub retargets this PR.Third of a stack of three
package:boringfixes:BN_ULONGasUintPtrOPENSSL_SMALLand the sanitizer of the Dart runtimeThe prebuilt Linux libraries are built on Ubuntu 22.04.
objdump -Tshows they require glibc 2.34, because pthread functions such aspthread_key_createmoved 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:webcryptocompiled BoringSSL on the user's machine, so it worked on all of these.Older glibc
precompilejobs run inquay.io/pypa/manylinux_2_28_{x86_64,aarch64}(AlmaLinux 8) containers. They provide GCC, CMake, and Make, and onlyunzipis installed forsetup-dart. The Dart SDK only needs glibc 2.18.Other C libraries
In the
fetchbuild mode, when building for the Linux machine the hook runs on (dart run,dart test), the hook callsgnu_get_libc_version()throughDynamicLibrary.process(). On musl, or on glibc older than 2.28, it fails with aBuildErrorand a hint to usebuildMode: 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.dartcovers parsing, the version floor, musl, and the C library of the test machine. Locally on Linux x64,dart testpasses (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.