authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-23 17:57:39+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-24 22:11:16+01:00
log24ecf45569f10743c5df6a39e6e71dcee265786a
treea2ed9bb83aa902511e10acc66d6d141b6d895e46
parent6d781e0955e7dd2b6cc17a5bb43c790e19a07ac0
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: Add Os.HurdVersionRange for Os.Tag.hurd.

This is necessary since isGnuLibC() is true for hurd, so we need to be able to represent a glibc version for it. Also add an Os.TaggedVersionRange.gnuLibCVersion() convenience function.

14 files changed, 111 insertions(+), 39 deletions(-)

lib/std/Build/Cache.zig+5
...@@ -217,6 +217,11 @@ pub const HashHelper = struct {...@@ -217,6 +217,11 @@ pub const HashHelper = struct {
217 },217 },
218 std.Target.Os.TaggedVersionRange => {218 std.Target.Os.TaggedVersionRange => {
219 switch (x) {219 switch (x) {
220 .hurd => |hurd| {
221 hh.add(hurd.range.min);
222 hh.add(hurd.range.max);
223 hh.add(hurd.glibc);
224 },
220 .linux => |linux| {225 .linux => |linux| {
221 hh.add(linux.range.min);226 hh.add(linux.range.min);
222 hh.add(linux.range.max);227 hh.add(linux.range.max);
lib/std/Target.zig+35-5
...@@ -187,7 +187,6 @@ pub const Os = struct {...@@ -187,7 +187,6 @@ pub const Os = struct {
187 .hermit,187 .hermit,
188188
189 .aix,189 .aix,
190 .hurd,
191 .rtems,190 .rtems,
192 .zos,191 .zos,
193192
...@@ -218,6 +217,7 @@ pub const Os = struct {...@@ -218,6 +217,7 @@ pub const Os = struct {
218 .vulkan,217 .vulkan,
219 => .semver,218 => .semver,
220219
220 .hurd => .hurd,
221 .linux => .linux,221 .linux => .linux,
222222
223 .windows => .windows,223 .windows => .windows,
...@@ -356,6 +356,21 @@ pub const Os = struct {...@@ -356,6 +356,21 @@ pub const Os = struct {
356 }356 }
357 };357 };
358358
359 pub const HurdVersionRange = struct {
360 range: std.SemanticVersion.Range,
361 glibc: std.SemanticVersion,
362
363 pub inline fn includesVersion(range: HurdVersionRange, ver: std.SemanticVersion) bool {
364 return range.range.includesVersion(ver);
365 }
366
367 /// Checks if system is guaranteed to be at least `version` or older than `version`.
368 /// Returns `null` if a runtime check is required.
369 pub inline fn isAtLeast(range: HurdVersionRange, ver: std.SemanticVersion) ?bool {
370 return range.range.isAtLeast(ver);
371 }
372 };
373
359 pub const LinuxVersionRange = struct {374 pub const LinuxVersionRange = struct {
360 range: std.SemanticVersion.Range,375 range: std.SemanticVersion.Range,
361 glibc: std.SemanticVersion,376 glibc: std.SemanticVersion,
...@@ -400,6 +415,7 @@ pub const Os = struct {...@@ -400,6 +415,7 @@ pub const Os = struct {
400 pub const VersionRange = union {415 pub const VersionRange = union {
401 none: void,416 none: void,
402 semver: std.SemanticVersion.Range,417 semver: std.SemanticVersion.Range,
418 hurd: HurdVersionRange,
403 linux: LinuxVersionRange,419 linux: LinuxVersionRange,
404 windows: WindowsVersion.Range,420 windows: WindowsVersion.Range,
405421
...@@ -456,9 +472,12 @@ pub const Os = struct {...@@ -456,9 +472,12 @@ pub const Os = struct {
456 },472 },
457 },473 },
458 .hurd => .{474 .hurd => .{
459 .semver = .{475 .hurd = .{
460 .min = .{ .major = 0, .minor = 9, .patch = 0 },476 .range = .{
461 .max = .{ .major = 0, .minor = 9, .patch = 0 },477 .min = .{ .major = 0, .minor = 9, .patch = 0 },
478 .max = .{ .major = 0, .minor = 9, .patch = 0 },
479 },
480 .glibc = .{ .major = 2, .minor = 28, .patch = 0 },
462 },481 },
463 },482 },
464 .linux => .{483 .linux => .{
...@@ -632,8 +651,17 @@ pub const Os = struct {...@@ -632,8 +651,17 @@ pub const Os = struct {
632 pub const TaggedVersionRange = union(enum) {651 pub const TaggedVersionRange = union(enum) {
633 none: void,652 none: void,
634 semver: std.SemanticVersion.Range,653 semver: std.SemanticVersion.Range,
654 hurd: HurdVersionRange,
635 linux: LinuxVersionRange,655 linux: LinuxVersionRange,
636 windows: WindowsVersion.Range,656 windows: WindowsVersion.Range,
657
658 pub fn gnuLibCVersion(range: TaggedVersionRange) ?std.SemanticVersion {
659 return switch (range) {
660 .none, .semver, .windows => null,
661 .hurd => |h| h.glibc,
662 .linux => |l| l.glibc,
663 };
664 }
637 };665 };
638666
639 /// Provides a tagged union. `Target` does not store the tag because it is667 /// Provides a tagged union. `Target` does not store the tag because it is
...@@ -642,6 +670,7 @@ pub const Os = struct {...@@ -642,6 +670,7 @@ pub const Os = struct {
642 return switch (os.tag.versionRangeTag()) {670 return switch (os.tag.versionRangeTag()) {
643 .none => .{ .none = {} },671 .none => .{ .none = {} },
644 .semver => .{ .semver = os.version_range.semver },672 .semver => .{ .semver = os.version_range.semver },
673 .hurd => .{ .hurd = os.version_range.hurd },
645 .linux => .{ .linux = os.version_range.linux },674 .linux => .{ .linux = os.version_range.linux },
646 .windows => .{ .windows = os.version_range.windows },675 .windows => .{ .windows = os.version_range.windows },
647 };676 };
...@@ -651,12 +680,13 @@ pub const Os = struct {...@@ -651,12 +680,13 @@ pub const Os = struct {
651 /// Returns `null` if a runtime check is required.680 /// Returns `null` if a runtime check is required.
652 pub inline fn isAtLeast(os: Os, comptime tag: Tag, ver: switch (tag.versionRangeTag()) {681 pub inline fn isAtLeast(os: Os, comptime tag: Tag, ver: switch (tag.versionRangeTag()) {
653 .none => void,682 .none => void,
654 .semver, .linux => std.SemanticVersion,683 .semver, .hurd, .linux => std.SemanticVersion,
655 .windows => WindowsVersion,684 .windows => WindowsVersion,
656 }) ?bool {685 }) ?bool {
657 return if (os.tag != tag) false else switch (tag.versionRangeTag()) {686 return if (os.tag != tag) false else switch (tag.versionRangeTag()) {
658 .none => true,687 .none => true,
659 inline .semver,688 inline .semver,
689 .hurd,
660 .linux,690 .linux,
661 .windows,691 .windows,
662 => |field| @field(os.version_range, @tagName(field)).isAtLeast(ver),692 => |field| @field(os.version_range, @tagName(field)).isAtLeast(ver),
lib/std/Target/Query.zig+5-5
...@@ -102,7 +102,7 @@ pub fn fromTarget(target: Target) Query {...@@ -102,7 +102,7 @@ pub fn fromTarget(target: Target) Query {
102 .os_version_min = undefined,102 .os_version_min = undefined,
103 .os_version_max = undefined,103 .os_version_max = undefined,
104 .abi = target.abi,104 .abi = target.abi,
105 .glibc_version = if (target.isGnuLibC()) target.os.version_range.linux.glibc else null,105 .glibc_version = target.os.versionRange().gnuLibCVersion(),
106 .android_api_level = if (target.abi.isAndroid()) target.os.version_range.linux.android else null,106 .android_api_level = if (target.abi.isAndroid()) target.os.version_range.linux.android else null,
107 };107 };
108 result.updateOsVersionRange(target.os);108 result.updateOsVersionRange(target.os);
...@@ -132,9 +132,9 @@ fn updateOsVersionRange(self: *Query, os: Target.Os) void {...@@ -132,9 +132,9 @@ fn updateOsVersionRange(self: *Query, os: Target.Os) void {
132 .{ .semver = os.version_range.semver.min },132 .{ .semver = os.version_range.semver.min },
133 .{ .semver = os.version_range.semver.max },133 .{ .semver = os.version_range.semver.max },
134 },134 },
135 .linux => .{135 inline .hurd, .linux => |t| .{
136 .{ .semver = os.version_range.linux.range.min },136 .{ .semver = @field(os.version_range, @tagName(t)).range.min },
137 .{ .semver = os.version_range.linux.range.max },137 .{ .semver = @field(os.version_range, @tagName(t)).range.max },
138 },138 },
139 .windows => .{139 .windows => .{
140 .{ .windows = os.version_range.windows.min },140 .{ .windows = os.version_range.windows.min },
...@@ -544,7 +544,7 @@ fn parseOs(result: *Query, diags: *ParseOptions.Diagnostics, text: []const u8) !...@@ -544,7 +544,7 @@ fn parseOs(result: *Query, diags: *ParseOptions.Diagnostics, text: []const u8) !
544 const version_text = it.rest();544 const version_text = it.rest();
545 if (version_text.len > 0) switch (tag.versionRangeTag()) {545 if (version_text.len > 0) switch (tag.versionRangeTag()) {
546 .none => return error.InvalidOperatingSystemVersion,546 .none => return error.InvalidOperatingSystemVersion,
547 .semver, .linux => range: {547 .semver, .hurd, .linux => range: {
548 var range_it = mem.splitSequence(u8, version_text, "...");548 var range_it = mem.splitSequence(u8, version_text, "...");
549 result.os_version_min = .{549 result.os_version_min = .{
550 .semver = parseVersion(range_it.first()) catch |err| switch (err) {550 .semver = parseVersion(range_it.first()) catch |err| switch (err) {
lib/std/c.zig+2-3
...@@ -56,9 +56,8 @@ pub inline fn versionCheck(comptime version: std.SemanticVersion) bool {...@@ -56,9 +56,8 @@ pub inline fn versionCheck(comptime version: std.SemanticVersion) bool {
56 if (!builtin.link_libc) break :blk false;56 if (!builtin.link_libc) break :blk false;
57 if (native_abi.isMusl()) break :blk true;57 if (native_abi.isMusl()) break :blk true;
58 if (builtin.target.isGnuLibC()) {58 if (builtin.target.isGnuLibC()) {
59 const ver = builtin.os.version_range.linux.glibc;59 const ver = builtin.os.versionRange().gnuLibCVersion().?;
60 const order = ver.order(version);60 break :blk switch (ver.order(version)) {
61 break :blk switch (order) {
62 .gt, .eq => true,61 .gt, .eq => true,
63 .lt => false,62 .lt => false,
64 };63 };
lib/std/zig/system.zig+8-5
...@@ -311,8 +311,8 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {...@@ -311,8 +311,8 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {
311311
312 if (query.os_version_min) |min| switch (min) {312 if (query.os_version_min) |min| switch (min) {
313 .none => {},313 .none => {},
314 .semver => |semver| switch (os.tag) {314 .semver => |semver| switch (os.tag.versionRangeTag()) {
315 .linux => os.version_range.linux.range.min = semver,315 inline .hurd, .linux => |t| @field(os.version_range, @tagName(t)).range.min = semver,
316 else => os.version_range.semver.min = semver,316 else => os.version_range.semver.min = semver,
317 },317 },
318 .windows => |win_ver| os.version_range.windows.min = win_ver,318 .windows => |win_ver| os.version_range.windows.min = win_ver,
...@@ -320,15 +320,18 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {...@@ -320,15 +320,18 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {
320320
321 if (query.os_version_max) |max| switch (max) {321 if (query.os_version_max) |max| switch (max) {
322 .none => {},322 .none => {},
323 .semver => |semver| switch (os.tag) {323 .semver => |semver| switch (os.tag.versionRangeTag()) {
324 .linux => os.version_range.linux.range.max = semver,324 inline .hurd, .linux => |t| @field(os.version_range, @tagName(t)).range.max = semver,
325 else => os.version_range.semver.max = semver,325 else => os.version_range.semver.max = semver,
326 },326 },
327 .windows => |win_ver| os.version_range.windows.max = win_ver,327 .windows => |win_ver| os.version_range.windows.max = win_ver,
328 };328 };
329329
330 if (query.glibc_version) |glibc| {330 if (query.glibc_version) |glibc| {
331 os.version_range.linux.glibc = glibc;331 switch (os.tag.versionRangeTag()) {
332 inline .hurd, .linux => |t| @field(os.version_range, @tagName(t)).glibc = glibc,
333 else => {},
334 }
332 }335 }
333336
334 if (query.android_api_level) |android| {337 if (query.android_api_level) |android| {
lib/std/zig/target.zig+2-2
...@@ -88,10 +88,10 @@ pub fn canBuildLibC(target: std.Target) bool {...@@ -88,10 +88,10 @@ pub fn canBuildLibC(target: std.Target) bool {
88 const ver = target.os.version_range.semver;88 const ver = target.os.version_range.semver;
89 return ver.min.order(libc.os_ver.?) != .lt;89 return ver.min.order(libc.os_ver.?) != .lt;
90 }90 }
91 // Ensure glibc (aka *-linux-gnu) version is supported91 // Ensure glibc (aka *-(linux,hurd)-gnu) version is supported
92 if (target.isGnuLibC()) {92 if (target.isGnuLibC()) {
93 const min_glibc_ver = libc.glibc_min orelse return true;93 const min_glibc_ver = libc.glibc_min orelse return true;
94 const target_glibc_ver = target.os.version_range.linux.glibc;94 const target_glibc_ver = target.os.versionRange().gnuLibCVersion().?;
95 return target_glibc_ver.order(min_glibc_ver) != .lt;95 return target_glibc_ver.order(min_glibc_ver) != .lt;
96 }96 }
97 return true;97 return true;
src/Builtin.zig+34
...@@ -142,6 +142,40 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {...@@ -142,6 +142,40 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
142142
143 linux.android,143 linux.android,
144 }),144 }),
145 .hurd => |hurd| try buffer.writer().print(
146 \\ .hurd = .{{
147 \\ .range = .{{
148 \\ .min = .{{
149 \\ .major = {},
150 \\ .minor = {},
151 \\ .patch = {},
152 \\ }},
153 \\ .max = .{{
154 \\ .major = {},
155 \\ .minor = {},
156 \\ .patch = {},
157 \\ }},
158 \\ }},
159 \\ .glibc = .{{
160 \\ .major = {},
161 \\ .minor = {},
162 \\ .patch = {},
163 \\ }},
164 \\ }}}},
165 \\
166 , .{
167 hurd.range.min.major,
168 hurd.range.min.minor,
169 hurd.range.min.patch,
170
171 hurd.range.max.major,
172 hurd.range.max.minor,
173 hurd.range.max.patch,
174
175 hurd.glibc.major,
176 hurd.glibc.minor,
177 hurd.glibc.patch,
178 }),
145 .windows => |windows| try buffer.writer().print(179 .windows => |windows| try buffer.writer().print(
146 \\ .windows = .{{180 \\ .windows = .{{
147 \\ .min = {c},181 \\ .min = {c},
src/Compilation.zig+1-1
...@@ -5315,7 +5315,7 @@ pub fn addCCArgs(...@@ -5315,7 +5315,7 @@ pub fn addCCArgs(
53155315
5316 if (comp.config.link_libc) {5316 if (comp.config.link_libc) {
5317 if (target.isGnuLibC()) {5317 if (target.isGnuLibC()) {
5318 const target_version = target.os.version_range.linux.glibc;5318 const target_version = target.os.versionRange().gnuLibCVersion().?;
5319 const glibc_minor_define = try std.fmt.allocPrint(arena, "-D__GLIBC_MINOR__={d}", .{5319 const glibc_minor_define = try std.fmt.allocPrint(arena, "-D__GLIBC_MINOR__={d}", .{
5320 target_version.minor,5320 target_version.minor,
5321 });5321 });
src/codegen/llvm.zig+10-6
...@@ -245,7 +245,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -245,7 +245,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
245 ver.min.minor,245 ver.min.minor,
246 ver.min.patch,246 ver.min.patch,
247 }),247 }),
248 .linux => |ver| try llvm_triple.writer().print("{d}.{d}.{d}", .{248 inline .linux, .hurd => |ver| try llvm_triple.writer().print("{d}.{d}.{d}", .{
249 ver.range.min.major,249 ver.range.min.major,
250 ver.range.min.minor,250 ver.range.min.minor,
251 ver.range.min.patch,251 ver.range.min.patch,
...@@ -290,11 +290,15 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -290,11 +290,15 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
290 .semver,290 .semver,
291 .windows,291 .windows,
292 => {},292 => {},
293 .linux => |ver| if (target.abi.isGnu()) try llvm_triple.writer().print("{d}.{d}.{d}", .{293 inline .hurd, .linux => |ver| if (target.abi.isGnu()) {
294 ver.glibc.major,294 try llvm_triple.writer().print("{d}.{d}.{d}", .{
295 ver.glibc.minor,295 ver.glibc.major,
296 ver.glibc.patch,296 ver.glibc.minor,
297 }) else if (target.abi.isAndroid()) try llvm_triple.writer().print("{d}", .{ver.android}),297 ver.glibc.patch,
298 });
299 } else if (@TypeOf(ver) == std.Target.Os.LinuxVersionRange and target.abi.isAndroid()) {
300 try llvm_triple.writer().print("{d}", .{ver.android});
301 },
298 }302 }
299303
300 return llvm_triple.toOwnedSlice();304 return llvm_triple.toOwnedSlice();
src/glibc.zig+3-3
...@@ -188,7 +188,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -188,7 +188,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
188 const arena = arena_allocator.allocator();188 const arena = arena_allocator.allocator();
189189
190 const target = comp.root_mod.resolved_target.result;190 const target = comp.root_mod.resolved_target.result;
191 const target_ver = target.os.version_range.linux.glibc;191 const target_ver = target.os.versionRange().gnuLibCVersion().?;
192 const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt;192 const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt;
193 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;193 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;
194194
...@@ -750,7 +750,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi...@@ -750,7 +750,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
750 const arena = arena_allocator.allocator();750 const arena = arena_allocator.allocator();
751751
752 const target = comp.getTarget();752 const target = comp.getTarget();
753 const target_version = target.os.version_range.linux.glibc;753 const target_version = target.os.versionRange().gnuLibCVersion().?;
754754
755 // Use the global cache directory.755 // Use the global cache directory.
756 var cache: Cache = .{756 var cache: Cache = .{
...@@ -1218,7 +1218,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi...@@ -1218,7 +1218,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
1218}1218}
12191219
1220fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {1220fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
1221 const target_version = comp.getTarget().os.version_range.linux.glibc;1221 const target_version = comp.getTarget().os.versionRange().gnuLibCVersion().?;
12221222
1223 assert(comp.glibc_so_files == null);1223 assert(comp.glibc_so_files == null);
1224 comp.glibc_so_files = so_files;1224 comp.glibc_so_files = so_files;
src/libcxx.zig+3-3
...@@ -262,7 +262,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -262,7 +262,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
262262
263 if (target.isGnuLibC()) {263 if (target.isGnuLibC()) {
264 // glibc 2.16 introduced aligned_alloc264 // glibc 2.16 introduced aligned_alloc
265 if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {265 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
266 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");266 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
267 }267 }
268 }268 }
...@@ -477,7 +477,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -477,7 +477,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
477 }477 }
478 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");478 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
479 } else if (target.abi.isGnu()) {479 } else if (target.abi.isGnu()) {
480 if (target.os.tag != .linux or !(target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))480 if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
481 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");481 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
482 }482 }
483483
...@@ -500,7 +500,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -500,7 +500,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
500500
501 if (target.isGnuLibC()) {501 if (target.isGnuLibC()) {
502 // glibc 2.16 introduced aligned_alloc502 // glibc 2.16 introduced aligned_alloc
503 if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {503 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
504 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");504 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
505 }505 }
506 }506 }
src/link/Elf.zig+1-1
...@@ -2013,7 +2013,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s...@@ -2013,7 +2013,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
2013 } else if (target.isGnuLibC()) {2013 } else if (target.isGnuLibC()) {
2014 for (glibc.libs) |lib| {2014 for (glibc.libs) |lib| {
2015 if (lib.removed_in) |rem_in| {2015 if (lib.removed_in) |rem_in| {
2016 if (target.os.version_range.linux.glibc.order(rem_in) != .lt) continue;2016 if (target.os.versionRange().gnuLibCVersion().?.order(rem_in) != .lt) continue;
2017 }2017 }
20182018
2019 const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{2019 const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{
test/link/glibc_compat/build.zig+1-4
...@@ -5,10 +5,7 @@ const builtin = @import("builtin");...@@ -5,10 +5,7 @@ const builtin = @import("builtin");
5// run-time glibc version needs to be new enough. Check the host's glibc5// run-time glibc version needs to be new enough. Check the host's glibc
6// version. Note that this does not allow for translation/vm/emulation6// version. Note that this does not allow for translation/vm/emulation
7// services to run these tests.7// services to run these tests.
8const running_glibc_ver: ?std.SemanticVersion = switch (builtin.os.tag) {8const running_glibc_ver = builtin.os.versionRange().gnuLibCVersion();
9 .linux => builtin.os.version_range.linux.glibc,
10 else => null,
11};
129
13pub fn build(b: *std.Build) void {10pub fn build(b: *std.Build) void {
14 const test_step = b.step("test", "Test");11 const test_step = b.step("test", "Test");
test/link/glibc_compat/glibc_runtime_check.zig+1-1
...@@ -21,7 +21,7 @@ const c_string = @cImport(...@@ -21,7 +21,7 @@ const c_string = @cImport(
21);21);
2222
23// Version of glibc this test is being built to run against23// Version of glibc this test is being built to run against
24const glibc_ver = builtin.target.os.version_range.linux.glibc;24const glibc_ver = builtin.os.versionRange().gnuLibCVersion().?;
2525
26// PR #17034 - fstat moved between libc_nonshared and libc26// PR #17034 - fstat moved between libc_nonshared and libc
27fn checkStat() !void {27fn checkStat() !void {