#!/bin/sh

script_dir="$(dirname "$0")"

# Determine the GCC binary to use.
# - REALGCC env var takes precedence (explicit override)
# - aarch64-linux-gnu-gcc (Ubuntu/Fedora cross-prefix)
# - gcc (Azure Linux / native aarch64 hosts where gcc has no prefix)
if [ -z "$REALGCC" ]; then
    if command -v aarch64-linux-gnu-gcc >/dev/null 2>&1; then
        REALGCC=aarch64-linux-gnu-gcc
    else
        REALGCC=gcc
    fi
fi

MUSL_ARCH=aarch64 MUSL_SYSROOT="$AARCH64_SYSROOT" exec "$REALGCC" "$@" -specs "$script_dir/musl-gcc.specs"
