From 0fcaac21e786bd7911b1e8f436cd885c5e2f6437 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 27 Oct 2023 08:42:41 +0100 Subject: gentoo auto-resync : 27:10:2023 - 08:42:41 --- .../zig-0.10.0-build-dir-install-stage3.patch | 42 ---- .../zig/files/zig-0.10.1-musl-1.2.4-lfs64.patch | 220 --------------------- .../zig/files/zig-0.11.0-first-try-getconf.patch | 109 ++++++++++ 3 files changed, 109 insertions(+), 262 deletions(-) delete mode 100644 dev-lang/zig/files/zig-0.10.0-build-dir-install-stage3.patch delete mode 100644 dev-lang/zig/files/zig-0.10.1-musl-1.2.4-lfs64.patch create mode 100644 dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch (limited to 'dev-lang/zig/files') diff --git a/dev-lang/zig/files/zig-0.10.0-build-dir-install-stage3.patch b/dev-lang/zig/files/zig-0.10.0-build-dir-install-stage3.patch deleted file mode 100644 index 5704e4ba7921..000000000000 --- a/dev-lang/zig/files/zig-0.10.0-build-dir-install-stage3.patch +++ /dev/null @@ -1,42 +0,0 @@ -From: Eric Joldasov - -Install 'zig' binary in 'build_dir/stage3' directory so that we can find it and use for testing. -Also split "add_custom_target(stage3 ALL" and command that it invokes, so that it won't retry it during installation, -as target will be considered not out-of-date. (Bug https://bugs.gentoo.org/890457 and https://bugs.gentoo.org/890459). -Upstream PR https://github.com/ziglang/zig/pull/14255. - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -1094,10 +1094,14 @@ set(ZIG_BUILD_ARGS - ) - - add_custom_target(stage3 ALL -- COMMAND zig2 build compile ${ZIG_BUILD_ARGS} -- DEPENDS zig2 -- COMMENT STATUS "Building stage3" -- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" -+ DEPENDS "${CMAKE_BINARY_DIR}/stage3/bin/zig" -+) -+ -+add_custom_command( -+ OUTPUT "${CMAKE_BINARY_DIR}/stage3/bin/zig" -+ COMMAND zig2 build --prefix "${CMAKE_BINARY_DIR}/stage3" ${ZIG_BUILD_ARGS} -+ COMMENT STATUS "Building stage3" -+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - ) - - install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")") - ---- a/build.zig -+++ b/build.zig -@@ -148,10 +148,6 @@ pub fn build(b: *Builder) !void { - }; - - const exe = b.addExecutable("zig", main_file); -- -- const compile_step = b.step("compile", "Build the self-hosted compiler"); -- compile_step.dependOn(&exe.step); -- - exe.stack_size = stack_size; - exe.strip = strip; - exe.sanitize_thread = sanitize_thread; diff --git a/dev-lang/zig/files/zig-0.10.1-musl-1.2.4-lfs64.patch b/dev-lang/zig/files/zig-0.10.1-musl-1.2.4-lfs64.patch deleted file mode 100644 index 05a550a7920e..000000000000 --- a/dev-lang/zig/files/zig-0.10.1-musl-1.2.4-lfs64.patch +++ /dev/null @@ -1,220 +0,0 @@ -From https://github.com/ziglang/zig/commit/b20ccff515364cdb8f3e733cc950e53ab77656db Mon Sep 17 00:00:00 2001 -From: Andrew Kelley -Date: Mon, 19 Jun 2023 15:17:01 -0700 -Subject: [PATCH] std.os: update logic for 64-bit symbol choice - -musl v1.2.4 dropped the "64"-suffixed aliases for legacy "LFS64" ("large -file support") interfaces, so this commit changes the corresponding Zig -logic to call the correct names. ---- a/lib/std/os.zig -+++ b/lib/std/os.zig -@@ -890,10 +890,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { - }; - const adjusted_len = @min(max_count, buf.len); - -- const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.pread64 -- else -- system.pread; -+ const pread_sym = if (lfs64_abi) system.pread64 else system.pread; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - while (true) { -@@ -966,10 +963,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { - } - - while (true) { -- const ftruncate_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.ftruncate64 -- else -- system.ftruncate; -+ const ftruncate_sym = if (lfs64_abi) system.ftruncate64 else system.ftruncate; - - const ilen = @bitCast(i64, length); // the OS treats this as unsigned - switch (errno(ftruncate_sym(fd, ilen))) { -@@ -1034,10 +1028,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { - - const iov_count = math.cast(u31, iov.len) orelse math.maxInt(u31); - -- const preadv_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.preadv64 -- else -- system.preadv; -+ const preadv_sym = if (lfs64_abi) system.preadv64 else system.preadv; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - while (true) { -@@ -1311,10 +1302,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { - }; - const adjusted_len = @min(max_count, bytes.len); - -- const pwrite_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.pwrite64 -- else -- system.pwrite; -+ const pwrite_sym = if (lfs64_abi) system.pwrite64 else system.pwrite; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - while (true) { -@@ -1400,10 +1388,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz - } - } - -- const pwritev_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.pwritev64 -- else -- system.pwritev; -+ const pwritev_sym = if (lfs64_abi) system.pwritev64 else system.pwritev; - - const iov_count = if (iov.len > IOV_MAX) IOV_MAX else @intCast(u31, iov.len); - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned -@@ -1514,10 +1499,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: mode_t) OpenError!fd_t - return open(mem.sliceTo(file_path, 0), flags, perm); - } - -- const open_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.open64 -- else -- system.open; -+ const open_sym = if (lfs64_abi) system.open64 else system.open; - - while (true) { - const rc = open_sym(file_path, flags, perm); -@@ -1730,10 +1712,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) - return openat(dir_fd, mem.sliceTo(file_path, 0), flags, mode); - } - -- const openat_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.openat64 -- else -- system.openat; -+ const openat_sym = if (lfs64_abi) system.openat64 else system.openat; - - while (true) { - const rc = openat_sym(dir_fd, file_path, flags, mode); -@@ -4117,10 +4096,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { - @compileError("fstat is not yet implemented on Windows"); - } - -- const fstat_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.fstat64 -- else -- system.fstat; -+ const fstat_sym = if (lfs64_abi) system.fstat64 else system.fstat; - - var stat = mem.zeroes(Stat); - switch (errno(fstat_sym(fd, &stat))) { -@@ -4176,10 +4152,7 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S - return fstatatWasi(dirfd, mem.sliceTo(pathname), flags); - } - -- const fstatat_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.fstatat64 -- else -- system.fstatat; -+ const fstatat_sym = if (lfs64_abi) system.fstatat64 else system.fstatat; - - var stat = mem.zeroes(Stat); - switch (errno(fstatat_sym(dirfd, pathname, &stat, flags))) { -@@ -4416,10 +4389,7 @@ pub fn mmap( - fd: fd_t, - offset: u64, - ) MMapError![]align(mem.page_size) u8 { -- const mmap_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.mmap64 -- else -- system.mmap; -+ const mmap_sym = if (lfs64_abi) system.mmap64 else system.mmap; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset); -@@ -4823,10 +4793,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { - } - } - -- const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.lseek64 -- else -- system.lseek; -+ const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - switch (errno(lseek_sym(fd, ioffset, SEEK.SET))) { -@@ -4870,10 +4837,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { - else => |err| return unexpectedErrno(err), - } - } -- const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.lseek64 -- else -- system.lseek; -+ const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - switch (errno(lseek_sym(fd, ioffset, SEEK.CUR))) { -@@ -4917,10 +4881,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { - else => |err| return unexpectedErrno(err), - } - } -- const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.lseek64 -- else -- system.lseek; -+ const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; - - const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned - switch (errno(lseek_sym(fd, ioffset, SEEK.END))) { -@@ -4964,10 +4925,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { - else => |err| return unexpectedErrno(err), - } - } -- const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.lseek64 -- else -- system.lseek; -+ const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; - - const rc = lseek_sym(fd, 0, SEEK.CUR); - switch (errno(rc)) { -@@ -6169,10 +6127,7 @@ pub fn sendfile( - // TODO we should not need this cast; improve return type of @min - const adjusted_count = @intCast(usize, adjusted_count_tmp); - -- const sendfile_sym = if (builtin.link_libc) -- system.sendfile64 -- else -- system.sendfile; -+ const sendfile_sym = if (lfs64_abi) system.sendfile64 else system.sendfile; - - while (true) { - var offset: off_t = @bitCast(off_t, in_offset); -@@ -7050,10 +7005,7 @@ pub fn prctl(option: PR, args: anytype) PrctlError!u31 { - pub const GetrlimitError = UnexpectedError; - - pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit { -- const getrlimit_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.getrlimit64 -- else -- system.getrlimit; -+ const getrlimit_sym = if (lfs64_abi) system.getrlimit64 else system.getrlimit; - - var limits: rlimit = undefined; - switch (errno(getrlimit_sym(resource, &limits))) { -@@ -7067,10 +7019,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit { - pub const SetrlimitError = error{ PermissionDenied, LimitTooBig } || UnexpectedError; - - pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void { -- const setrlimit_sym = if (builtin.os.tag == .linux and builtin.link_libc) -- system.setrlimit64 -- else -- system.setrlimit; -+ const setrlimit_sym = if (lfs64_abi) system.setrlimit64 else system.setrlimit; - - switch (errno(setrlimit_sym(resource, &limits))) { - .SUCCESS => return, -@@ -7339,3 +7288,5 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError! - }, - }; - } -+ -+const lfs64_abi = builtin.os.tag == .linux and builtin.link_libc and builtin.abi.isGnu(); diff --git a/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch b/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch new file mode 100644 index 000000000000..6d1b3ca7e5b7 --- /dev/null +++ b/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch @@ -0,0 +1,109 @@ +From: Eric Joldasov + +Based on https://github.com/ziglang/zig/pull/12567 and https://github.com/ziglang/zig/pull/17671 +with small fixes, all ported to 0.11.0. + +First try `getconf GNU_LIBC_VERSION` to detect glibc version, +If there are any errors, skip to the upstream logic. + +Also fix glibc version parsing: if version string does not contain third (patch) component, "std.SemanticVersion.parse" returns parsing error. +For example, this currently happens with "GLIBC_2.37" or "glibc 2.37" inputs. +To fix this, we use copy-pasted "std.zig.CrossTarget.parse" function here, that sets omitted patch component to 0. + +After applying this patch, both `zig build-exe --show-builtin` and `zig env` show correct version on my default/linux/amd64/17.1/desktop/plasma : +glibc 2.37. + +Bug: https://bugs.gentoo.org/914731 +Bug: https://bugs.gentoo.org/914101 + +diff --git a/lib/std/zig/system/NativeTargetInfo.zig b/lib/std/zig/system/NativeTargetInfo.zig +index 99a1a8f2e..d1032a716 100644 +--- a/lib/std/zig/system/NativeTargetInfo.zig ++++ b/lib/std/zig/system/NativeTargetInfo.zig +@@ -19,6 +19,32 @@ dynamic_linker: DynamicLinker = DynamicLinker{}, + + pub const DynamicLinker = Target.DynamicLinker; + ++// Copy-pasted from `std.zig.CrossTarget.parse` to avoid changing visibility of mentioned function. ++/// Parses a version with an omitted patch component, such as "1.0", ++/// which SemanticVersion.parse is not capable of. ++fn parseWithOptionalPatchField(ver: []const u8) error{ InvalidVersion, Overflow }!std.SemanticVersion { ++ const parseVersionComponent = struct { ++ fn parseVersionComponent(component: []const u8) !usize { ++ return std.fmt.parseUnsigned(usize, component, 10) catch |err| { ++ switch (err) { ++ error.InvalidCharacter => return error.InvalidVersion, ++ error.Overflow => return error.Overflow, ++ } ++ }; ++ } ++ }.parseVersionComponent; ++ var version_components = mem.split(u8, ver, "."); ++ const major = version_components.first(); ++ const minor = version_components.next() orelse return error.InvalidVersion; ++ const patch = version_components.next() orelse "0"; ++ if (version_components.next() != null) return error.InvalidVersion; ++ return .{ ++ .major = try parseVersionComponent(major), ++ .minor = try parseVersionComponent(minor), ++ .patch = try parseVersionComponent(patch), ++ }; ++} ++ + pub const DetectError = error{ + FileSystem, + SystemResources, +@@ -307,6 +333,35 @@ fn detectAbiAndDynamicLinker( + } + const ld_info_list = ld_info_list_buffer[0..ld_info_list_len]; + ++ if (is_linux and !os_is_non_native and cross_target.glibc_version == null) try_getconf: { ++ var buf: [4096]u8 = undefined; ++ var fba = std.heap.FixedBufferAllocator.init(&buf); ++ const allocator = fba.allocator(); ++ ++ const getconf = std.process.Child.exec(.{ ++ .allocator = allocator, ++ .argv = &.{ "getconf", "GNU_LIBC_VERSION" }, ++ .max_output_bytes = 1024, ++ }) catch break :try_getconf; ++ if (!std.mem.startsWith(u8, getconf.stdout, "glibc ")) break :try_getconf; ++ const version_string = getconf.stdout["glibc ".len..]; ++ const glibc_version = parseWithOptionalPatchField(version_string) catch break :try_getconf; ++ ++ var os_with_glibc = os; ++ os_with_glibc.version_range.linux.glibc = glibc_version; ++ ++ const result: NativeTargetInfo = .{ ++ .target = .{ ++ .cpu = cpu, ++ .os = os_with_glibc, ++ .abi = cross_target.abi orelse Target.Abi.default(cpu.arch, os_with_glibc), ++ .ofmt = cross_target.ofmt orelse Target.ObjectFormat.default(os_with_glibc.tag, cpu.arch), ++ }, ++ .dynamic_linker = cross_target.dynamic_linker, ++ }; ++ return result; ++ } ++ + // Best case scenario: the executable is dynamically linked, and we can iterate + // over our own shared objects and find a dynamic linker. + const elf_file = blk: { +@@ -563,7 +618,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.SemanticVersion { + while (it.next()) |s| { + if (mem.startsWith(u8, s, "GLIBC_2.")) { + const chopped = s["GLIBC_".len..]; +- const ver = std.SemanticVersion.parse(chopped) catch |err| switch (err) { ++ const ver = parseWithOptionalPatchField(chopped) catch |err| switch (err) { + error.Overflow => return error.InvalidGnuLibCVersion, + error.InvalidVersion => return error.InvalidGnuLibCVersion, + }; +@@ -586,7 +641,7 @@ fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.Semantic + } + // chop off "libc-" and ".so" + const link_name_chopped = link_name[prefix.len .. link_name.len - suffix.len]; +- return std.SemanticVersion.parse(link_name_chopped) catch |err| switch (err) { ++ return parseWithOptionalPatchField(link_name_chopped) catch |err| switch (err) { + error.Overflow => return error.InvalidGnuLibCVersion, + error.InvalidVersion => return error.InvalidGnuLibCVersion, + }; -- cgit v1.2.3