%global _trivial .0 %global _buildid .1 # 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 # AL2023 uses compat LLVM packages %if 0%{?amzn} %define llvm_compat 21 %endif %global llvm_version 21.1.8 %bcond_with docs %bcond_without macro %bcond_without test %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="%{version}" \ -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 Version: 0.16.0 Release: 1%{?dist}%{?_trivial}%{?_buildid} 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}/download/%{version}/%{name}-%{version}.tar.xz Source1: %{url}/download/%{version}/%{name}-%{version}.tar.xz.minisig Source2: macros.%{name} # Remove native lib directories from rpath # this is unlikely to be upstreamed in its current state because upstream # wants to work around the shortcomings of NixOS Patch0: 0001-remove-native-lib-directories-from-rpath.patch BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: llvm%{?llvm_compat}-devel BuildRequires: clang%{?llvm_compat}-devel BuildRequires: lld%{?llvm_compat}-devel BuildRequires: compiler-rt%{?llvm_compat} BuildRequires: zlib-devel BuildRequires: libxml2-devel # for man page generation BuildRequires: help2man # for signature verification BuildRequires: minisign %if 0%{?amzn} BuildRequires: gcc14 BuildRequires: gcc14-c++ %global toolchain gcc14 %endif %if %{with test} # for testing BuildRequires: elfutils-libelf-devel BuildRequires: libstdc++-static %endif Requires: %{name}-libs = %{version} # These packages are bundled as source Provides: bundled(compiler-rt) = %{llvm_version} Provides: bundled(glibc) = 2.43 Provides: bundled(libcxx) = %{llvm_version} Provides: bundled(libcxxabi) = %{llvm_version} Provides: bundled(libunwind) = %{llvm_version} Provides: bundled(mingw) = 3839e21b08807479a31d5a9764666f82ae2f0356 Provides: bundled(musl) = 1.2.5 Provides: bundled(wasi-libc) = d03829489904d38c624f6de9983190f1e5e7c9c5 ExclusiveArch: %{zig_arches} %description Zig is an open-source programming language designed for robustness, optimality, and clarity. This package provides the zig compiler and the associated runtime. # The Zig stdlib only contains uncompiled code %package libs Summary: %{name} Standard Library BuildArch: noarch %description libs %{name} Standard Library %if %{with docs} %package doc Summary: Documentation for %{name} BuildArch: noarch Requires: %{name} = %{version} %description doc Documentation for %{name}. For more information, visit %{url} %endif %if %{with macro} %package rpm-macros Summary: Common RPM macros for %{name} Requires: rpm BuildArch: noarch %description rpm-macros This package contains common RPM macros for %{name}. %endif %prep /usr/bin/minisign -V -m %{SOURCE0} -x %{SOURCE1} -P %{public_key} %autosetup -p1 %build export CCACHE_DISABLE=1 %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="%{version}" # 1. Build the stage3 compiler using the C++ bootstrap code (no pre-existing zig needed). echo "### Building stage3 bootstrap compiler... ###" %cmake_build --target stage3 export PATH="%{_builddir}/%{name}-%{version}/%{__cmake_builddir}/stage3/bin:$PATH" %cmake_build --target zigcpp zig build %{zig_build_options} # 2. Generate the manpage using the newly-built compiler. echo "### Generating man page... ###" LD_LIBRARY_PATH=%{_libdir} help2man --no-discard-stderr --no-info "./zig-out/bin/zig" --version-option=version --output=zig.1 %if %{with docs} # 3. Use the newly made compiler to generate docs. echo "### Building documentation... ###" LD_LIBRARY_PATH=%{_libdir} ./zig-out/bin/zig build docs %{zig_build_options} %endif %install # Use the newly built zig compiler to install itself into the buildroot. echo "### Installing zig... ###" LD_LIBRARY_PATH=%{_libdir} DESTDIR="%{buildroot}" ./zig-out/bin/zig build install %{zig_install_options} # Install the man page. echo "### Installing man page... ###" install -D -pv -m 0644 -t %{buildroot}%{_mandir}/man1/ zig.1 %if %{with macro} install -D -pv -m 0644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}/macros.%{name} %endif %if %{with test} %check # Run reduced set of tests, based on the Zig CI LD_LIBRARY_PATH=%{_libdir} "%{buildroot}%{_bindir}/zig" test test/behavior.zig -Itest %endif %files %license LICENSE %{_bindir}/zig %{_mandir}/man1/%{name}.1.* %files libs %{_prefix}/lib/%{name} %if %{with docs} %files doc %doc README.md %doc zig-out/doc/langref.html %doc zig-out/doc/std %endif %if %{with macro} %files rpm-macros %{_rpmmacrodir}/macros.%{name} %endif %changelog * Sun Jul 06 2025 yxwang5db2 - 0.16.0-1.amzn2023.0.1 - Update to 0.16.0 - Switch to LLVM 21 - Update bundled glibc to 2.43