From a2b0e631561dc74a2027116b6945f724156b84d9 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Wed, 8 May 2024 23:59:11 +0200 Subject: [PATCH] chore!: pin the default glibc version to 2.17 This is reportedly the lowest glibc version number that Zig's own standard library supports, see https://github.com/ziglang/zig/blob/0.12.0/lib/libc/glibc/README.md?plain=1#L33-L34. Note, users can configure their own glibc version, see https://github.com/aherrmann/rules_zig/pull/169. Without this change the test at `//zig/runfiles:test` failed on the BuildBuddy default remote execution Docker image with an error of the form ``` /buildbuddy/remotebuilds/ace1eb7e-d203-470d-978b-3e7634972e45/bazel-out/k8-fastbuild/bin/zig/runfiles/test.runfiles/_main/zig/runfiles/test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /buildbuddy/remotebuilds/ace1eb7e-d203-470d-978b-3e7634972e45/bazel-out/k8-fastbuild/bin/zig/runfiles/test.runfiles/_main/zig/runfiles/test) ``` BREAKING CHANGE: The default glibc version is now pinned at 2.17. --- e2e/workspace/location-expansion/main.zig | 5 +++-- zig/target/BUILD.bazel | 8 ++++---- zig/tests/target_platform_test.bzl | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/e2e/workspace/location-expansion/main.zig b/e2e/workspace/location-expansion/main.zig index 368d4ea3..d0075d82 100644 --- a/e2e/workspace/location-expansion/main.zig +++ b/e2e/workspace/location-expansion/main.zig @@ -22,9 +22,10 @@ test "-DTARGET is set" { test "-DZIG_TARGET is set" { const actual_target = try builtin.target.linuxTriple(std.testing.allocator); defer std.testing.allocator.free(actual_target); - try std.testing.expectEqualStrings( - actual_target, + // TODO revert to an equality check. + try std.testing.expectStringStartsWith( std.mem.sliceTo(zig_target, 0), + actual_target, ); } diff --git a/zig/target/BUILD.bazel b/zig/target/BUILD.bazel index b6d112de..d2be014d 100644 --- a/zig/target/BUILD.bazel +++ b/zig/target/BUILD.bazel @@ -53,7 +53,7 @@ toolchain( zig_target_toolchain( name = "x86_32-linux-gnu", - target = "x86-linux-gnu", + target = "x86-linux-gnu.2.17", ) toolchain( @@ -112,7 +112,7 @@ toolchain( zig_target_toolchain( name = "x86_64-linux-gnu", - target = "x86_64-linux-gnu", + target = "x86_64-linux-gnu.2.17", ) toolchain( @@ -160,7 +160,7 @@ toolchain( zig_target_toolchain( name = "ppc-linux-gnu", - target = "powerpc-linux-gnu", + target = "powerpc-linux-gnu.2.17", ) toolchain( @@ -219,7 +219,7 @@ toolchain( zig_target_toolchain( name = "aarch64-linux-gnu", - target = "aarch64-linux-gnu", + target = "aarch64-linux-gnu.2.17", ) toolchain( diff --git a/zig/tests/target_platform_test.bzl b/zig/tests/target_platform_test.bzl index 70f4ee95..5fb0a110 100644 --- a/zig/tests/target_platform_test.bzl +++ b/zig/tests/target_platform_test.bzl @@ -37,9 +37,9 @@ def _define_target_platform_test(target, option): config_settings = {_TARGET_PLATFORM: target}, ) -_target_platform_x86_64_linux_test = _define_target_platform_test(_PLATFORM_X86_64_LINUX, "x86_64-linux-gnu") +_target_platform_x86_64_linux_test = _define_target_platform_test(_PLATFORM_X86_64_LINUX, "x86_64-linux-gnu.2.17") _target_platform_x86_64_linux_musl_test = _define_target_platform_test(_PLATFORM_X86_64_LINUX_MUSL, "x86_64-linux-musl") -_target_platform_aarch64_linux_test = _define_target_platform_test(_PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu") +_target_platform_aarch64_linux_test = _define_target_platform_test(_PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu.2.17") _target_platform_aarch64_linux_none_test = _define_target_platform_test(_PLATFORM_AARCH64_LINUX_NONE, "aarch64-linux-none") _target_platform_x86_64_windows_test = _define_target_platform_test(_PLATFORM_X86_64_WINDOWS, "x86_64-windows-gnu") _target_platform_x86_64_windows_none_test = _define_target_platform_test(_PLATFORM_X86_64_WINDOWS_NONE, "x86_64-windows-none") @@ -59,30 +59,30 @@ def _define_build_target_platform_test(mnemonic, target, option): config_settings = {_TARGET_PLATFORM: target}, ) -_build_exe_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu") +_build_exe_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu.2.17") _build_exe_target_platform_x86_64_linux_musl_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_X86_64_LINUX_MUSL, "x86_64-linux-musl") -_build_exe_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu") +_build_exe_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu.2.17") _build_exe_target_platform_aarch64_linux_none_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_AARCH64_LINUX_NONE, "aarch64-linux-none") _build_exe_target_platform_x86_64_windows_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_X86_64_WINDOWS, "x86_64-windows-gnu") _build_exe_target_platform_x86_64_windows_none_test = _define_build_target_platform_test("ZigBuildExe", _PLATFORM_X86_64_WINDOWS_NONE, "x86_64-windows-none") -_build_lib_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu") +_build_lib_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu.2.17") _build_lib_target_platform_x86_64_linux_musl_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_X86_64_LINUX_MUSL, "x86_64-linux-musl") -_build_lib_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu") +_build_lib_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu.2.17") _build_lib_target_platform_aarch64_linux_none_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_AARCH64_LINUX_NONE, "aarch64-linux-none") _build_lib_target_platform_x86_64_windows_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_X86_64_WINDOWS, "x86_64-windows-gnu") _build_lib_target_platform_x86_64_windows_none_test = _define_build_target_platform_test("ZigBuildLib", _PLATFORM_X86_64_WINDOWS_NONE, "x86_64-windows-none") -_build_shared_lib_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu") +_build_shared_lib_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu.2.17") _build_shared_lib_target_platform_x86_64_linux_musl_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_X86_64_LINUX_MUSL, "x86_64-linux-musl") -_build_shared_lib_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu") +_build_shared_lib_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu.2.17") _build_shared_lib_target_platform_aarch64_linux_none_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_AARCH64_LINUX_NONE, "aarch64-linux-none") _build_shared_lib_target_platform_x86_64_windows_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_X86_64_WINDOWS, "x86_64-windows-gnu") _build_shared_lib_target_platform_x86_64_windows_none_test = _define_build_target_platform_test("ZigBuildSharedLib", _PLATFORM_X86_64_WINDOWS_NONE, "x86_64-windows-none") -_build_test_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu") +_build_test_target_platform_x86_64_linux_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_X86_64_LINUX, "x86_64-linux-gnu.2.17") _build_test_target_platform_x86_64_linux_musl_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_X86_64_LINUX_MUSL, "x86_64-linux-musl") -_build_test_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu") +_build_test_target_platform_aarch64_linux_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_AARCH64_LINUX, "aarch64-linux-gnu.2.17") _build_test_target_platform_aarch64_linux_none_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_AARCH64_LINUX_NONE, "aarch64-linux-none") _build_test_target_platform_x86_64_windows_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_X86_64_WINDOWS, "x86_64-windows-gnu") _build_test_target_platform_x86_64_windows_none_test = _define_build_target_platform_test("ZigBuildTest", _PLATFORM_X86_64_WINDOWS_NONE, "x86_64-windows-none")