authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-30 07:55:15+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-01 23:03:15+02:00
log80c3de40b3a9b9a751200c07d7eaf4d6965ca5c2
tree7e7436822e551039d9bc84d4e4071f9f7c32af6a
parent3d7fb4f204940875e7cd9e4dd82f28c464f688e8
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test: Properly limit glibc_compat versions based on the host


1 files changed, 21 insertions(+), 4 deletions(-)

test/link/glibc_compat/build.zig+21-4
......@@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
3333 }
3434
3535 // Build & run a C test case against a sampling of supported glibc versions
36 for ([_][]const u8{
36 versions: for ([_][]const u8{
3737 // "native-linux-gnu.2.0", // fails with a pile of missing symbols.
3838 "native-linux-gnu.2.2.5",
3939 "native-linux-gnu.2.4",
......@@ -52,9 +52,14 @@ pub fn build(b: *std.Build) void {
5252 const glibc_ver = target.result.os.version_range.linux.glibc;
5353
5454 // only build test if glibc version supports the architecture
55 if (target.result.cpu.arch.isAARCH64()) {
56 if (glibc_ver.order(.{ .major = 2, .minor = 17, .patch = 0 }) == .lt) {
55 for (std.zig.target.available_libcs) |libc| {
56 if (libc.arch != target.result.cpu.arch or
57 libc.os != target.result.os.tag or
58 libc.abi != target.result.abi)
5759 continue;
60
61 if (libc.glibc_min) |min| {
62 if (glibc_ver.order(min) == .lt) continue :versions;
5863 }
5964 }
6065
......@@ -147,7 +152,7 @@ pub fn build(b: *std.Build) void {
147152 }
148153
149154 // Build & run a Zig test case against a sampling of supported glibc versions
150 for ([_][]const u8{
155 versions: for ([_][]const u8{
151156 "native-linux-gnu.2.17", // Currently oldest supported, see #17769
152157 "native-linux-gnu.2.23",
153158 "native-linux-gnu.2.28",
......@@ -161,6 +166,18 @@ pub fn build(b: *std.Build) void {
161166
162167 const glibc_ver = target.result.os.version_range.linux.glibc;
163168
169 // only build test if glibc version supports the architecture
170 for (std.zig.target.available_libcs) |libc| {
171 if (libc.arch != target.result.cpu.arch or
172 libc.os != target.result.os.tag or
173 libc.abi != target.result.abi)
174 continue;
175
176 if (libc.glibc_min) |min| {
177 if (glibc_ver.order(min) == .lt) continue :versions;
178 }
179 }
180
164181 const exe = b.addExecutable(.{
165182 .name = t,
166183 .root_module = b.createModule(.{