#!/usr/bin/env bash # brintcc — the C compiler driver for wasm32-hwjs-linux. # # The front door. It resolves configuration (libexec/config.sh), decides which # libc this line is for, and execs the implementation in libexec/. It is an # exec, not a call: this toolchain compiles entire distributions, and a second # process per translation unit is a cost paid a million times. # # LIBC SELECTION. Default musl; `-mlibc=glibc` or a target triple naming a gnu # environment selects the glibc implementation. The selector is STRIPPED before # the exec — clang has no -mlibc flag and refuses the line if it sees one. # Autotools does not ask for a libc by flag; it looks for a program named after # the target triple, which is what the wasm32-hwjs-linux-*-gcc symlinks beside # this file are for. Invoked through one of those, the name decides the default. set -euo pipefail # readlink -f, not dirname alone: these front doors are meant to be symlinked # into a prefix on PATH, and a symlink's dirname is the prefix, not this repo. source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../libexec/config.sh" brintium_require llvm sysroot brintium_select_libc "$@" case "$BRINTIUM_LIBC" in glibc) # The glibc arm compiles against the kernel UAPI headers unconditionally # (-isystem, on every line), so an absent pointer is a refusal here rather # than an -isystem of a directory that does not exist and a header error # a thousand lines into a build. brintium_require kernel-headers exec "$BRINTIUM/libexec/brintcc-glibc" "${BRINTIUM_ARGV[@]}" ;; musl) exec "$BRINTIUM/libexec/brintcc-musl" "${BRINTIUM_ARGV[@]}" ;; esac