Cosmopolitan v3.1
Cosmopolitan Libc makes C a build-once run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine. Instead, it reconfigures stock GCC and Clang to output a POSIX-approved polyglot format that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS with the best possible performance and the tiniest footprint imaginable.
Overview
This release fixes issues with the 3.0.x series. A new cosmo_dlopen()
function is now provided that's good enough to load nontrivial dynamic libraries on all platforms except OpenBSD. Cosmos binaries are now being distributed on our new online service https://cosmo.zip/ that's operated by the Cosmopolitan authors. This release was made possible thanks to the testing and contribution efforts of our GitHub and Discord communities https://discord.gg/FwAVVu7eJ4. Thank you!
Changes
- 5330442 Avoid APE fork bomb
- 291103a Redesign
cosmocc
toolchain - 751d20d Fix nsync_mu_unlock_slow_() on Apple Silicon
- 3ac473d Floating point parsing support for scanf family (#924)
- 8caf1b4 Improve time/sleep accuracy on Windows
- e4dea37 Make clock_nanosleep() cancel faster
- 32b97f2 Improve execve() path argument munging
- bcf268a Don't modify argument block on MacOS Arm64
- 0863427 Make development more pleasant on MacOS Arm64
- 48bd3d8 Fix sigaction() return handler address on XNU/BSD
- 3e6d536 Correct misunderstanding with zip64 extra records
- 0c89516 Fix unzip warning with apelink generated symtabs
- f25beb3 Add architecture flag to zipobj
- 736fdb7 Implement raise() with getcontext() / setcontext
- bd56a9c Rename dlopen() to cosmo_dlopen()
- f7cfe03 Fix dlopen() for FreeBSD and NetBSD
- 529cb48 Improve dlopen() on Apple Silicon
- dffee60 Run host compiler to create dlopen helper
- e4584ac Get cosmo_dlopen() working better on System Five
- ac125d3 Fix console copy/paste issue on Windows
- e961385 Put more thought into Windows i/o polyfills
- 7138399 Close Lua state before exiting redbean worker to allow GC to collect (#941)
- 5c1fdc9 Fix session changeset procesing (reverting some of 0d748ad changes) (#949)
- ddc08dc [metal] Make deathstar.com draw onto both VGA and serial consoles (#955)
- eea601f [metal] Some minor fixes and tweaks (#933)
- 545a8f4 Add more sched.h content
- 7a9e176 Improve debug binary location detection
- 68c7c9c Make strerror() conform more to other libc impls and introduce __clear_cache()
- 8f5e516 Remove sync_file_range
- 1351d3c Remove bool from public headers
- 1c2e7c1 Introduce SIP_DISABLED compile option for ape-m1.c
- 3b15d31 Fix
#include <shared_mutex>
- c6d3802 Add more fixes for new cosmocc toolchain
- cdbd10c Introduce X86_CHECK() macro
- d2f49ca Improve mkdeps
- 15af5c2 Fix ucontext_t alignment in strict ansi mode
- b8d1377 Give new wait4() another review pass
- ea28f93 Support includes in monorepo
- cc3e3de Make
args
replace...
only at the end of file (#909)
Known Issues
Shells
If you use zsh and have trouble running APE programs try sh -c ./prog
or simply upgrade to zsh 5.9+ (since we patched it two years ago). The same is the case for Python subprocess
, old versions of fish, etc.
Linux
Some Linux systems are configured to launch MZ executables under WINE or run-detectors
. You can fix that by registering APE with binfmt_misc
:
sudo wget -O /usr/bin/ape https://cosmo.zip/pub/cosmos/bin/ape-$(uname -m).elf
sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
sudo sh -c "echo ':APE-jart:M::jartsr::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
If things still aren't working, it's also possible to disable binfmt_misc
as follows:
sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/cli' # remove Ubuntu's MZ interpreter
sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/status' # remove ALL binfmt_misc entries
WSL
WSL tries to run MZ executables as WIN32 binaries within the WSL environment. In order to make it safe to use Cosmopolitan software on WSL, run this:
sudo sh -c "echo -1 > /proc/sys/fs/binfmt_misc/WSLInterop"