Cosmopolitan Versions Save

build-once run-anywhere c library

3.2.1

4 months ago
  • 0e49bed66 Support 40 cosmo_dlopen() function parameters
  • 2d93788ce Fix --ftrace with cosmo_dlopen()
  • 44a463e4d Invent *cosmo_dltramp() function
  • 15548b523 Cleanup apeinstall.sh (#1057)
  • 412a200ae Support binfmt_misc P flag in APE loader (#1058)
  • a334f9cc3 Update redbean ProgramDirectory to return a list of previously set directories (#1021)
  • 3315b6ef1 Store StrlenDevFd in n (#1056)

3.2

4 months ago

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. For further details, read Cosmopolitan Third Edition, the Cosmo README, and the Cosmopolitan Toolchain README.

Our latest 3.2 release features exciting fixes and improvements.

  • 83107f78e Introduce FreeBSD ARM64 support
  • 43fe5956a Use DNS implementation from Musl Libc
  • 796148790 Remove hard coded paths from APE bootloader (NixOS)
  • f8ea02d4d Import /etc/shadow support from Musl for Linux
  • ce0143e2a Fix madvise() on Windows
  • 873069fcd Fix -Xaarch64 in cosmocc
  • 1a28e35c6 Use good locks in dlmalloc
  • cd52c5955 Allow MAP_POPULATE under pledge()
  • e36283f1d Support double parameters in dlsym() imports
  • 6be9477b9 Fix redbean to only check additional content types when Lua is present (#1033)

We've fixed important threading bugs on /zip/... file descriptors.

  • 53357aa26 Fix __zipos_close (#984)
  • 8a10ccf9c Fix ZipOS deadlock/segfault (#1011)
  • 5c3586352 Rename __zipos_free -> __zipos_drop (#1043)
  • 4c6f928fb Disable argv[0] tests on non-XnuSilicon (#1015)

We now have a hack that lets you use cosmo binaries as a login shell. Setuid security is improved. Executable path self-detection is better. There's a new APE loader version as a result. If you have a systemwide APE loader install, it's recommended that you upgrade, but not required.

  • 81949f038 Mint APE Loader v1.10
  • 2a3813c6c $prog.ape support (#977)
  • f94c11d97 Loader path security (#1012)
  • 68dbe5312 Prepend getcwd to exename early in init (#1048)
  • b02d13ccd Re-enable/fix non-argv[0] exe name tests (#1046)
  • 10b4693e3 Sanity-check set-id interpreter script paths (#1029)
  • 77facc4f7 Cover more cases for detecting ape loader (#1022)
  • 2a11a09d9 Remove realpath/getcwd from loaders (#1024)
  • d8ad34686 Implement issetugid() on NetBSD

Our public header files now have better open source compatibility.

  • 8874a37ab Add <link.h> for absl
  • 221a27836 Define max_align_t in <stddef.h>
  • 06ace4e7b Always use compiler builtin for offsetof()
  • a11016e59 Use gid_t and uid_t in passwd.h (#995)
  • b0cced855 Move tcgetpgrp and tcsetpgrp decls to unistd.h (#996) (#997)

3.1.3

5 months ago
  • 69ba51646 Revert "Re-enable apelink size optimization"

3.1.2

5 months ago
  • d1a745c17 Implement __zipos_dup (#972)
  • 4b7ba9a4c Fix some bugs with dup2() and ZipOS
  • 7845495a9 Get tool/cosmocc/package.sh working on M1 (#970)
  • 14bf57180 Make cosmocc make work right on aarch64
  • 7b3d7ee07 Re-enable apelink size optimization
  • ff955aaa0 Make memcmp() and memchr() go fast again
  • 70155df7a Avoid linking win32 signals impl
  • 2b960bb24 Exclude strace from MODE=tiny builds

3.1.1

5 months ago
  • 41c06c632 Make cosmocc 100x faster on MacOS
  • 43de12db5 Introduce forkpty()
  • cc5c5319b Linux: Add cachestat, fchmodat2 syscalls (#958)
  • 0bffd0943 Allow redbean to accept --assimilate option without complaining (#916)
  • 96185e1ac Fix MODE=aarch64 cross-compiling
  • ca5e36191 Don't show (win32 error 0)
  • 9cad66aa1 Freshen bootstrap binaries for MacOS + SIP
  • 96f979dfc Rename makefiles BUILD.mk

3.1

5 months ago

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

  • 5330442d8 Avoid APE fork bomb
  • 291103ad8 Redesign cosmocc toolchain
  • 751d20d98 Fix nsync_mu_unlock_slow_() on Apple Silicon
  • 3ac473df3 Floating point parsing support for scanf family (#924)
  • 8caf1b48a Improve time/sleep accuracy on Windows
  • e4dea37b8 Make clock_nanosleep() cancel faster
  • 32b97f2d2 Improve execve() path argument munging
  • bcf268adf Don't modify argument block on MacOS Arm64
  • 0863427b3 Make development more pleasant on MacOS Arm64
  • 48bd3d85d Fix sigaction() return handler address on XNU/BSD
  • 3e6d53682 Correct misunderstanding with zip64 extra records
  • 0c89516ac Fix unzip warning with apelink generated symtabs
  • f25beb341 Add architecture flag to zipobj
  • 736fdb757 Implement raise() with getcontext() / setcontext
  • bd56a9cf5 Rename dlopen() to cosmo_dlopen()
  • f7cfe0388 Fix dlopen() for FreeBSD and NetBSD
  • 529cb4817 Improve dlopen() on Apple Silicon
  • dffee606c Run host compiler to create dlopen helper
  • e4584ace8 Get cosmo_dlopen() working better on System Five
  • ac125d3e1 Fix console copy/paste issue on Windows
  • e961385e5 Put more thought into Windows i/o polyfills
  • 7138399f9 Close Lua state before exiting redbean worker to allow GC to collect (#941)
  • 5c1fdc981 Fix session changeset procesing (reverting some of 0d748ad5 changes) (#949)
  • ddc08dc97 [metal] Make deathstar.com draw onto both VGA and serial consoles (#955)
  • eea601f34 [metal] Some minor fixes and tweaks (#933)
  • 545a8f4cb Add more sched.h content
  • 7a9e176ec Improve debug binary location detection
  • 68c7c9c1e Make strerror() conform more to other libc impls and introduce __clear_cache()
  • 8f5e516b3 Remove sync_file_range
  • 1351d3ced Remove bool from public headers
  • 1c2e7c133 Introduce SIP_DISABLED compile option for ape-m1.c
  • 3b15d3124 Fix #include <shared_mutex>
  • c6d3802d3 Add more fixes for new cosmocc toolchain
  • cdbd10c9d Introduce X86_CHECK() macro
  • d2f49ca17 Improve mkdeps
  • 15af5c2d7 Fix ucontext_t alignment in strict ansi mode
  • b8d1377ae Give new wait4() another review pass
  • ea28f93a2 Support includes in monorepo
  • cc3e3de04 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"

3.0.2

6 months ago

Features

  • Introduce getifaddrs() 024be3b009d500970168e41f375ff8f0c79c80b0
  • Introduce very primitive dlopen() support 5e8c928f1a37349a8c72f0b6aae5e535eace3f41
  • Make it possible to use APE Loader on Apple Silicon systems with SIP enabled a12ad17291e6ce688ce1d997e90b3f971852359c

Bug Fixes

  • Fix APE Loader CRT bugs which caused crashes for MacOS x86-64 users (#931)
  • Fix getcwd() on Windows which was causing weirdness with bash 1eb6484c9c89b3cf85cd9f235aef70e1e5ed1776
  • Embed GNU TLS in Cosmos Emacs so M-x package-list-packages will work on Windows
  • Use /usr/local/bin/ape (instead of /usr/bin/ape) on Apple Silicon for systemwide APE.
  • Add database and statement readonly checks to sqlite in redbean (#914)
  • Make WIN32 i/o signals more atomic and longjmp() safe d7917ea076df24967ec578c5dabe1ce30b93793d
  • Support \n in /zip/.args files 585c86e2a439d5df23595b249eb28554764ec6b4
  • Make cosmocc -dumpmachine work

Upgrade Notes

If you've used ape-install or ape/ape-install.sh in the past (to install the system-wide APE Loader) then you need to run it again so that your system can use APE Loader v1.9. This new release of APE Loader fixes bugs. Apple M1 systems need it to run the APE binaries in this release..It's also backwards compatible with all APE and static ELF binaries ever made with Cosmo. Any of your own programs which you've compiled before on Apple Silicon which use execve() may need to be recompiled in order to run the latest APE executables unless you've installed a system-wide APE Loader.

It's recommended that cosmocc users run:

cd /opt/cosmo
rm -rf o/third_party/gcc
unzip -vl cosmocc-0.0.18.zip

To get the latest build of Cosmopolitan's toolchain.

3.0.1

6 months ago

3.0

7 months ago

Release notes upcoming.

2.2

1 year ago

Cosmopolitan Libc makes C/C++ a build-once run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine. Instead, it reconfigures stock GCC to output a POSIX-approved polyglot format that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS or UEFI with the best possible performance and the tiniest footprint imaginable.

Getting Started

If you use Linux, then you can build Cosmopolitan and its included software from source as follows:

wget https://justine.lol/cosmopolitan/cosmopolitan-2.2.tar.gz
tar xf cosmopolitan-2.2.tar.gz
cd cosmopolitan
build/bootstrap/make.com -j8
o//examples/hello.com

If you're doing your development work on Linux or BSD and you want to bring your own build system, then you need just five files to get started:

wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-2.2.zip
unzip cosmopolitan-amalgamation-2.2.zip
printf 'main() { printf("hello world\\n"); }\n' >hello.c
gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone -gdwarf-4 \
  -fno-omit-frame-pointer -pg -mnop-mcount -mno-tls-direct-seg-refs \
  -o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds -Wl,--gc-sections \
  -include cosmopolitan.h crt.o ape-no-modify-self.o cosmopolitan.a
objcopy -S -O binary hello.com.dbg hello.com

Features

  • Implement POSIX semaphores 811146278
  • Implement POSIX cancellations 2278327eb 022536cab 3f0bcdc3e 3f0bcdc3e 4a6fd3d91 e522aa3a0
  • Implement atomic swar token bucket library for DDOS protection e7329b7cb
  • Introduce sigtimedwait() and sigwaitinfo() 467a332e3
  • Invent iso8601us() for faster timestamps f7ff77d86
  • Work towards zipos / open(argv[0]) on metal cb9a0466f
  • Introduce readdir_r, scandir, pthread_kill, sigsetjmp, etc.. e557058ac
  • Allow more fine-grained control over bare metal page permissions d38700687
  • Make cli commands yoinkable into cosmo shell 3d2d04b25
  • Support Ctrl-Left / Ctrl-Right keystrokes in Bestline
  • Introduce a ParseCidr() API c995838e5

Fixes and Improvements

  • Make fcntl() locks on Windows work well enough to support SQLite 997ce29dd
  • Make fork/system/popen thread safe 60cb435cb f52f65b2e
  • Fix support for WSL1 platform fc96af058 f44d88707 d6ff4c754 fae0c0286 14d036b68
  • Fix bug: do not initialize IDT & TSS if unneeded (#654)
  • Integrate upstream dash changes into unbourne shell (#656)
  • Import more of the remaining math library routines from Musl e557058ac
  • Make the conformance of libc/isystem/ headers nearly perfect e557058ac
  • Fixed bug where stdio eof wasn't being sticky d5910e267
  • Fixed bug where fseeko() wasn't clearing eof state d5910e267
  • Fix ParseHttpMessage failing to store >2 repeatable headers (#657)
  • Fix a harmless integer overflow in ParseIp() c995838e5
  • Improve cosmo's conformance to libc-test e557058ac
  • Improve lock performance on NetBSD c995838e5
  • Elevate the quality of getrandom() and getentropy() 3f0bcdc3e
  • Make Windows fcntl() and lseek() fixes da8f5009f
  • Windows fork() now restores TLS memory of calling thread e522aa3a0
  • More cosmocc toolchain FOSS compatibility improvements 5af19b7ee
  • Rewrite makedirs() so it doesn't need dynamic memory 0f8914088
  • Rewrite putenv() and friends to conform to POSIX f7ff77d86
  • Permit Linux OFD fcntl() locks under pledge(flock) f7ff77d86
  • Support closefrom() on NetBSD
  • Support tgkill() on FreeBSD

Breakages

  • Remove underscore prefix from awesome timespec_*() APIs 3f0bcdc3e
  • Rename LINUX to _HOSTLINUX etc. to reduce clashes (#655)
  • Rename rand64() to _rand64() 7ae556463