git: 943322cf87a2 - main - lang/nim: fix on powerpc64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Oct 2026 09:32:14 UTC
The branch main has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/ports/commit/?id=943322cf87a27b08b503f2cc1d355e80fe3b720b
commit 943322cf87a27b08b503f2cc1d355e80fe3b720b
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-18 18:21:49 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-10-19 09:31:45 +0000
lang/nim: fix on powerpc64
countProcessors() reads the 4-byte hw.ncpu into an 8-byte int, which puts
it in the high word on big-endian, so any nim c without --parallelBuild
tried to size its build state for 2^38 CPUs and got OOM-killed. That is
also why DOCS was turned off on powerpc64 in 2020, so enable it again.
Also take the upstream fix for the shr constant folding on big-endian and
apply it to the pre-generated bootstrap compiler too.
---
lang/nim/Makefile | 5 ++++-
lang/nim/distinfo | 4 +++-
lang/nim/files/patch-c__code_5__2__msemfold.nim.c | 22 +++++++++++++++++++
.../files/patch-lib_pure_concurrency_cpuinfo.nim | 25 ++++++++++++++++++++++
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/lang/nim/Makefile b/lang/nim/Makefile
index d99a6d1aa557..129887c2feca 100644
--- a/lang/nim/Makefile
+++ b/lang/nim/Makefile
@@ -1,7 +1,11 @@
PORTNAME= nim
DISTVERSION= 2.2.12
+PORTREVISION= 1
CATEGORIES= lang
MASTER_SITES= https://nim-lang.org/download/
+# e97b0bb541ee: semfold folded shr wrongly on big-endian hosts
+PATCH_SITES= https://github.com/nim-lang/Nim/commit/
+PATCHFILES= e97b0bb541ee182c4f38709e2dbbaee03be12138.patch:-p1
MAINTAINER= ports@nicandneal.net
COMMENT= Nim programming language
@@ -20,7 +24,6 @@ SUB_FILES= pkg-message
OPTIONS_DEFINE= DOCS TOOLS
OPTIONS_DEFAULT= TOOLS
-OPTIONS_EXCLUDE_powerpc64= DOCS
OPTIONS_SUB= yes
TOOLS_DESC= Build and install nim tools, not including nimble nor nimfind
diff --git a/lang/nim/distinfo b/lang/nim/distinfo
index c68e657922dd..aa7371e6828d 100644
--- a/lang/nim/distinfo
+++ b/lang/nim/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1788942773
+TIMESTAMP = 1792345642
SHA256 (nim-2.2.12.tar.xz) = 2639a06a5ea7a7fcf57df1e7e1ef4d1b2bee58c7ac9bd00dbd2aa5bea1e5a56a
SIZE (nim-2.2.12.tar.xz) = 10259940
+SHA256 (e97b0bb541ee182c4f38709e2dbbaee03be12138.patch) = 487082111e65a2d9da145134ff9da7d54c258a2ee96e26792a8f71671a4dc4c7
+SIZE (e97b0bb541ee182c4f38709e2dbbaee03be12138.patch) = 1619
diff --git a/lang/nim/files/patch-c__code_5__2__msemfold.nim.c b/lang/nim/files/patch-c__code_5__2__msemfold.nim.c
new file mode 100644
index 000000000000..bb47c92ba1f0
--- /dev/null
+++ b/lang/nim/files/patch-c__code_5__2__msemfold.nim.c
@@ -0,0 +1,22 @@
+The pre-generated bootstrap compiler reinterprets the first 8 bytes of an
+Int128 (an array of uint32 words, least significant first) as uint64 when
+folding shr, which only works on little-endian. Same fix as upstream
+e97b0bb541ee (castToUInt64) applied to the generated C.
+
+--- c_code/5_2/@msemfold.nim.c.orig 2026-09-08 04:06:18 UTC
++++ c_code/5_2/@msemfold.nim.c
+@@ -3172,12 +3172,12 @@
+ T183_ = getInt__ast_u7046(a_p2);
+ if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
+ LOC182.source = T183_;
+- a_2 = LOC182.dest;
++ a_2 = ((NU64)(LOC182.source.udata[0]) | ((NU64)(LOC182.source.udata[1]) << 32));
+ nimZeroMem((void*)(&T185_), sizeof(tyObject_Int128__Moyhy3H7f18q9axhPc7Yt9bg));
+ T185_ = getInt__ast_u7046(b_p3);
+ if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
+ LOC184.source = T185_;
+- b_2 = (NU64)(LOC184.dest & ((NU64) ((NI64)((NI64)((*(*n_p1).typField).size * IL64(8)) - IL64(1)))));
++ b_2 = (NU64)(((NU64)(LOC184.source.udata[0]) | ((NU64)(LOC184.source.udata[1]) << 32)) & ((NU64) ((NI64)((NI64)((*(*n_p1).typField).size * IL64(8)) - IL64(1)))));
+ {
+ tyObject_TType__8qAQZfpTDk89aeclTNn4d9cg* colontmpD__6;
+ if (!((NU64)(0ULL) < (NU64)(b_2))) goto LA188_;
diff --git a/lang/nim/files/patch-lib_pure_concurrency_cpuinfo.nim b/lang/nim/files/patch-lib_pure_concurrency_cpuinfo.nim
new file mode 100644
index 000000000000..2c4538a80253
--- /dev/null
+++ b/lang/nim/files/patch-lib_pure_concurrency_cpuinfo.nim
@@ -0,0 +1,25 @@
+--- lib/pure/concurrency/cpuinfo.nim.orig 2026-10-18 17:48:12 UTC
++++ lib/pure/concurrency/cpuinfo.nim
+@@ -78,15 +78,18 @@ else:
+ getSystemInfo(addr si)
+ result = int(si.dwNumberOfProcessors)
+ elif defined(macosx) or defined(bsd):
+- let dest = addr result
+- var len = sizeof(result).csize_t
++ # hw.ncpu is a C int; reading it into the full-width result would leave
++ # it in the high word on big-endian hosts
++ var ncpu: cint = 0
++ let dest = addr ncpu
++ var len = sizeof(ncpu).csize_t
+ when defined(macosx):
+ # alias of "hw.activecpu"
+ if sysctlbyname("hw.logicalcpu", dest, len, nil, 0) == 0:
+- return
++ return int(ncpu)
+ var mib = [CTL_HW, HW_NCPU]
+ if sysctl(mib, 2, dest, len, nil, 0) == 0:
+- return
++ return int(ncpu)
+ elif defined(hpux):
+ result = mpctl(MPC_GETNUMSPUS, nil, nil)
+ elif defined(irix):