#!/usr/bin/env bash # brintconfigure — run a package's configure script against this toolchain. # # WHY THIS EXISTS. A configure run needs WASMLD_HWJS_CONFTEST=1 and the build # that follows it must NOT have it. That knob fast-links autoconf's probes with # plain wasm-ld, skipping the whole-program merge and the pass: behaviour- # equivalent for a probe whose only question is "did this link", and the # difference between a configure that finishes and one that spends ~30 seconds # per probe running LTO over every pulled bitcode member of a static archive. # Left set through `make`, the same knob builds every real object in the package # on the arm that skips the pass. # # Until now that was a variable a human set by hand and had to remember to # unset. Here it is scoped to the process this script execs, which is the only # scope in which it is ever correct — and bin/brintmake refuses outright if it # finds the knob still set, so forgetting is loud instead of silent. # # Usage: # brintconfigure [--libc=musl|glibc] [path/to/configure] [configure args...] # # With no path, ./configure in the current directory. 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 # A leading argument that names an existing file is the configure script # (out-of-tree builds run ../src/configure); anything else is configure's own. CONFIGURE='./configure' if [ $# -gt 0 ] && [ -f "$1" ]; then CONFIGURE="$1"; shift fi [ -f "$CONFIGURE" ] || brintium_fatal \ "no configure script at '$CONFIGURE' (from $PWD). Run this from the package's build directory, or pass the script's path as the first argument. Refusing rather than running make or guessing at autogen.sh: which one a package wants is the package's decision, not this script's." [ -x "$CONFIGURE" ] || brintium_fatal \ "'$CONFIGURE' is not executable. A configure script arrives executable; one that is not has been copied or checked out wrong, and running it through a shell would paper over that. chmod +x it if you know it is intact." brintium_require llvm sysroot if [ "$LIBC" = glibc ]; then brintium_require kernel-headers; fi brintium_export_build_tools "$LIBC" # Scoped by the exec: this assignment reaches the configure process and dies # with it. No caller has to remember to unset it. export WASMLD_HWJS_CONFTEST=1 echo "brintium: configuring with CC=$CC (conftest fast-link ON for this run only)" >&2 exec "$CONFIGURE" "$@"