2025-09-20 14:35:56 +00:00
|
|
|
#
|
|
|
|
|
# spec file for package zig
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2025 SUSE LLC
|
|
|
|
|
#
|
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
%global version_suffix 0.14
|
|
|
|
|
%global version_current 0.14.1
|
|
|
|
|
%global version_previous 0.13.0
|
|
|
|
|
|
|
|
|
|
%global _lto_cflags %{nil}
|
|
|
|
|
%global __builder ninja
|
|
|
|
|
%bcond_without macro
|
|
|
|
|
%bcond_without test
|
|
|
|
|
|
2026-01-27 21:54:32 +00:00
|
|
|
# LLVM 19 is a hard requirement
|
2025-09-20 14:35:56 +00:00
|
|
|
%define clang_ver 19
|
2026-01-27 21:54:32 +00:00
|
|
|
|
2026-01-27 21:03:33 +00:00
|
|
|
%define force_gcc_version 15
|
|
|
|
|
|
2025-09-20 22:47:42 +00:00
|
|
|
%bcond_without clang
|
2026-01-27 21:03:33 +00:00
|
|
|
%if 0%{?suse_version} >= 1600
|
2026-01-18 01:35:52 +00:00
|
|
|
%ifnarch aarch64
|
2025-09-20 22:47:42 +00:00
|
|
|
%bcond_without mold
|
2026-01-18 01:35:52 +00:00
|
|
|
%else
|
|
|
|
|
%bcond_with mold
|
|
|
|
|
%endif
|
2025-09-20 18:21:51 +00:00
|
|
|
%endif
|
|
|
|
|
|
2026-01-27 21:54:32 +00:00
|
|
|
%if 0%{?suse_version} >= 1699
|
|
|
|
|
%bcond_without has_linker_type
|
|
|
|
|
%else
|
|
|
|
|
%bcond_with has_linker_type
|
|
|
|
|
%endif
|
|
|
|
|
|
2025-09-20 14:35:56 +00:00
|
|
|
Name: zig%{version_suffix}
|
|
|
|
|
Version: %{version_current}
|
|
|
|
|
Release: 0
|
|
|
|
|
Summary: Compiler for the Zig language
|
|
|
|
|
License: MIT
|
|
|
|
|
Group: Development/Languages/Other
|
|
|
|
|
URL: https://ziglang.org/
|
|
|
|
|
Source0: https://ziglang.org/download/%{version}/zig-%{version}.tar.xz
|
|
|
|
|
Source1: macros.zig
|
|
|
|
|
# The vendored tarball is for tests. This contains the
|
|
|
|
|
# cached deps. See https://en.opensuse.org/Zig#Packaging
|
|
|
|
|
Source3: zig%{version_suffix}-rpmlintrc
|
|
|
|
|
Patch0: 0000-remove-lld-in-cmakelist.patch
|
|
|
|
|
Patch1: 0001-invoke-lld.patch
|
|
|
|
|
Patch2: 0002-no-lld-libs-and-includes.patch
|
|
|
|
|
# Just copying from Archlinux. Thanks
|
|
|
|
|
Patch3: https://gitlab.archlinux.org/archlinux/packaging/packages/zig/-/raw/main/skip-localhost-test.patch
|
|
|
|
|
# to improve reproducible-builds -- https://github.com/ziglang/zig/pull/22673
|
|
|
|
|
Patch4: reproducible.patch
|
2026-01-28 01:01:46 +00:00
|
|
|
# https://github.com/ziglang/zig/issues/23347 https://github.com/ziglang/zig/pull/23254
|
|
|
|
|
Patch5: bump_max_rss.patch
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildRequires: clang%{?clang_ver}
|
|
|
|
|
BuildRequires: clang%{?clang_ver}-devel
|
|
|
|
|
BuildRequires: cmake
|
|
|
|
|
BuildRequires: elfutils
|
2025-09-20 22:47:42 +00:00
|
|
|
#BuildRequires: gcc%{?force_gcc_version}-c++
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildRequires: glibc
|
|
|
|
|
BuildRequires: glibc-devel
|
|
|
|
|
BuildRequires: glibc-devel-32bit
|
|
|
|
|
BuildRequires: help2man
|
|
|
|
|
BuildRequires: libelf-devel
|
|
|
|
|
BuildRequires: liburing-devel
|
|
|
|
|
BuildRequires: lld%{?clang_ver}
|
|
|
|
|
BuildRequires: llvm%{?clang_ver}-devel
|
2026-01-27 21:03:33 +00:00
|
|
|
%if %{with mold}
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildRequires: mold
|
2026-01-27 21:03:33 +00:00
|
|
|
%endif
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildRequires: ninja
|
|
|
|
|
BuildRequires: zlib-devel
|
|
|
|
|
BuildRequires: zstd
|
|
|
|
|
Requires: lld%{?clang_ver}
|
|
|
|
|
|
|
|
|
|
Conflicts: zig < %{version}
|
|
|
|
|
Provides: zig = %{version}
|
2025-10-19 18:02:19 +00:00
|
|
|
Provides: zig-implementation = %{version}
|
2025-09-20 14:35:56 +00:00
|
|
|
|
|
|
|
|
# llvm-config is missing targets for ppc and arm architectures.
|
|
|
|
|
# ExcludeArch: ppc64 ppc64le %%arm %%ix86
|
|
|
|
|
ExclusiveArch: x86_64 aarch64 riscv64 %{mips64}
|
|
|
|
|
|
|
|
|
|
# Zig needs this to work
|
2026-01-18 02:08:55 +00:00
|
|
|
Requires: zig-libs%{version_suffix} = %{version}
|
2025-09-20 14:35:56 +00:00
|
|
|
|
|
|
|
|
# Zig Macros
|
|
|
|
|
Recommends: zig-rpm-macros = %{version}
|
|
|
|
|
|
|
|
|
|
%description
|
|
|
|
|
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
|
|
|
|
|
|
|
|
|
|
* Robust - behavior is correct even for edge cases such as out of memory.
|
|
|
|
|
* Optimal - write programs the best way they can behave and perform.
|
|
|
|
|
* Reusable - the same code works in many environments which have different constraints.
|
|
|
|
|
* Maintainable - precisely communicate intent to the compiler and other programmers.
|
|
|
|
|
The language imposes a low overhead to reading code and is resilient to changing requirements and environments.
|
|
|
|
|
|
|
|
|
|
%package -n zig-libs%{version_suffix}
|
|
|
|
|
Summary: Zig Standard Library
|
2025-09-21 04:53:45 +00:00
|
|
|
Conflicts: zig-libs < %{version_current}
|
2025-09-20 14:35:56 +00:00
|
|
|
Provides: zig-libs = %{version_current}
|
2025-10-19 18:02:19 +00:00
|
|
|
Provides: zig-libs-implementation = %{version_current}
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildArch: noarch
|
|
|
|
|
|
|
|
|
|
%description -n zig-libs%{version_suffix}
|
|
|
|
|
Zig %{version_current} Standard Library
|
|
|
|
|
|
|
|
|
|
%if %{with macro}
|
|
|
|
|
%package -n zig-rpm-macros%{version_suffix}
|
|
|
|
|
Summary: Common RPM macros for %{name}
|
|
|
|
|
Requires: rpm
|
2025-09-21 04:53:45 +00:00
|
|
|
Conflicts: zig-rpm-macros < %{version_current}
|
2025-09-20 14:35:56 +00:00
|
|
|
Provides: zig-rpm-macros = %{version_current}
|
2025-10-19 18:02:19 +00:00
|
|
|
Provides: zig-rpm-macros-implementation = %{version_current}
|
2025-09-20 14:35:56 +00:00
|
|
|
BuildArch: noarch
|
|
|
|
|
|
|
|
|
|
%description -n zig-rpm-macros%{version_suffix}
|
|
|
|
|
This package contains common RPM macros for zig in version %{version_current}.
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%prep
|
2026-01-19 08:06:46 +00:00
|
|
|
%autosetup -n zig-%{version} -p1
|
2025-09-20 14:35:56 +00:00
|
|
|
|
|
|
|
|
%build
|
2025-09-20 22:47:42 +00:00
|
|
|
%if %{without clang}
|
2025-09-20 18:21:51 +00:00
|
|
|
export CFLAGS="%{optflags} -Wno-error=return-type"
|
|
|
|
|
export CXXFLAGS="${CFLAGS}"
|
2025-09-20 22:47:42 +00:00
|
|
|
%endif
|
2025-09-20 14:35:56 +00:00
|
|
|
%cmake \
|
2025-09-20 18:21:51 +00:00
|
|
|
%if %{with clang}
|
2025-09-20 14:35:56 +00:00
|
|
|
-DCMAKE_C_COMPILER="clang-%{?clang_ver}" \
|
|
|
|
|
-DCMAKE_CXX_COMPILER="clang++-%{?clang_ver}" \
|
2025-09-20 18:21:51 +00:00
|
|
|
%else
|
|
|
|
|
%if 0%{?force_gcc_version}
|
|
|
|
|
-DCMAKE_C_COMPILER="gcc-%{?force_gcc_version}" \
|
|
|
|
|
-DCMAKE_CXX_COMPILER="g++-%{?force_gcc_version}" \
|
|
|
|
|
%endif
|
|
|
|
|
%endif
|
2026-01-27 21:54:32 +00:00
|
|
|
%if %{with has_linker_type}
|
2025-09-20 22:47:42 +00:00
|
|
|
%if %{with mold}
|
2025-09-20 14:35:56 +00:00
|
|
|
-DCMAKE_LINKER_TYPE=MOLD \
|
2025-09-20 22:47:42 +00:00
|
|
|
%else
|
|
|
|
|
-DCMAKE_LINKER_TYPE=LLD \
|
2026-01-27 21:54:32 +00:00
|
|
|
%endif
|
2025-09-20 22:47:42 +00:00
|
|
|
%endif
|
2025-09-20 14:35:56 +00:00
|
|
|
-DZIG_SHARED_LLVM=On \
|
|
|
|
|
-DZIG_USE_LLVM_CONFIG=ON \
|
2026-01-27 21:54:32 +00:00
|
|
|
-DZIG_PIE:BOOL=true \
|
2025-09-20 14:35:56 +00:00
|
|
|
-DZIG_TARGET_MCPU="baseline" \
|
|
|
|
|
-DZIG_TARGET_TRIPLE:STRING=native \
|
|
|
|
|
-DZIG_VERSION:STRING="%{version}"
|
|
|
|
|
|
|
|
|
|
# Workaround since CMAKE on Leap does not have
|
|
|
|
|
# the CMAKE_LINKER_TYPE option
|
2026-01-27 21:54:32 +00:00
|
|
|
%if %{without has_linker_type} && %{with mold}
|
2025-09-20 14:35:56 +00:00
|
|
|
mold -run %cmake_build
|
2026-01-27 21:03:33 +00:00
|
|
|
%else
|
|
|
|
|
%cmake_build
|
2025-09-20 14:35:56 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%install
|
|
|
|
|
%cmake_install
|
|
|
|
|
mkdir -p %{buildroot}%{_mandir}/man1
|
|
|
|
|
help2man --no-discard-stderr "%{buildroot}%{_bindir}/zig" --version-option=version --output=%{buildroot}%{_mandir}/man1/zig.1
|
|
|
|
|
|
|
|
|
|
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d/
|
|
|
|
|
install -p -m644 %{SOURCE1} %{buildroot}%{_rpmmacrodir}
|
|
|
|
|
|
|
|
|
|
sed -i -e "s|@@ZIG_VERSION@@|%{version}|" %{buildroot}%{_rpmmacrodir}/macros.zig
|
|
|
|
|
|
|
|
|
|
mv -v doc/langref.html.in doc/langref.html
|
|
|
|
|
|
|
|
|
|
%if 0%{?with test}
|
|
|
|
|
%check
|
|
|
|
|
./build/stage3/bin/zig build test -Dconfig_h=build/config.h \
|
|
|
|
|
-Dcpu=baseline \
|
|
|
|
|
-Dskip-debug \
|
|
|
|
|
-Dskip-release-safe \
|
|
|
|
|
-Dskip-release-small \
|
2026-01-27 21:54:32 +00:00
|
|
|
-Dstatic-llvm=false \
|
2025-09-20 14:35:56 +00:00
|
|
|
-Denable-llvm=true \
|
|
|
|
|
-Dskip-non-native=true
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%files
|
|
|
|
|
%license LICENSE
|
|
|
|
|
%{_bindir}/zig
|
|
|
|
|
%{_mandir}/man1/zig.1%{?ext_man}
|
|
|
|
|
%doc README.md
|
|
|
|
|
%doc lib/docs
|
|
|
|
|
%doc doc/langref.html
|
|
|
|
|
|
|
|
|
|
%files -n zig-libs%{version_suffix}
|
|
|
|
|
%dir %{_prefix}/lib/zig
|
|
|
|
|
%{_prefix}/lib/zig/*
|
|
|
|
|
|
2026-01-27 21:03:33 +00:00
|
|
|
%if %{with macro}
|
2025-09-20 14:35:56 +00:00
|
|
|
%files -n zig-rpm-macros%{version_suffix}
|
|
|
|
|
%{_rpmmacrodir}/macros.zig
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%changelog
|