--- a/build.sh 2025-12-19 19:30:12.000000000 +0800 +++ b/build.sh 2025-12-19 23:18:46.000000000 +0800 @@ -60,8 +60,8 @@ fi CC="sem -j $parallel --id $$ ${CC}" fi -COMP_FLAGS="${CPPFLAGS:-} ${CFLAGS:-} -w -fmax-errors=3 -fno-strict-aliasing $extraBuildArgs" -LINK_FLAGS="${LDFLAGS:-} " +COMP_FLAGS="${CPPFLAGS:-} ${CFLAGS:-} -isystem@PREFIX@/include/LegacySupport -w -fmax-errors=3 -fno-strict-aliasing $extraBuildArgs" +LINK_FLAGS="${LDFLAGS:-} -L@PREFIX@/lib -lMacportsLegacySupport" PS4="" # platform detection ucpu=`uname -m` --- a/makefile 2025-12-19 19:30:12.000000000 +0800 +++ b/makefile 2025-12-19 23:18:40.000000000 +0800 @@ -3,7 +3,7 @@ # To regenerate run ``niminst csource`` or ``koch csource`` CC ?= gcc -CFLAGS += -Ic_code -w -fmax-errors=3 -fno-strict-aliasing +CFLAGS += -Ic_code -isystem@PREFIX@/include/LegacySupport -w -fmax-errors=3 -fno-strict-aliasing LDFLAGS += binDir = bin @@ -47,7 +47,7 @@ ifeq ($(uos),darwin) myos = macosx CC = gcc - LDFLAGS += -ldl -lm + LDFLAGS += -L@PREFIX@/lib -lMacportsLegacySupport -ldl -lm ifeq ($(HOSTTYPE),x86_64) ucpu = amd64 endif --- a/config/nim.cfg +++ b/config/nim.cfg 2025-12-22 12:19:19.000000000 +0800 @@ -216,6 +216,10 @@ # Options for Mac OS X. Mac OS X uses its own Objective-C stack that is # totally different from GNUStep. @if macosx: + gcc.options.always %= "-isystem@PREFIX@/include/LegacySupport ${gcc.options.always}" + gcc.cpp.options.always %= "-isystem@PREFIX@/include/LegacySupport ${gcc.cpp.options.always}" + gcc.options.linker = "-lMacportsLegacySupport" + gcc.cpp.options.linker = "-lMacportsLegacySupport" gcc.objc.options.linker = "-framework Foundation" llvm_gcc.objc.options.linker = "-framework Foundation" clang.objc.options.linker = "-framework Foundation" --- a/lib/std/sysrand.nim 2025-12-22 13:15:41.000000000 +0800 +++ b/lib/std/sysrand.nim 2025-12-22 13:18:38.000000000 +08000 @@ -66,7 +66,7 @@ import std/assertions const - batchImplOS = defined(freebsd) or defined(openbsd) or defined(zephyr) + batchImplOS = defined(freebsd) or defined(openbsd) or defined(macosx) or defined(zephyr) batchSize {.used.} = 256 when batchImplOS: @@ -232,7 +232,16 @@ proc getRandomImpl(p: pointer, size: int): int {.inline.} = result = getrandom(p, csize_t(size), 0) -elif defined(ios) or defined(macosx): +elif defined(macosx): + proc getentropy(p: pointer, size: cint): cint {.importc: "getentropy", header: "".} + # Fills a buffer with high-quality entropy, + # which can be used as input for process-context pseudorandom generators like `arc4random`. + # The maximum buffer size permitted is 256 bytes. + + proc getRandomImpl(p: pointer, size: int): int {.inline.} = + result = getentropy(p, cint(size)).int + +elif defined(ios): {.passl: "-framework Security".} const errSecSuccess = 0 ## No error.