diff --git a/.gitignore b/.gitignore index 2476d59..023b23f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/zig-0.11.0.tar.xz -/zig-0.11.0.tar.xz.minisig +/zig-*.tar.xz +/zig-*.tar.xz.minisig diff --git a/0001-Fedora-bootstrap-and-extra-build-flags-support.patch b/0001-Fedora-bootstrap-and-extra-build-flags-support.patch index 61537c7..cc20f3b 100644 --- a/0001-Fedora-bootstrap-and-extra-build-flags-support.patch +++ b/0001-Fedora-bootstrap-and-extra-build-flags-support.patch @@ -1,29 +1,31 @@ -From 83a3cf50d81b65809d4a4619502295b4b5ff8636 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 20 Oct 2023 04:49:46 +0000 -Subject: [PATCH 1/2] Fedora: bootstrap and extra build flags support +Subject: [PATCH] Fedora: bootstrap and extra build flags support - Allow passing ZIG_EXTRA_BUILD_FLAGS for stage3 build. - Allow redefining ZIG_EXECUTABLE and short-circuiting to stage3 build when using a prebuilt compiler from bootstrap package. - Bump required CMake version to 3.14 to enable generator expression expansion in `install(CODE ...)`. + +Signed-off-by: Jan200101 --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt -index f1289e20b..031654dee 100644 +index e677ee0947..1fb4821b60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) + include(CheckSymbolExists) if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING -@@ -859,6 +859,10 @@ else() - set(ZIG_PIE_ARG "") +@@ -910,6 +910,10 @@ else() + set(ZIG_DYNAMIC_LINKER_ARG "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}") endif() +# Fedora customizations @@ -31,17 +33,17 @@ index f1289e20b..031654dee 100644 +set(ZIG_EXECUTABLE "$" CACHE STRING "Compiler command to use for stage3 build") + # -Dno-langref is currently hardcoded because building the langref takes too damn long - # -Dno-autodocs is currently hardcoded because the C backend generates a miscompilation - # that prevents it from working. -@@ -877,6 +881,7 @@ set(ZIG_BUILD_ARGS - "-Dtarget=${ZIG_TARGET_TRIPLE}" + # To obtain these two forms of documentation, run zig build against stage3 rather than stage2. + set(ZIG_BUILD_ARGS +@@ -926,6 +930,7 @@ set(ZIG_BUILD_ARGS "-Dcpu=${ZIG_TARGET_MCPU}" + ${ZIG_DYNAMIC_LINKER_ARG} "-Dversion-string=${RESOLVED_ZIG_VERSION}" + ${ZIG_EXTRA_BUILD_ARGS} ) add_custom_target(stage3 ALL -@@ -885,17 +890,12 @@ add_custom_target(stage3 ALL +@@ -934,17 +939,12 @@ add_custom_target(stage3 ALL add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/stage3/bin/zig" @@ -61,6 +63,3 @@ index f1289e20b..031654dee 100644 install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")") install(CODE "set(ZIG_BUILD_ARGS \"${ZIG_BUILD_ARGS}\")") install(CODE "set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") --- -2.41.0 - diff --git a/0002-Enable-build-id-by-default.patch b/0002-Enable-build-id-by-default.patch index dc955dc..e29227c 100644 --- a/0002-Enable-build-id-by-default.patch +++ b/0002-Enable-build-id-by-default.patch @@ -1,25 +1,23 @@ -From 4e1416ebff98155b07031790ec1afcb0035fb2ab Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 20 Oct 2023 04:49:54 +0000 -Subject: [PATCH 2/2] Enable build-id by default +Subject: [PATCH] Enable build-id by default +Signed-off-by: Jan200101 --- src/Compilation.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilation.zig b/src/Compilation.zig -index a08c3e09f..95ade766a 100644 +index 7af3d7bfd1..78bc2b65c8 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig -@@ -807,7 +807,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { - const unwind_tables = options.want_unwind_tables orelse - (link_libunwind or target_util.needUnwindTables(options.target)); - const link_eh_frame_hdr = options.link_eh_frame_hdr or unwind_tables; +@@ -1230,7 +1230,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil + const any_sanitize_thread = options.config.any_sanitize_thread or options.root_mod.sanitize_thread; + + const link_eh_frame_hdr = options.link_eh_frame_hdr or any_unwind_tables; - const build_id = options.build_id orelse .none; + const build_id = options.build_id orelse .sha1; - // Make a decision on whether to use LLD or our own linker. - const use_lld = options.use_lld orelse blk: { --- -2.41.0 - + const link_libc = options.config.link_libc; + diff --git a/0003-fetch-prevent-global-cache-from-being-copied.patch b/0003-fetch-prevent-global-cache-from-being-copied.patch new file mode 100644 index 0000000..df7b041 --- /dev/null +++ b/0003-fetch-prevent-global-cache-from-being-copied.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jan200101 +Date: Sun, 12 May 2024 18:20:19 +0200 +Subject: [PATCH] fetch: prevent global cache from being copied + +Signed-off-by: Jan200101 +--- + src/Package/Fetch.zig | 33 +++++++++++++++++++++------------ + 1 file changed, 21 insertions(+), 12 deletions(-) + +diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig +index 506075e921..ca11f4c579 100644 +--- a/src/Package/Fetch.zig ++++ b/src/Package/Fetch.zig +@@ -1248,6 +1248,7 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource) anyerror!Unpac + + fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void { + const gpa = f.arena.child_allocator; ++ const cache_root = f.job_queue.global_cache; + // Recursive directory copy. + var it = try dir.walk(gpa); + defer it.deinit(); +@@ -1255,18 +1256,26 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void + switch (entry.kind) { + .directory => {}, // omit empty directories + .file => { +- dir.copyFile( +- entry.path, +- tmp_dir, +- entry.path, +- .{}, +- ) catch |err| switch (err) { +- error.FileNotFound => { +- if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(dirname); +- try dir.copyFile(entry.path, tmp_dir, entry.path, .{}); +- }, +- else => |e| return e, +- }; ++ const full_path = try dir.realpathAlloc(gpa, entry.path); ++ defer gpa.free(full_path); ++ ++ const cache_path = try cache_root.handle.realpathAlloc(gpa, "."); ++ defer gpa.free(cache_path); ++ ++ if (!std.mem.startsWith(u8, full_path, cache_path)) { ++ dir.copyFile( ++ entry.path, ++ tmp_dir, ++ entry.path, ++ .{}, ++ ) catch |err| switch (err) { ++ error.FileNotFound => { ++ if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(dirname); ++ try dir.copyFile(entry.path, tmp_dir, entry.path, .{}); ++ }, ++ else => |e| return e, ++ }; ++ } + }, + .sym_link => { + var buf: [fs.MAX_PATH_BYTES]u8 = undefined; diff --git a/macros.zig b/macros.zig index dcb6059..969c861 100644 --- a/macros.zig +++ b/macros.zig @@ -1,6 +1,8 @@ %zig_arches x86_64 aarch64 riscv64 %{mips64} -%zig /usr/bin/zig +%zig %{_bindir}/zig + +%_zig_cache_dir zig-cache # expected features for each arch when targeting baseline # found in https://github.com/ziglang/zig/tree/master/lib/std/target @@ -18,24 +20,38 @@ # mips32 %_zig_cpu baseline %_zig_target native +%_zig_release_mode safe # seperated build options -%_zig_general_options --verbose -%_zig_project_options -Dtarget=%{_zig_target} -Dcpu=%{_zig_cpu} -Doptimize=ReleaseSafe -%_zig_advanced_options --cache-dir zig-cache +%_zig_general_options --verbose --release=%{_zig_release_mode} +%_zig_project_options -Dtarget=%{_zig_target} -Dcpu=%{_zig_cpu} +%_zig_system_integration --system %{_zig_cache_dir} +%_zig_advanced_options --cache-dir %{_zig_cache_dir} --global-cache-dir %{_zig_cache_dir} -%_zig_build_options %{?_zig_general_options} %{?_zig_project_options} %{?_zig_advanced_options} +%_zig_build_options %{?_zig_general_options} %{?_zig_project_options} %{?%_zig_system_integration} %{?_zig_advanced_options} %_zig_install_options --prefix "%{_prefix}" --prefix-lib-dir "%{_libdir}" --prefix-exe-dir "%{_bindir}" --prefix-include-dir "%{_includedir}" +%_zig_fetch_options --global-cache-dir %{_zig_cache_dir} -%zig_build %zig \\\ - build \\\ - %{?_zig_build_options} +%zig_build %{shrink: \ + %zig \ + build \ + %{?_zig_build_options} \ +} -%zig_install \ - DESTDIR="%{buildroot}" %zig_build \\\ - install \\\ - %{?_zig_install_options} +%zig_install %{shrink: \ + DESTDIR="%{buildroot}" \ + %zig_build \ + install \ + %{?_zig_install_options} \ +} -%zig_test \ - %zig_build \\\ +%zig_fetch %{shrink: \ + %zig \ + fetch \ + %{?_zig_fetch_options} \ +} + +%zig_test %{shrink: \ + %zig_build \ test +} diff --git a/sources b/sources index 16e07e6..ab9f6ae 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (zig-0.11.0.tar.xz) = c19a8ae6d440a16dd5e77941fc77c036d1f284f1784376625e63b65f30b4acad62f9f4217bc818c401f88c2c33f8722f26fc467c3e23c29a89178c4b1882d1c4 -SHA512 (zig-0.11.0.tar.xz.minisig) = 565dd1eacb7dd697e6b1ff54517adc1e4775d2523afaeb4f9a3dd404df871b187862211ecbbcf90b42e3a03853677fc1603e7fc8fc5ba7126a054679faa601ca +SHA512 (zig-0.12.0.tar.xz) = 0c3d9396fea4905245c7e32ce6bd9b4ff140f061cd8a957929e4c84cf105f5bbcbf2e7c030013ac649edb569e909f65d928b3e8a86f35c9076fb62e996feea14 +SHA512 (zig-0.12.0.tar.xz.minisig) = 6e14c1e1926beeb249cb88fb2247ff401f679b64785c3ec8a924e33c894174deb77b48286469a863761bce0ca57524f904995eacf544919dda387c140e6e829e diff --git a/zig.spec b/zig.spec index cd5c9fd..3014311 100644 --- a/zig.spec +++ b/zig.spec @@ -1,25 +1,23 @@ -# https://ziglang.org/download/%{version}/release-notes.html#Support-Table -# 32 bit builds currently run out of memory https://github.com/ziglang/zig/issues/6485 +# 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 # note here at which Fedora or EL release we need to use compat LLVM packages -%if 0%{?fedora} >= 39 || 0%{?rhel} >= 9 -%define llvm_compat 16 +%if 0%{?fedora} >= 40 || 0%{?rhel} >= 9 +%define llvm_compat 17 %endif -%global llvm_version 16.0.0 - +%global llvm_version 17.0.0 %bcond bootstrap 0 -%bcond docs %{without bootstrap} -%bcond macro %{without bootstrap} -%bcond test 1 +%bcond docs %{without bootstrap} +%bcond macro %{without bootstrap} +%bcond test 1 Name: zig -Version: 0.11.0 -Release: 2%{?dist} +Version: 0.12.0 +Release: 1%{?dist} Summary: Programming language for maintaining robust, optimal, and reusable software License: MIT and NCSA and LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and ISC and Public Domain and GFDL and ZPLv2.1 @@ -32,6 +30,9 @@ Patch: 0001-Fedora-bootstrap-and-extra-build-flags-support.patch # There's no global option for build-id so enable it by default # instead of patching every project's build.zig Patch: 0002-Enable-build-id-by-default.patch +# Zig fetch will recurse onto the cache directory, prevent that from happening. +# https://github.com/ziglang/zig/pull/19951 +Patch: 0003-fetch-prevent-global-cache-from-being-copied.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -62,7 +63,7 @@ Requires: %{name}-libs = %{version} # Apache-2.0 WITH LLVM-exception OR NCSA OR MIT Provides: bundled(compiler-rt) = %{llvm_version} # LGPLv2+, LGPLv2+ with exceptions, GPLv2+, GPLv2+ with exceptions, BSD, Inner-Net, ISC, Public Domain and GFDL -Provides: bundled(glibc) = 2.34 +Provides: bundled(glibc) = 2.38 # 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 @@ -70,7 +71,7 @@ Provides: bundled(libcxxabi) = %{llvm_version} # NCSA Provides: bundled(libunwind) = %{llvm_version} # BSD, LGPG, ZPL -Provides: bundled(mingw) = 10.0.0 +Provides: bundled(mingw) = 0bac2d3cdb122dadcdee90009f7e24a69d56939f # MIT Provides: bundled(musl) = 1.2.4 # Apache-2.0 WITH LLVM-exception AND Apache-2.0 AND MIT AND BSD-2-Clause @@ -126,10 +127,14 @@ rm -f stage1/zig1.wasm -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;-Dbuild-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}" \ %{!?with_bootstrap:-DZIG_EXECUTABLE:STRING="/usr/bin/zig"} # Build only stage3 and dependencies. Skips stage1/2 if using /usr/bin/zig @@ -140,7 +145,10 @@ rm -f stage1/zig1.wasm help2man --no-discard-stderr --no-info "%{__cmake_builddir}/stage3/bin/zig" --version-option=version --output=%{name}.1 %if %{with docs} -"%{__cmake_builddir}/stage3/bin/zig" build docs --verbose -Dversion-string="%{version}" +"%{__cmake_builddir}/stage3/bin/zig" build docs \ + --verbose \ + --global-cache-dir zig-cache \ + -Dversion-string="%{version}" %endif %install @@ -179,6 +187,9 @@ install -D -pv -m 0644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}/macros.%{name} %endif %changelog +* Sat May 25 2024 Jan200101 - 0.12.0-1 +- Update to 0.12.0 + * Wed Feb 21 2024 Jan Drögehoff - 0.11.0-2 - Rebuilt for bootstrapping