diff --git a/anda/langs/zig/bootstrap/0000-remove-native-lib-directories-from-rpath.patch b/anda/langs/zig/bootstrap/0000-remove-native-lib-directories-from-rpath.patch new file mode 100644 index 0000000000..1e1c1f1709 --- /dev/null +++ b/anda/langs/zig/bootstrap/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/bootstrap/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/bootstrap/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch diff --git a/anda/langs/zig/bootstrap/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch b/anda/langs/zig/bootstrap/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/bootstrap/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/bootstrap/anda.hcl b/anda/langs/zig/bootstrap/anda.hcl new file mode 100644 index 0000000000..60172542b7 --- /dev/null +++ b/anda/langs/zig/bootstrap/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "zig-master-bootstrap.spec" + } +} diff --git a/anda/langs/zig/update.rhai b/anda/langs/zig/bootstrap/update.rhai similarity index 100% rename from anda/langs/zig/update.rhai rename to anda/langs/zig/bootstrap/update.rhai diff --git a/anda/langs/zig/bootstrap/zig-master-bootstrap.spec b/anda/langs/zig/bootstrap/zig-master-bootstrap.spec new file mode 100644 index 0000000000..dcb73fe418 --- /dev/null +++ b/anda/langs/zig/bootstrap/zig-master-bootstrap.spec @@ -0,0 +1,207 @@ +# https://ziglang.org/download/VERSION/release-notes.html#Support-Table +%global zig_arches x86_64 aarch64 riscv64 %{mips64} +# Signing key from https://ziglang.org/download/ +%global public_key RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U +# Not needed yet +%if 0%{?fedora} >= 42 || 0%{?rhel} >= 9 +%define llvm_compat 20 +%endif +%global llvm_version 20.0.0 +%global ver 0.15.0-dev.551+518105471 +%bcond bootstrap 1 +%bcond docs %{without bootstrap} +%bcond test 1 +%global zig_cache_dir %{builddir}/zig-cache +%global zig_build_options %{shrink: \ + --verbose \ + --release=fast \ + --summary all \ + \ + -Dtarget=native \ + -Dcpu=baseline \ + --zig-lib-dir lib \ + --build-id=sha1 \ + \ + --cache-dir "%{zig_cache_dir}" \ + --global-cache-dir "%{zig_cache_dir}" \ + \ + -Dversion-string="%(v=%{ver}; echo ${v:0:6})" \ + -Dstatic-llvm=false \ + -Denable-llvm=true \ + -Dno-langref=true \ + -Dstd-docs=false \ + -Dpie \ + -Dconfig_h="%{__cmake_builddir}/config.h" \ +} +%global zig_install_options %zig_build_options %{shrink: \ + --prefix "%{_prefix}" \ +} + +Name: zig-master-bootstrap +Version: %(echo %{ver} | sed 's/-/~/g') +Release: 1%?dist +Summary: Boostrap builds for Zig. +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-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++ +BuildRequires: libxml2-devel +BuildRequires: llvm-devel +BuildRequires: clang-devel +BuildRequires: lld-devel +BuildRequires: zlib-devel +# for man page generation +BuildRequires: help2man +# for signature verification +BuildRequires: minisign +%if %{without bootstrap} +BuildRequires: %{name} <= %{version} +%endif +%if %{with test} +BuildRequires: elfutils-libelf-devel +BuildRequires: libstdc++-static +%endif +# Zig invokes the C compiler to figure out system info +Requires: gcc +Requires: %{name}-libs = %{version} +# Apache-2.0 WITH LLVM-exception OR NCSA OR MIT +Provides: bundled(compiler-rt) = %{llvm_version} +# LGPL-2.1-or-later AND SunPro AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND GPL-2.0-or-later AND LGPL-2.1-or-later WITH GNU-compiler-exception AND GPL-2.0-only AND ISC AND LicenseRef-Fedora-Public-Domain AND HPND AND CMU-Mach AND LGPL-2.0-or-later AND Unicode-3.0 AND GFDL-1.1-or-later AND GPL-1.0-or-later AND FSFUL AND MIT AND Inner-Net-2.0 AND X11 AND GPL-2.0-or-later WITH GCC-exception-2.0 AND GFDL-1.3-only AND GFDL-1.1-only +Provides: bundled(glibc) = 2.41 +# Apache-2.0 WITH LLVM-exception OR MIT OR NCSA +Provides: bundled(libcxx) = %{llvm_version} +# Apache-2.0 WITH LLVM-exception OR MIT OR NCSA +Provides: bundled(libcxxabi) = %{llvm_version} +# NCSA +Provides: bundled(libunwind) = %{llvm_version} +# BSD, LGPG, ZPL +Provides: bundled(mingw) = 3839e21b08807479a31d5a9764666f82ae2f0356 +# MIT +Provides: bundled(musl) = 1.2.5 +# Apache-2.0 WITH LLVM-exception AND Apache-2.0 AND MIT AND BSD-2-Clause +Provides: bundled(wasi-libc) = d03829489904d38c624f6de9983190f1e5e7c9c5 +Conflicts: zig +ExclusiveArch: %{zig_arches} +Packager: Gilver E. + +%description +Zig is an open source alternative to C. +This package provides the bootstrap to build full "prerelease"/master builds of Zig. +It is not recommended to use this build on its own. + +# The Zig stdlib only contains uncompiled code +%package libs +Summary: Zig Standard Library +Conflicts: zig-libs +BuildArch: noarch + +%description libs +Zig Standard Library + +%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 +# if we provide the header we need to also build zigcpp + +# C_FLAGS: wasm2c output generates a lot of noise with -Wunused. +# EXTRA_BUILD_ARGS: explicitly specify a build-id +%cmake \ + -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ + -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="-DNDEBUG -Wno-unused" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-DNDEBUG -Wno-unused" \ + \ + -DZIG_EXTRA_BUILD_ARGS:STRING="--verbose;--build-id=sha1" \ + -DZIG_SHARED_LLVM:BOOL=true \ + -DZIG_PIE:BOOL=true \ + \ + -DZIG_TARGET_MCPU:STRING=baseline \ + -DZIG_TARGET_TRIPLE:STRING=native \ + \ + -DZIG_VERSION:STRING="%(v=%{ver}; echo ${v:0:6})" + +%if %{with bootstrap} +%cmake_build --target stage3 +%else +%cmake_build --target zigcpp +zig build %{zig_build_options} + +# Zig has no official manpage +# https://github.com/ziglang/zig/issues/715 +help2man --no-discard-stderr --no-info "./zig-out/bin/zig" --version-option=version --output=zig.1 +%endif + + +%if %{with docs} +# Use the newly made stage 3 compiler to generate docs +# Zig has an extremely annoying issue with transitive failures when trying to build the docs, retry until it succeeds +max=3 +attempt=1 +while ./zig-out/bin/zig build docs \ + --verbose \ + --global-cache-dir "%{zig_cache_dir}" \ + -Dversion-string="%(v=%{ver}; echo ${v:0:6})"; [[ $? -ne 0 ]]; +do + echo "Transitive failure. Trying again." + + if [[ $attempt -eq $max ]] + then + break + fi + + sleep 1 + ((attempt++)) +done +%endif + +%install +%if %{with bootstrap} +%cmake_install +%else +DESTDIR="%{buildroot}" zig build install %{zig_install_options} + +install -Dpm644 zig.1 -t %{buildroot}%{_mandir}/man1/ +%endif + +%if %{with test} +%check +# Run reduced set of tests, based on the Zig CI +"%{buildroot}%{_bindir}/zig" test test/behavior.zig -Itest +%endif + +%files +%license LICENSE +%{_bindir}/zig +%if %{without bootstrap} +%{_mandir}/man1/zig.1.* +%endif + +%files libs +%{_prefix}/lib/zig + +%if %{with docs} +%files doc +%doc README.md +%doc zig-out/doc/langref.html +%doc zig-out/doc/std +%endif + +%changelog +* Sat May 10 2025 Gilver E. - 0.15.0~dev.482+2c241b263-2 +- Added GCC runtime dependency to pass system information to Zig +* 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 diff --git a/anda/langs/zig/master/0000-remove-native-lib-directories-from-rpath.patch b/anda/langs/zig/master/0000-remove-native-lib-directories-from-rpath.patch new file mode 100644 index 0000000000..1e1c1f1709 --- /dev/null +++ b/anda/langs/zig/master/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/master/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch b/anda/langs/zig/master/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch new file mode 100644 index 0000000000..2101ac8a2d --- /dev/null +++ b/anda/langs/zig/master/0001-increase-upper-bounds-of-main-zig-executable-to-9G.patch @@ -0,0 +1,11 @@ +--- a/build.zig 2025-04-23 22:33:17.801652844 -0500 ++++ b/build.zig 2025-04-23 22:34:14.127282140 -0500 +@@ -679,7 +679,7 @@ + + const exe = b.addExecutable(.{ + .name = "zig", +- .max_rss = 7_800_000_000, ++ .max_rss = 9_000_000_000, + .root_module = compiler_mod, + }); + exe.stack_size = stack_size; diff --git a/anda/langs/zig/master/0002-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch b/anda/langs/zig/master/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/master/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/anda.hcl b/anda/langs/zig/master/anda.hcl similarity index 62% rename from anda/langs/zig/anda.hcl rename to anda/langs/zig/master/anda.hcl index 2ed6c200f0..5daedf31a8 100644 --- a/anda/langs/zig/anda.hcl +++ b/anda/langs/zig/master/anda.hcl @@ -2,4 +2,7 @@ project pkg { rpm { spec = "zig-master.spec" } + labels { + updbranch = 1 + } } diff --git a/anda/langs/zig/master/update.rhai b/anda/langs/zig/master/update.rhai new file mode 100644 index 0000000000..fb5cefc6c1 --- /dev/null +++ b/anda/langs/zig/master/update.rhai @@ -0,0 +1,8 @@ +import "andax/bump_extras.rhai" as bump; + +rpm.version(bump::madoguchi("zig-master-bootstrap", labels.branch)); +if rpm.changed () { + let v = sh("cat anda/langs/zig/bootstrap/zig-master-bootstrap.spec | grep '%global ver' | sed -E 's/.+ver //'", #{"stdout": "piped"}).ctx.stdout; + v.pop(); + rpm.global("ver", v); +} diff --git a/anda/langs/zig/zig-master.spec b/anda/langs/zig/master/zig-master.spec similarity index 76% rename from anda/langs/zig/zig-master.spec rename to anda/langs/zig/master/zig-master.spec index 512bea670c..c19174e01e 100644 --- a/anda/langs/zig/zig-master.spec +++ b/anda/langs/zig/master/zig-master.spec @@ -7,15 +7,11 @@ %define llvm_compat 20 %endif %global llvm_version 20.0.0 -%global ver 0.15.0-dev.464+dffd18f13 -%bcond bootstrap 1 +%global ver 0.15.0-dev.483+837e0f9c3 +%bcond bootstrap 0 %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 \ @@ -42,14 +38,16 @@ } Name: zig-master -Version: %(echo %{ver} | sed 's/-/~/g') -Release: 1%{?dist} -Summary: Programming language for maintaining robust, optimal, and reusable software +Version: 0.15.0~dev.483+837e0f9c3 +Release: 1%?dist +Summary: Master builds of the Zig language 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,12 +61,14 @@ BuildRequires: help2man # for signature verification BuildRequires: minisign %if %{without bootstrap} -BuildRequires: %{name} = %{version} +BuildRequires: %{name}-bootstrap = %{version} %endif %if %{with test} BuildRequires: elfutils-libelf-devel BuildRequires: libstdc++-static %endif +# Zig invokes the C compiler to figure out system info +Requires: gcc Requires: %{name}-libs = %{version} # Apache-2.0 WITH LLVM-exception OR NCSA OR MIT Provides: bundled(compiler-rt) = %{llvm_version} @@ -91,8 +91,9 @@ ExclusiveArch: %{zig_arches} Packager: Gilver E. %description -Zig is an open-source programming language designed for robustness, optimality, -and clarity. This package provides the zig compiler and the associated runtime. +Zig is an open source alternative to C. +This package provides the master/"prerelease" builds of the Zig compiler and the associated runtime. +Please note these are not stable releases and should only be used for Zig projects that use these or Git versions of Zig. # The Zig stdlib only contains uncompiled code %package libs @@ -117,6 +118,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 @@ -136,7 +141,7 @@ Documentation for Zig. For more information, visit %{url} -DZIG_TARGET_MCPU:STRING=baseline \ -DZIG_TARGET_TRIPLE:STRING=native \ \ - -DZIG_VERSION:STRING="%{ver}" + -DZIG_VERSION:STRING="%(v=%{ver}; echo ${v:0:6})" %if %{with bootstrap} %cmake_build --target stage3 @@ -152,10 +157,24 @@ help2man --no-discard-stderr --no-info "./zig-out/bin/zig" --version-option=vers %if %{with docs} # Use the newly made stage 3 compiler to generate docs -./zig-out/bin/zig build docs \ +# Zig has an extremely annoying issue with transitive failures when trying to build the docs, retry until it succeeds +max=3 +attempt=1 +while ./zig-out/bin/zig build docs \ --verbose \ --global-cache-dir "%{zig_cache_dir}" \ - -Dversion-string="%{version}" + -Dversion-string="%(v=%{ver}; echo ${v:0:6})"; [[ $? -ne 0 ]]; +do + echo "Transitive failure. Trying again." + + if [[ $attempt -eq $max ]] + then + break + fi + + sleep 1 + ((attempt++)) +done %endif %install @@ -164,12 +183,7 @@ help2man --no-discard-stderr --no-info "./zig-out/bin/zig" --version-option=vers %else DESTDIR="%{buildroot}" zig build install %{zig_install_options} -install -D -pv -m 0644 -t %{buildroot}%{_mandir}/man1/zig.1 -%endif - - -%if %{with macro} -install -D -pv -m 0644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}/macros.%{name} +install -Dpm644 zig.1 -t %{buildroot}%{_mandir}/man1/ %endif %if %{with test} @@ -196,5 +210,9 @@ install -D -pv -m 0644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}/macros.%{name} %endif %changelog +* Sat May 10 2025 Gilver E. - 0.15.0~dev.482+2c241b263-2 +- Added GCC runtime dependency to pass system information to Zig +* 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