github jart/cosmopolitan 2.2
Cosmopolitan v2.2

latest releases: 3.9.4, 3.9.3, 3.9.2...
2 years 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 8111462
  • Implement POSIX cancellations 2278327 022536c 3f0bcdc 3f0bcdc 4a6fd3d e522aa3
  • Implement atomic swar token bucket library for DDOS protection e7329b7
  • Introduce sigtimedwait() and sigwaitinfo() 467a332
  • Invent iso8601us() for faster timestamps f7ff77d
  • Work towards zipos / open(argv[0]) on metal cb9a046
  • Introduce readdir_r, scandir, pthread_kill, sigsetjmp, etc.. e557058
  • Allow more fine-grained control over bare metal page permissions d387006
  • Make cli commands yoinkable into cosmo shell 3d2d04b
  • Support Ctrl-Left / Ctrl-Right keystrokes in Bestline
  • Introduce a ParseCidr() API c995838

Fixes and Improvements

  • Make fcntl() locks on Windows work well enough to support SQLite 997ce29
  • Make fork/system/popen thread safe 60cb435 f52f65b
  • Fix support for WSL1 platform fc96af0 f44d887 d6ff4c7 fae0c02 14d036b
  • 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 e557058
  • Make the conformance of libc/isystem/ headers nearly perfect e557058
  • Fixed bug where stdio eof wasn't being sticky d5910e2
  • Fixed bug where fseeko() wasn't clearing eof state d5910e2
  • Fix ParseHttpMessage failing to store >2 repeatable headers (#657)
  • Fix a harmless integer overflow in ParseIp() c995838
  • Improve cosmo's conformance to libc-test e557058
  • Improve lock performance on NetBSD c995838
  • Elevate the quality of getrandom() and getentropy() 3f0bcdc
  • Make Windows fcntl() and lseek() fixes da8f500
  • Windows fork() now restores TLS memory of calling thread e522aa3
  • More cosmocc toolchain FOSS compatibility improvements 5af19b7
  • Rewrite makedirs() so it doesn't need dynamic memory 0f89140
  • Rewrite putenv() and friends to conform to POSIX f7ff77d
  • Permit Linux OFD fcntl() locks under pledge(flock) f7ff77d
  • Support closefrom() on NetBSD
  • Support tgkill() on FreeBSD

Breakages

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

Don't miss a new cosmopolitan release

NewReleases is sending notifications on new releases.