Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a check on Linux to ensure the host system has glibc 2.34 or later before using prebuilt libraries in fetch build mode, falling back to a build error with a hint to use buildMode: checkout on unsupported systems (such as Alpine Linux with musl). Feedback on the tests suggests making the glibc detection test more robust, as it currently assumes the host environment running the tests will always have a compatible glibc version, which may cause failures on Alpine Linux or older distributions.
| 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 assumes that any Linux environment running the tests will have a glibc version of at least 2.34. However, this package is designed to support other Linux environments (like Alpine Linux with musl, or older Ubuntu distributions with glibc < 2.34) by falling back to compiling from source. Running dart test on those platforms will cause this test to fail. We should make the test robust to these environments by only asserting the version structure if glibc is detected, without assuming its presence or a specific minimum version.
if (Platform.isLinux) {
// On Linux, the host may use glibc (which might be older than 2.34) or another libc like musl.
if (version != null) {
final (major, minor) = version;
expect(major, greaterThan(0));
expect(minor, greaterThanOrEqualTo(0));
}
} else {
expect(version, isNull);
}56ca107 to
a000c1c
Compare
a000c1c to
e241a3e
Compare
…ux libraries The prebuilt Linux libraries are built on Ubuntu 22.04, the oldest Ubuntu that GitHub Actions has, so they require glibc 2.34, for the pthread functions that moved into libc in 2.34. The README didn't say so, and the libraries are picked by OS and architecture only, so they failed to load on older distributions and on other C libraries, such as musl on Alpine Linux. - List the requirement in the README. - 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.34, instead of bundling a library that fails to load. - Tighten the ABI check of the binaries workflow from 2.35 to 2.34, what the libraries need today, so the requirement can't silently grow.
806435c to
e2bd58b
Compare
Note
This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.
Important
Stacked on #2893, which is its base branch. CI runs once #2893 lands and GitHub retargets this PR. This replaces #2894, which built the libraries in containers.
Part of a stack of
package:boringfixes:BN_ULONGasUintPtr(merged)OPENSSL_SMALLmoved to #2910, which is independent of this stack.The prebuilt Linux libraries are built on Ubuntu 22.04, the oldest Ubuntu runner GitHub Actions has.
objdump -Tshows that both the x64 and the arm64 library require glibc 2.34, because pthread functions such aspthread_key_createmoved into libc in that version. The README didn't say so, and the prebuilt library is picked by OS and architecture only. So on older distributions (Debian 11, Ubuntu 20.04, RHEL 8) and on other C libraries (musl on Alpine Linux),fetchbundled a library that failed to load at run time.package:webcryptoused to compile BoringSSL on the user's machine, so it worked on all of these.This PR doesn't change how the libraries are built. It makes the requirement explicit:
buildMode: checkout.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.34, it fails with aBuildErrorand thebuildMode: checkouthint, like for other targets without prebuilt libraries. When cross-compiling, the target's C library isn't known, so the hook doesn't check it.boring_binaries.yamlgoes from 2.35 to 2.34, what the libraries need today, so a runner or toolchain change can't silently raise the requirement.prebuiltLinuxGlibcinlib/src/hook_helpers/libc.dartand the README must stay in sync with it.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).