#!/bin/bash cd $(dirname "$0") if [ x"$CC" == x ]; then export CC=cc fi if command -v ccache > /dev/null; then export CC="ccache $CC" fi echo '==========================================' echo '=== Building bootstrap compiler (cff0) ===' echo '==========================================' ./build.sh || exit 1 export CFLAGS="-Wno-builtin-declaration-mismatch -Wno-discarded-qualifiers -g" set -euo pipefail echo "extern static host_target_triple const *const u8 = \"`clang -print-target-triple`\";" > ../src/host-target-triple.cff echo '=====================================================================' echo '=== Building self-hosted compiler using bootstrap compiler (cff1) ===' echo '=====================================================================' mkdir -p obj1/ for f in $(find ../src/ -name '*.cff'); do out=obj1/$(basename "$f").o (set -x ; ./cff0 "$f" | $CC $CFLAGS -xc - -c -o $out) done for f in $(find ../src/ -name '*.c'); do out=obj1/$(basename "$f").o (set -x ; $CC $CFLAGS "$f" -c -o $out) done :$(set -x ; $CC $CFLAGS -ocff1 obj1/*.o) echo '=======================================================================' echo '=== Building self-hosted compiler using self-hosted compiler (cff2) ===' echo '=======================================================================' OUT=bootstrap/cff2 CFFC=$(dirname "$0")/cff1 make -C ../ echo '===============================================================================' echo '=== Building self-hosted compiler using self-hosted compiler squared (cffc) ===' echo '===============================================================================' CFFC=$(dirname "$0")/cff2 make -C ../ clean all