From 7af94b3c44c1779201cd8778c0b0b431f34f6012 Mon Sep 17 00:00:00 2001 From: mattgodbolt-molty Date: Tue, 29 Sep 2026 20:35:19 -0500 Subject: [PATCH] Fix flambda configure flag and parallel builds for pre-4.08 OCaml The IS_AUTOCONF check used arithmetic -eq on strings, so it was always true and always passed --enable-flambda, which the hand-written configure used before OCaml 4.08 rejects. Detect autoconf from configure.ac in the source tree instead. Those older trees also race under make -j, so build them serially. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_019UuPJbXuMH8A4DCDNoiBiv --- build/build.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/build/build.sh b/build/build.sh index 4ab5f5c..b531578 100755 --- a/build/build.sh +++ b/build/build.sh @@ -3,17 +3,7 @@ set -ex FULL_VERSION=$1 -IS_AUTOCONF=$3 -VERSION=${FULL_VERSION} -FLAGS= -if echo ${VERSION} | grep -- '-flambda'; then - if [[ "x$IS_AUTOCONF" -eq "xyes" ]]; then - FLAGS=--enable-flambda - else - FLAGS=-flambda - fi - VERSION=${VERSION%-flambda} -fi +VERSION=${FULL_VERSION%-flambda} if echo ${VERSION} | grep 'trunk'; then echo Not supported at present @@ -43,9 +33,21 @@ mkdir -p ${STAGING_DIR} curl -L https://github.com/ocaml/ocaml/archive/${VERSION}.tar.gz | tar zxf - cd ocaml-${VERSION} +if [[ -f configure.ac ]]; then + FLAMBDA_FLAG=--enable-flambda + JOBS=$(nproc) +else + # Before 4.08 OCaml had a hand-written configure (only takes -flambda) and its Makefiles aren't parallel-safe + FLAMBDA_FLAG=-flambda + JOBS=1 +fi +FLAGS= +if [[ "${FULL_VERSION}" != "${VERSION}" ]]; then + FLAGS=${FLAMBDA_FLAG} +fi ./configure ${FLAGS} -prefix ${STAGING_DIR} -make -j$(nproc) world.opt -make -j$(nproc) install +make -j${JOBS} world.opt +make -j${JOBS} install export XZ_DEFAULTS="-T 0" tar Jcf ${OUTPUT} --transform "s,^./,./ocaml-${FULL_VERSION}/," -C ${STAGING_DIR} .