--- a/bazel/foreign_cc/luajit.patch +++ b/bazel/foreign_cc/luajit.patch @@ -56,7 +56,7 @@ index 00000000..3b4f8eca --- /dev/null +++ b/luajit_build.sh -@@ -0,0 +1,79 @@ +@@ -0,0 +1,86 @@ +#!/bin/bash + +set -e @@ -107,6 +107,11 @@ + # Clear LDFLAGS so cross-compilation flags (--target, --sysroot) are not applied + # when linking host build tools (e.g. minilua) via make's implicit rules. + export LDFLAGS="" ++elif [[ "$(uname -s)" == "FreeBSD" ]]; then ++ EXTRA_MAKE_ARGS+=("TARGET_AR=${AR} ${ARFLAGS:-rcus}") ++ export TARGET_CFLAGS="${TARGET_CFLAGS} -fno-stack-protector -U_FORTIFY_SOURCE" ++ export TARGET_LDFLAGS="${LDFLAGS:-} -fno-function-sections -fno-data-sections" ++ export CFLAGS="" +else + # macOS: extract sysroot from CFLAGS and pass to HOST_CFLAGS/HOST_LDFLAGS for building host tools + SYSROOT_FLAG=$(echo "$CFLAGS" | grep -o -- '--sysroot=[^ ]*' || :) @@ -133,6 +138,7 @@ +fi + +# Run make with all available cores -+"${MAKE:-make}" -j$(nproc) V=1 PREFIX="$PREFIX" \ ++NPROC=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) ++"${MAKE:-make}" -j${NPROC} V=1 PREFIX="$PREFIX" \ + "${EXTRA_MAKE_ARGS[@]}" \ + install