Andreas Klebinger pushed to branch wip/andreask/hadrian_build_par at Glasgow Haskell Compiler / GHC
Commits:
-
b65ce27c
by Andreas Klebinger at 2026-02-19T09:27:54+01:00
1 changed file:
Changes:
| ... | ... | @@ -23,9 +23,52 @@ fi |
| 23 | 23 | CABVERSTR=$("$CABAL" --numeric-version)
|
| 24 | 24 | CABVER=( ${CABVERSTR//./ } )
|
| 25 | 25 | |
| 26 | +THREADS="-j1"
|
|
| 27 | +GC_THREADS=""
|
|
| 28 | +SEMAPHORE=""
|
|
| 29 | + |
|
| 30 | +echo "$@"
|
|
| 31 | + |
|
| 32 | +# Try building hadrian in parallel. We check for -j<n>.
|
|
| 33 | +# If threads > 1 we pass --semaphore to allow ghc to build more than one module in parallel
|
|
| 34 | +# If threads > 4 we pass -qn as higher parallel gc thread counts can lead to slow downs
|
|
| 35 | +# We only do any of thise for cabal >= 3.14, because I don't trust older versions to handle --semaphore right
|
|
| 36 | +if [ "${CABVER[0]}" -gt 3 ] || [ "${CABVER[0]}" -eq 3 -a "${CABVER[1]}" -ge 14 ];
|
|
| 37 | +then
|
|
| 38 | + |
|
| 39 | + for arg in "$@"; do
|
|
| 40 | + case "$arg" in
|
|
| 41 | + -j)
|
|
| 42 | + GC_THREADS="-qn4"
|
|
| 43 | + SEMAPHORE="--semaphore"
|
|
| 44 | + THREADS="-j"
|
|
| 45 | + ;;
|
|
| 46 | + -j[0-9]*)
|
|
| 47 | + threads="${arg#-j}"
|
|
| 48 | + if [[ "$threads" =~ ^[0-9]+$ ]] && [ "$threads" -ne 0 ]; then
|
|
| 49 | + THREADS="-j${threads}"
|
|
| 50 | + if [ $threads -ge 4 ]; then
|
|
| 51 | + GC_THREADS="-qn4"
|
|
| 52 | + fi
|
|
| 53 | + if [ $threads -gt 1 ]; then
|
|
| 54 | + SEMAPHORE="--semaphore"
|
|
| 55 | + fi
|
|
| 56 | + fi
|
|
| 57 | + ;;
|
|
| 58 | + esac
|
|
| 59 | + |
|
| 60 | + done
|
|
| 61 | + |
|
| 62 | +fi
|
|
| 63 | + |
|
| 64 | +if [ "$(uname -s)" = "FreeBSD" ]; then
|
|
| 65 | + # Can't rely on posix semaphore support in free bsd.
|
|
| 66 | + SEMAPHORE=""
|
|
| 67 | +fi
|
|
| 68 | + |
|
| 26 | 69 | if [ "${CABVER[0]}" -gt 2 -o "${CABVER[0]}" -eq 2 -a "${CABVER[1]}" -ge 2 ];
|
| 27 | 70 | then
|
| 28 | - "$CABAL" --project-file="$PROJ" new-build "${CABFLAGS[@]}" -j exe:hadrian
|
|
| 71 | + "$CABAL" --project-file="$PROJ" new-build "${CABFLAGS[@]}" ${THREADS} ${SEMAPHORE} --ghc-options="+RTS ${GC_THREADS} -RTS" exe:hadrian
|
|
| 29 | 72 | # use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH
|
| 30 | 73 | "$CABAL" --project-file="$PROJ" new-exec "${CABFLAGS[@]}" hadrian -- \
|
| 31 | 74 | --directory "$PWD" \
|