From a575999eb6e2b6fdceb2fe679b56110cab20f012 Mon Sep 17 00:00:00 2001 From: Raboneko <119771935+raboneko@users.noreply.github.com> Date: Fri, 25 Apr 2025 10:04:31 -0700 Subject: [PATCH] feat(zig-master): Fix build commands for future bootstrapping, port Fedora patches (#4427) (#4433) * feat(zig-master): Bootstrap build * chore: Bump release * Fix up the docs build flag * fix: zig_build_options macro * fix: Don't self-bootstrap for now * Update zig-master.spec * Add files via upload * feat: Port all applicable Fedora patches * Oops * fix: Add back that space * chore: Changelog --------- (cherry picked from commit aae75fdddbccc2ed75857826f05d9c1ac7d85883) Signed-off-by: Gilver Co-authored-by: Gilver --- ...ve-native-lib-directories-from-rpath.patch | 18 ++++++++++++++ ...bounds-of-main-zig-executable-to-9G.patch} | 0 ...ib-dir-as-directory-instead-of-as-st.patch | 18 ++++++++++++++ anda/langs/zig/zig-master.spec | 24 +++++++++++-------- 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 anda/langs/zig/0000-remove-native-lib-directories-from-rpath.patch rename anda/langs/zig/{0000-increase-upper-bounds-of-main-zig-executable-to-9G.patch => 0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch} (100%) create mode 100644 anda/langs/zig/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch diff --git a/anda/langs/zig/0000-remove-native-lib-directories-from-rpath.patch b/anda/langs/zig/0000-remove-native-lib-directories-from-rpath.patch new file mode 100644 index 0000000000..1e1c1f1709 --- /dev/null +++ b/anda/langs/zig/0000-remove-native-lib-directories-from-rpath.patch @@ -0,0 +1,18 @@ +--- a/src/main.zig 2025-04-25 06:01:31.337458939 -0500 ++++ b/src/main.zig 2025-04-25 06:03:02.239473385 -0500 +@@ -4072,6 +4072,15 @@ + + try create_module.lib_directories.ensureUnusedCapacity(arena, paths.lib_dirs.items.len); + for (paths.lib_dirs.items) |path| addLibDirectoryWarn2(&create_module.lib_directories, path, true); ++ ++ for (paths.lib_dirs.items) |native_lib_dir| { ++ for (0.., create_module.rpath_list.items) |i, rpath_dir| { ++ if (std.mem.eql(u8, native_lib_dir, rpath_dir)) { ++ _ = create_module.rpath_list.orderedRemove(i); ++ break; ++ } ++ } ++ } + } + + if (create_module.libc_paths_file) |paths_file| { diff --git a/anda/langs/zig/0000-increase-upper-bounds-of-main-zig-executable-to-9G.patch b/anda/langs/zig/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch similarity index 100% rename from anda/langs/zig/0000-increase-upper-bounds-of-main-zig-executable-to-9G.patch rename to anda/langs/zig/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch diff --git a/anda/langs/zig/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch b/anda/langs/zig/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch new file mode 100644 index 0000000000..21438943cc --- /dev/null +++ b/anda/langs/zig/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch @@ -0,0 +1,18 @@ +--- a/build.zig 2025-04-25 05:56:25.033100994 -0500 ++++ b/build.zig 2025-04-25 05:57:16.965173352 -0500 +@@ -1392,7 +1392,14 @@ + // in a temporary directory + "--cache-root", b.cache_root.path orelse ".", + }); +- cmd.addArgs(&.{ "--zig-lib-dir", b.fmt("{}", .{b.graph.zig_lib_directory}) }); ++ if (b.graph.zig_lib_directory.path) |zig_lib_dir| { ++ cmd.addArgs(&.{"--zig-lib-dir"}); ++ if (fs.path.isAbsolute(zig_lib_dir)) { ++ cmd.addArgs(&.{zig_lib_dir}); ++ } else { ++ cmd.addDirectoryArg(b.path(zig_lib_dir)); ++ } ++ } + cmd.addArgs(&.{"-i"}); + cmd.addFileArg(b.path(b.fmt("doc/langref/{s}", .{entry.name}))); + diff --git a/anda/langs/zig/zig-master.spec b/anda/langs/zig/zig-master.spec index 7b986b933f..a2b6275472 100644 --- a/anda/langs/zig/zig-master.spec +++ b/anda/langs/zig/zig-master.spec @@ -11,11 +11,7 @@ %bcond bootstrap 1 %bcond docs %{without bootstrap} %bcond test 1 -%if 0%{?fedora} <= 40 -%global zig_cache_dir %{_builddir}/zig-cache -%else %global zig_cache_dir %{builddir}/zig-cache -%endif %global zig_build_options %{shrink: \ --verbose \ --release=fast \ @@ -29,7 +25,7 @@ --cache-dir "%{zig_cache_dir}" \ --global-cache-dir "%{zig_cache_dir}" \ \ - -Dversion-string="%{version}" \ + -Dversion-string="%(v=%{ver}; echo ${v:0:6})" \ -Dstatic-llvm=false \ -Denable-llvm=true \ -Dno-langref=true \ @@ -43,13 +39,15 @@ Name: zig-master Version: %(echo %{ver} | sed 's/-/~/g') -Release: 1%?dist +Release: 2%?dist Summary: Programming language for maintaining robust, optimal, and reusable software License: MIT AND NCSA AND LGPL-2.1-or-later AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND GPL-2.0-or-later AND GPL-2.0-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND Inner-Net-2.0 AND ISC AND LicenseRef-Fedora-Public-Domain AND GFDL-1.1-or-later AND ZPL-2.1 URL: https://ziglang.org Source0: %{url}/builds/zig-%{ver}.tar.xz Source1: %{url}/builds/zig-%{ver}.tar.xz.minisig -Patch0: 0000-increase-upper-bounds-of-main-zig-executable-to-9G.patch +Patch0: 0000-remove-native-lib-directories-from-rpath.patch +Patch1: 0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch +Patch2: 0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ @@ -63,7 +61,7 @@ BuildRequires: help2man # for signature verification BuildRequires: minisign %if %{without bootstrap} -BuildRequires: %{name} = %{version} +BuildRequires: %{name} >= %{version} %endif %if %{with test} BuildRequires: elfutils-libelf-devel @@ -108,7 +106,7 @@ Zig Standard Library Summary: Documentation for Zig Conflicts: zig-doc BuildArch: noarch -Requires: %{name} = %{version} +Requires: %{name} >= %{version} %description doc Documentation for Zig. For more information, visit %{url} @@ -117,6 +115,10 @@ Documentation for Zig. For more information, visit %{url} %prep /usr/bin/minisign -V -m %{SOURCE0} -x %{SOURCE1} -P %{public_key} %autosetup -p1 -n zig-%{ver} +%if %{without bootstrap} +# Ensure that the pre-build stage1 binary is not used +rm -f stage1/zig1.wasm +%endif %build # zig doesn't know how to dynamically link llvm on its own so we need cmake to generate a header ahead of time @@ -155,7 +157,7 @@ help2man --no-discard-stderr --no-info "./zig-out/bin/zig" --version-option=vers ./zig-out/bin/zig build docs \ --verbose \ --global-cache-dir "%{zig_cache_dir}" \ - -Dversion-string="%{version}" + -Dversion-string="%(v=%{ver}; echo ${v:0:6})" %endif %install @@ -191,5 +193,7 @@ install -D -pv -m 0644 -t %{buildroot}%{_mandir}/man1/zig.1 %endif %changelog +* Fri Apr 25 2025 Gilver E. - 0.15.0~dev.384+c06fecd46-2 +- Ported Fedora Zig patches * Wed Apr 23 2025 Gilver E. - Initial package