#!/usr/bin/env bash # brintmake — run make against this toolchain, with the conftest knob OFF. # # The other half of bin/brintconfigure. It sets the same CC/CXX/AR/RANLIB so a # package is built by the compiler it was probed with, and it does NOT set # WASMLD_HWJS_CONFTEST — the whole point of the pair. # # It also REFUSES if it finds that knob set in the environment, which is the # footgun this pair exists to close. WASMLD_HWJS_CONFTEST=1 fast-links with # plain wasm-ld and never runs the pass; a build that inherits it from an # earlier `export` produces objects that link, pass their tests on the host, # and cannot fork or be preempted at run time. Nothing downstream detects that, # so it is caught here, where the value is still visible. # # Usage: # brintmake [--libc=musl|glibc] [make args...] 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" LIBC='' if [ $# -gt 0 ]; then case "$1" in --libc=*) LIBC="$(brintium_parse_libc_opt "$1")"; shift ;; esac fi case "${WASMLD_HWJS_CONFTEST:-0}" in 0) ;; *) brintium_fatal \ "WASMLD_HWJS_CONFTEST='$WASMLD_HWJS_CONFTEST' is set in this environment. It belongs to a ./configure run and to nothing else: it fast-links with plain wasm-ld, so the coroutinize pass never runs and every object this build produced would be un-forkable and un-preemptible while still linking clean. Unset it (bin/brintconfigure scopes it to the configure process for exactly this reason) and build again." ;; esac # Where the Makefile is: honor make's own -C and -f before deciding, so the # refusal below can never fire on a build that was going to work. DIR='.' MAKEFILE='' prev='' for a in "$@"; do case "$prev" in -C) DIR="$a" ;; -f|--file|--makefile) MAKEFILE="$a" ;; esac case "$a" in -C*) [ "$a" = -C ] || DIR="${a#-C}" ;; -f*) [ "$a" = -f ] || MAKEFILE="${a#-f}" ;; --file=*|--makefile=*) MAKEFILE="${a#*=}" ;; esac prev="$a" done [ -d "$DIR" ] || brintium_fatal "no such directory '$DIR' (make -C)." if [ -n "$MAKEFILE" ]; then [ -f "$DIR/$MAKEFILE" ] || [ -f "$MAKEFILE" ] || brintium_fatal \ "no makefile at '$MAKEFILE' (make -f, from $PWD)." else found='' for m in GNUmakefile makefile Makefile; do [ -f "$DIR/$m" ] && { found="$m"; break; } done [ -n "$found" ] || brintium_fatal \ "no GNUmakefile, makefile or Makefile in '$DIR' (from $PWD). Configure the package first — bin/brintconfigure — or point make at one with -f. Refusing rather than letting make report it: make's own message does not say which toolchain it was about to use, and this one does." fi brintium_require llvm sysroot if [ "$LIBC" = glibc ]; then brintium_require kernel-headers; fi brintium_export_build_tools "$LIBC" exec make "$@"