Files
macports-ports/lang/zig-bootstrap/files/patch-parallel.diff
2026-05-06 17:36:24 +08:00

65 lines
2.0 KiB
Diff

--- build 2026-04-14 04:52:27
+++ build 2026-05-03 21:06:47
@@ -5,7 +5,12 @@
TARGET="$1" # Example: riscv64-linux-gnu
MCPU="$2" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`
+JOBS="${3:-}" # Optional: number of parallel jobs
+if [ -z "$JOBS" ]; then
+ JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)"
+fi
+
ROOTDIR="$(pwd)"
ZIG_VERSION="0.16.0"
@@ -56,7 +61,7 @@
-DCLANG_TOOL_CLANG_LINKER_WRAPPER_BUILD=OFF \
-DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF \
-DCLANG_TOOL_LIBCLANG_BUILD=OFF
-cmake --build . --target install
+cmake --build . --target install --parallel "$JOBS"
# Now we build Zig, still with system C/C++ compiler, linking against LLVM,
# Clang, LLD we just built from source.
@@ -67,7 +72,7 @@
-DCMAKE_PREFIX_PATH="$ROOTDIR/out/host" \
-DCMAKE_BUILD_TYPE=Release \
-DZIG_VERSION="$ZIG_VERSION"
-cmake --build . --target install
+cmake --build . --target install --parallel "$JOBS"
# Now we have Zig as a cross compiler.
ZIG="$ROOTDIR/out/host/bin/zig"
@@ -89,7 +94,7 @@
-DCMAKE_RC_COMPILER="$ROOTDIR/out/host/bin/llvm-rc" \
-DCMAKE_AR="$ROOTDIR/out/host/bin/llvm-ar" \
-DCMAKE_RANLIB="$ROOTDIR/out/host/bin/llvm-ranlib"
-cmake --build . --target install
+cmake --build . --target install --parallel "$JOBS"
# Same deal for zstd.
# The build system for zstd is whack so I just put all the files here.
@@ -97,6 +102,7 @@
cp "$ROOTDIR/zstd/lib/zstd.h" "$ROOTDIR/out/$TARGET-$MCPU/include/zstd.h"
cd "$ROOTDIR/out/$TARGET-$MCPU/lib"
$ZIG build-lib \
+ -j"$JOBS" \
--name zstd \
-target $TARGET \
-mcpu=$MCPU \
@@ -190,11 +196,12 @@
-DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF \
-DCLANG_TOOL_LIBCLANG_BUILD=OFF \
-DLLD_BUILD_TOOLS=OFF
-cmake --build . --target install
+cmake --build . --target install --parallel "$JOBS"
# Finally, we can cross compile Zig itself, with Zig.
cd "$ROOTDIR/zig"
$ZIG build \
+ -j"$JOBS" \
--prefix "$ROOTDIR/out/zig-$TARGET-$MCPU" \
--search-prefix "$ROOTDIR/out/$TARGET-$MCPU" \
-Dflat \