cosmopolitan/build/sanitycheck
Justine Tunney 4e9662cbc7 Write tests for new APE loader and fix bugs
- Add FreeBSD-specific mmap() flags
- Reduce size of the APE loader from 8kb to 4kb
- Work towards fixing the Makefile build on WSL
- Automate testing of APE no-modify-self behaviors
- Make the ape.S shell script code cleaner and tinier
- Improve the APE sanity check to test behavior better
- Fixed issue with ShowCrashReports() sigaltstack() on BSDs
- Delete symbols for S_MODE magnums which wasted compile time

If you checked out yesterday's APE commit, please run:

    rm -f /usr/bin/ape o/tmp/ape /tmp/ape "${TMPDIR:-/tmp}/ape"

Because this change fixes certain aspects of the new ABI. We don't have
automated migrations for APE loader versions yet. Thanks! You can also
download prebuilt binaries here:

- https://justine.lol/ape.elf    (Linux/FreeBSD/NetBSD/OpenBSD)
- https://justine.lol/ape.macho  (Apple)

Install the appropriate one as `/usr/bin/ape`.
2022-05-22 05:45:38 -07:00

66 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
#
# OVERVIEW
#
# System Sanity Check
#
# DESCRIPTION
#
# This script is launched at the start of Makefile to detect if
# binfmt_misc was tuned to launch 'MZ' shell scripts under WINE
if [ x`uname -s` != xLinux ]; then
cat <<'EOF' >&2
ERROR
Want Linux Build Environment
DETAILS
Cosmopolitan builds binaries that run on all major platforms.
You need to compile them on Linux, using any distro you like.
Consider setting up Alpine, Debian, or Ubuntu in a VMWare VM.
EOF
kill $1
exit 1
fi
if [ ! -f /proc/sys/fs/binfmt_misc/status ]; then
exit 0
fi
STATUS="$(build/bootstrap/apetest.com)"
if [ x"$STATUS" != xsuccess ]; then
cat <<'EOF' >&2
ERROR
APE Execution error.
DETAILS
Your system has probably been configured to use binfmt_misc. You need
to run the command below to install /usr/bin/ape and register it with
binfmt_misc. See ape/loader.c for source code, and technical details.
WORKAROUND
ape/apeinstall.sh
NOTES
If it still doesn't work, possibly due to an overly aggressive WINE
or WSL registration, or possibly due to the ordering of definitions,
then one troubleshooting step is to just unregister everything using
sudo sh -c 'echo -1 >/proc/sys/fs/binfmt_misc/status' and try again.
SEE ALSO
https://justine.lol/ape.html
EOF
kill $1
exit 1
fi