|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
| 4 | + echo "Error: Script must be sourced, Usage: source $0 <gcc_version>" >&2 |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +if [[ -z "$1" ]]; then |
| 9 | + echo "Error: Missing argument, Usage: source $0 <gcc_version>" >&2 |
| 10 | + return 1 |
| 11 | +fi |
| 12 | + |
| 13 | +if ! brew --version > /dev/null 2>&1; then |
| 14 | + echo "Error: Homebrew missing, install from https://brew.sh/." >&2 |
| 15 | + return 1 |
| 16 | +fi |
| 17 | + |
| 18 | +GCC_VERSION="$1" |
| 19 | + |
| 20 | +REQUIRED_FORMULAE=( |
| 21 | + "gcc@${GCC_VERSION}" |
| 22 | + "openjdk" |
| 23 | + "cmake" |
| 24 | + "ninja" |
| 25 | +) |
| 26 | + |
| 27 | +for formula in "${REQUIRED_FORMULAE[@]}"; do |
| 28 | + if ! brew list --formula "${formula}" &>/dev/null; then |
| 29 | + echo "Error: ${formula} missing, install with `brew install ${formula}`" >&2 |
| 30 | + return 1 |
| 31 | + fi |
| 32 | +done |
| 33 | + |
| 34 | +GCC_PREFIX="$(brew --prefix "gcc@${GCC_VERSION}")" |
| 35 | +OPENJDK_PREFIX="$(brew --prefix "openjdk")" |
| 36 | + |
| 37 | + |
| 38 | +# specify minimum support macOS version |
| 39 | +export MACOSX_DEPLOYMENT_TARGET="15.0" |
| 40 | + |
| 41 | +# java needs to be in path |
| 42 | +export PATH="${OPENJDK_PREFIX}/bin:${PATH}" |
| 43 | + |
| 44 | +# apple-clang is completely incompatible to tentris in every way |
| 45 | +# llvm-clang has issues with thread local variables when using libstdc++ and libc++ is completely imcompatible to tentris |
| 46 | +export CC="${GCC_PREFIX}/bin/gcc-${GCC_VERSION}" |
| 47 | +export CXX="${GCC_PREFIX}/bin/g++-${GCC_VERSION}" |
| 48 | + |
| 49 | +# aws-lc-sys requires __ARM_FEATURE_AES and __ARM_FEATURE_SHA2 |
| 50 | +# which are only enabled when you pass this option |
| 51 | +# see https://developer.arm.com/documentation/101754/0624/armclang-Reference/armclang-Command-line-Options/-march |
| 52 | +export CFLAGS="-march=armv8-a+aes+sha2" |
| 53 | + |
| 54 | +# rustc needs to be able to find libgcc.a libgcc_s.dylib and libstdc++.a |
| 55 | +export RUSTFLAGS="-L${GCC_PREFIX}/lib/gcc/${GCC_VERSION} -L${GCC_PREFIX}/lib/gcc/${GCC_VERSION}/gcc/aarch64-apple-darwin24/${GCC_VERSION}" |
0 commit comments