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 {...@@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
33 }33 }
3434
35 // Build & run a C test case against a sampling of supported glibc versions35 // Build & run a C test case against a sampling of supported glibc versions
36 for ([_][]const u8{36 versions: for ([_][]const u8{
37 // "native-linux-gnu.2.0", // fails with a pile of missing symbols.37 // "native-linux-gnu.2.0", // fails with a pile of missing symbols.
38 "native-linux-gnu.2.2.5",38 "native-linux-gnu.2.2.5",
39 "native-linux-gnu.2.4",39 "native-linux-gnu.2.4",
...@@ -52,9 +52,14 @@ pub fn build(b: *std.Build) void {...@@ -52,9 +52,14 @@ pub fn build(b: *std.Build) void {
52 const glibc_ver = target.result.os.version_range.linux.glibc;52 const glibc_ver = target.result.os.version_range.linux.glibc;
5353
54 // only build test if glibc version supports the architecture54 // only build test if glibc version supports the architecture
55 if (target.result.cpu.arch.isAARCH64()) {55 for (std.zig.target.available_libcs) |libc| {
56 if (glibc_ver.order(.{ .major = 2, .minor = 17, .patch = 0 }) == .lt) {56 if (libc.arch != target.result.cpu.arch or
57 libc.os != target.result.os.tag or
58 libc.abi != target.result.abi)
57 continue;59 continue;
60
61 if (libc.glibc_min) |min| {
62 if (glibc_ver.order(min) == .lt) continue :versions;
58 }63 }
59 }64 }
6065
...@@ -147,7 +152,7 @@ pub fn build(b: *std.Build) void {...@@ -147,7 +152,7 @@ pub fn build(b: *std.Build) void {
147 }152 }
148153
149 // Build & run a Zig test case against a sampling of supported glibc versions154 // Build & run a Zig test case against a sampling of supported glibc versions
150 for ([_][]const u8{155 versions: for ([_][]const u8{
151 "native-linux-gnu.2.17", // Currently oldest supported, see #17769156 "native-linux-gnu.2.17", // Currently oldest supported, see #17769
152 "native-linux-gnu.2.23",157 "native-linux-gnu.2.23",
153 "native-linux-gnu.2.28",158 "native-linux-gnu.2.28",
...@@ -161,6 +166,18 @@ pub fn build(b: *std.Build) void {...@@ -161,6 +166,18 @@ pub fn build(b: *std.Build) void {
161166
162 const glibc_ver = target.result.os.version_range.linux.glibc;167 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
164 const exe = b.addExecutable(.{181 const exe = b.addExecutable(.{
165 .name = t,182 .name = t,
166 .root_module = b.createModule(.{183 .root_module = b.createModule(.{