From 8c49e2d738656fbe5f46583997bfef62fdf713db Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Fri, 27 Jun 2025 16:05:20 -0600 Subject: [PATCH] Generate self-hosted with installed compiler --- self_hosted_build.sh | 11 +++++++++ self_hosted_generate.sh | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 self_hosted_build.sh create mode 100755 self_hosted_generate.sh diff --git a/self_hosted_build.sh b/self_hosted_build.sh new file mode 100755 index 0000000..00cb859 --- /dev/null +++ b/self_hosted_build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -eu +if [[ -z "${BOOTSTRAP_COMPILER:-}" ]]; then + BOOTSTRAP_COMPILER=$HOME/bloat-buster-artifacts/releases/main/compiler_generic +fi + +if [[ -z "${CMAKE_PREFIX_PATH:-}" ]]; then + CMAKE_PREFIX_PATH=$HOME/dev/llvm/install/llvm_20.1.7_x86_64-linux-Release +fi + +$BOOTSTRAP_COMPILER compile src/compiler.bbb diff --git a/self_hosted_generate.sh b/self_hosted_generate.sh new file mode 100755 index 0000000..74f4091 --- /dev/null +++ b/self_hosted_generate.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -eux + +if [[ -z "${LLVM_VERSION:-}" ]]; then + LLVM_VERSION=20.1.7 +fi + +if [[ -z "${BB_CI:-}" ]]; then + BB_CI=0 +fi + +if [[ -z "${CMAKE_BUILD_TYPE:-}" ]]; then + CMAKE_BUILD_TYPE=Debug + LLVM_CMAKE_BUILD_TYPE=Release +else + LLVM_CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE +fi + +BIRTH_NATIVE_OS_STRING=$OSTYPE + +case "$BIRTH_NATIVE_OS_STRING" in + darwin*) BIRTH_OS="macos";; + linux*) BIRTH_OS="linux";; + msys*) BIRTH_OS="windows";; + *) exit 1 +esac + +BIRTH_NATIVE_ARCH_STRING="$(uname -m)" + +case "$BIRTH_NATIVE_ARCH_STRING" in + x86_64) BIRTH_ARCH="x86_64";; + arm64) BIRTH_ARCH="aarch64";; + *) exit 1 +esac + +if [[ -z "${CMAKE_PREFIX_PATH:-}" ]]; then + CMAKE_PREFIX_PATH=$HOME/dev/llvm/install/llvm_${LLVM_VERSION}_${BIRTH_ARCH}-${BIRTH_OS}-${LLVM_CMAKE_BUILD_TYPE} +fi + +if [[ -z "${CLANG_PATH:-}" ]]; then + CLANG_PATH=clang + CLANGXX_PATH=clang++ +fi + +OPT_ARGS="" + +case "${CMAKE_BUILD_TYPE%%-*}" in + Debug) OPT_ARGS="-O0 -g";; + Release*) OPT_ARGS="-O3";; + *) exit 1;; +esac + +mkdir -p self-hosted-bb-cache +$CLANG_PATH -c tests/c_abi.c -o self-hosted-bb-cache/c_abi.o $OPT_ARGS -std=gnu2x