Subject: [PATCH] gnu: zig: Set rss_max to unlimited
From: Tommy Langhelle <[email-masked]>
To: [email-masked]
Cc: Tommy Langhelle <[email-masked]>
Date: Tue, 1 Apr 2025 10:33:36 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Upstream sets this for CI purposes, but it fails my ARM builds. The
limit itself doesn't make too much sense as long as zig builds and the
build host is big enough, so simply allowing unlimited rss should be
fine.

* gnu/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch: New file.
* gnu/packages/zig.scm (zig-0.14)[source]: Add patch.
* gnu/local.mk (dist_patch_DATA): Register it.
---
 gnu/local.mk                                  |  1 +
 ...ax_rss-to-unlimited-for-building-zig.patch | 31 +++++++++++++++++++
 gnu/packages/zig.scm                          |  3 +-
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f03fcb14fc..63e87a232e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2473,6 +2473,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/zig-0.14-fix-runpath.patch		\
   %D%/packages/patches/zig-0.14-use-baseline-cpu-by-default.patch	\
   %D%/packages/patches/zig-0.14-use-system-paths.patch		\
+  %D%/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch		\
   %D%/packages/patches/zsh-egrep-failing-test.patch		\
   %D%/packages/patches/zuo-bin-sh.patch
 
diff --git a/gnu/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch b/gnu/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch
new file mode 100644
index 0000000000..d944827353
--- /dev/null
+++ b/gnu/packages/patches/zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch
@@ -0,0 +1,31 @@
+From 408722e084edf0a86066344e29bdfced70679129 Mon Sep 17 00:00:00 2001
+From: Tommy Langhelle <[email-masked]>
+Date: Mon, 31 Mar 2025 11:47:12 +0200
+Subject: [PATCH] Set max_rss to unlimited for building zig
+
+https://github.com/ziglang/zig/issues/18263
+
+Upstream sets this for CI purposes, but it fails my ARM builds. The
+limit itself doesn't make too much sense as long as zig builds and the
+build host is big enough, so simply allowing unlimited rss should be
+fine.
+---
+ build.zig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/build.zig b/build.zig
+index 375cb6df09..16862fc5f9 100644
+--- a/build.zig
++++ b/build.zig
+@@ -703,7 +703,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
+ 
+     const exe = b.addExecutable(.{
+         .name = "zig",
+-        .max_rss = 7_800_000_000,
++        .max_rss = 0,
+         .root_module = compiler_mod,
+     });
+     exe.stack_size = stack_size;
+-- 
+2.41.0
+
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 733251242e..eb7bda8c62 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -1871,7 +1871,8 @@ (define-public zig-0.14
         (search-patches
          "zig-0.14-use-baseline-cpu-by-default.patch"
          "zig-0.14-use-system-paths.patch"
-         "zig-0.14-fix-runpath.patch"))))
+         "zig-0.14-fix-runpath.patch"
+         "zig-0.14-set-max_rss-to-unlimited-for-building-zig.patch"))))
     (inputs
      (modify-inputs (package-inputs zig-0.13)
        (replace "clang" clang-19)

base-commit: e7aeec67feaa5cf888f0aae14400fc015390aa8e
-- 
2.41.0