#!/bin/bash

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"

cd "${REPO_ROOT}"

for opt in 0 1 2 3; do
  echo "==> Building host binaries with -O${opt}"
  make TARGET=host OPT_CFLAGS="-O${opt}" run-tests
  find . -maxdepth 2 -type f -name '*.host' -execdir mv {} {}.O${opt} \;
done

echo "All host optimization builds complete."
