Skip to content

Releases: jart/cosmopolitan

redbean v2.1

08 Oct 16:39
1c0adb5
Compare
Choose a tag to compare

redbean is an open source webserver in a zip executable that runs on six operating systems. The basic idea is if you want to build a web app that runs anywhere, then you download the redbean.com file, put your .html and .lua files inside it using the zip command, and then you've got a hermetic app you can deploy and share.

  • New unix.mapshared() api that lets you allocate memory that's shared between processes. It returns a module that has atomics and futexes. A demo script has been added that shows how it can be used to serialize a JSON GetPath() hit counter to shared memory.
  • This release fixes a bug with the parsing of space / plus parameters in the Request-URI.
  • Proof of concept of sqlite serialization (#436)
  • Lua's os.execute() function will now use Cosmopolitan's builtin cocmd interpreter, which provides a subset of bourne shell features, with faster performance, and consistent behavior across unixes and windows.
  • Fix re.NOSUB memory error (#645)
  • Update redbean api definitions (#652)
  • Make HTTP message parsing a little faster
  • Permit multiple certs with same common name

This is the first redbean release announcement that's been shared on GitHub. It only reflects the changes to redbean since 2.0.19. The web page for the 2.0.x release series is at https://redbean.dev/2.0.html which has links at the bottom to pages detailing older releases. For details on features and bug fixes that were introduced during the series over the past several months, please see the cosmo commit log.

pledge.com v1.8

08 Oct 16:50
7d6835c
Compare
Choose a tag to compare

pledge.com is a tool for sandboxing CLI commands on Linux that doesn't require root privileges. It's based on the Cosmopolitan Libc polyfills for the OpenBSD pledge() and unveil() functions which we've implemented using SECCOMP BPF and Landlock LSM.

  • Fix thread killing semantics #628
  • Fix interop with Go DNS #627

Cosmopolitan v2.1

20 Sep 12:50
8c2bf34
Compare
Choose a tag to compare

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.1.tar.gz
tar xf cosmopolitan-2.1.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.1.zip
unzip cosmopolitan-amalgamation-2.1.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

  • Introduce POSIX threads support with locking primitives based on *NSYNC
  • Add VGA terminal support on bare metal (see examples/vga.c) 3fdb1c1
  • System call portability is now documented at https://justine.lol/cosmopolitan/functions.html
  • Add cosmocc and cosmoc++ scripts which can serve as an open source toolchain 6cc9e08
  • Add lchown(), lchmod(), statvfs(), fstatvfs() 5a632cf
  • Add sigpending() a849a63
  • Add getgroups() and setgroups() 4c40c50
  • Implement inet_pton for AF_INET6 d213a48
  • The _gc() garbage collector is now thread safe 0e2b1bf
  • Use OpenBSD qsort() which is faster (quicksort) and secure (heapsort fallback) d861d27
  • Add notpossible keyword and _npassert() 0c70e89
  • IPv6 is now polyfilled on non-Linux 0547eab
  • Introduce MODE=fastbuild and shorthand notation m=fastbuild

Bug Fixes

  • Upgrade to the latest Chromium Zlib. This improves security and performance 224c12f 775944a
  • Fix out of bounds read in IP address parser 775944a
  • APE binaries now work better with BusyBox 0305194
  • Numerous fixes to bare metal support 3733b43 8569704 e0fabd1
  • Fix bug where SIG_IGN and SIG_DFL weren't working as advertised on BSDs c5c4dfc
  • Improve quality of raise(), abort(), and tkill() c5c4dfc
  • Improve quality of uname(), gethostname(), and getdomainname() b66bd06
  • Improve quality of clock() 12d9e1e
  • Improve quality of copy_file_range(), sendfile(), splice(), openpty(), closefrom(), close_range(), fadvise() and posix_fadvise() c7a8cd2 9fa6725
  • Fix _Thread_local with fork() on Windows bf757c4
  • Improve zipos path handling 1ef955c
  • Fix preadv() and pwritev() for old distros 3f49889
  • Support fcntl(F_DUPFD_CLOEXEC) on more systems 3f49889
  • Fix POSIX advisory locks on Windows 3f49889
  • Fix race condition in makedirs() 571c2c3
  • Fix pledge() thread kill semantics 1ea01fc
  • Improve open source compatibility b73e35c dbf12c3 55c6297
  • Make SIG_DFL and SIG_IGN C++ compatible 8cd4248
  • Discard ignored signals on New Technology 7de2f22
  • Fix inability to add some signals to mask on NT 5986408
  • Fix issue with ZipOS file descriptors in MODE=asan 3265324
  • The virtual memory layout is now more optimized b69f3d2
  • Repository is now buildable by GCC11

Breaking changes

  • Underscore added to many non-standard APIs to improve open source compatibility 6f7d0cb
  • Windows 7 and Vista support has now been moved to our vista branch 134ffee
  • Add sys_ prefix to unwrapped system calls to improve open source compatibility aab4ee4
  • Debug symbols now removed from MODE=tiny* builds by default
  • Removed testonly keyword

Third Party

  • FreeBSD's o//examples/script.com can record and playback terminal screencasts on five OSes 1ad2f53
  • NetBSD's sed command is now available in third_party/sed/
  • The One True Awk is now available in third_party/awk/ and https://justine.lol/awk/

Community

2.0.1

22 Aug 05:18
Compare
Choose a tag to compare
Release Cosmopolitan v2.0.1

Cosmopolitan v2.0

19 Aug 03:12
Compare
Choose a tag to compare

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.0.tar.gz
tar xf cosmopolitan-2.0.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.0.zip
unzip cosmopolitan-amalgamation-2.0.zip
printf 'main() { printf("hello world\\n"); }\n' >hello.c
gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
  -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

Breaking Changes

  • You have to use /zip/... rather than zip:... when open()'ing assets stored in the PKZIP structure of your executable program. 00611e9
  • You should use /c/... paths on Windows rather than C:/.... Your arguments and environment variables will be patched conservatively by the runtime to normalize $PATH and make life easy. It's still possible to use DOS, WIN32, NT, and other Microsoft-style paths with our APIs.
  • The default stack size has been reduced to 128kb. To learn how to increase this limit, or log your stack usage, please see 226aaf3
  • We renamed LOGF to INFOF in the logging API. 0584684
  • We no longer define intmax_t as 128-bit. We now violate the standard like everyone else, by defining it as 64-bit. We've introduced a new %jjd formatting directive for int128_t. Functions like bsrmax() are now called bsr128(). 868af3f
  • We've renamed nothrow to dontthrow and nodiscard is now dontdiscard. 868af3f
  • Remove undocumented and ANSI WIN32 APIs in d3b599a and a157940

Features

  • We now favor the new APE loader (see ape-no-modify-self.o). It's extracted automatically. It's fast. It maps your programs into memory without copying or self-modifying the header. An --assimilate flag is baked-in to the shell script at the tops of your binaries, so you can convert them to the platform-local format whenever you want. If you're using binfmt_misc then a separate assimilate program is provided for doing just that. We also still distribute the classic ape.o bootloader. 47a53e1
  • Binfmt_misc support for Linux users. This is the fastest way to run APE programs. You can install it by running the ape/apeinstall.sh program in this repository.
  • We've polyfilled the OpenBSD pledge() and unveil() system calls for Linux. You can now use these APIs in your C/C++/Python/Redbean programs, or you can use the new pledge.com command to sandbox your existing Linux userspace.
  • We now use Landlock Make to build the repository, since it offers sandboxing and hermeticity guarantees. Our project will still build fine using vanilla GNU Make, since Landlock Make is backwards compatible.
  • We now offer support for threading that works on all six supported operating systems. Use the _spawn() and _join() functions. We're working on POSIX Threads support and recommend using our new pthread_mutex_lock implementation. For examples of multi-threaded programs, see examples/greenbean.c and tool/build/mkdeps.c.
  • You can now use the _Thread_local keyword. Your C runtime will now always initialize Thread-Local Storage (TLS) for your main process thread. Doing that means the minimum APE binary size had to be increased from 12kb to 16kb. We prefer using the %fs register. You must use the -mno-tls-direct-seg-refs flag. On Windows and Apple platforms, your executable will rewritten in memory at initialization to turn %fs opcodes into %gs. If you wish to control your segment registers, then you may do so by setting __tls_enabled to false and calling arch_prctl. Please note if you use threads, this will make errno no longer thread safe.
  • We now uniquely polyfill mmap(MAP_STACK) which brings the FreeBSD behavior to Linux. You must use it if you want your code to run on OpenBSD. Please see the mmap() documentation to learn more.
  • The Cosmopolitan monolithic repository now offers the LLVM LIBCXX Standard Template Library for C++ developers. This is not currently available in the amalgamation.
  • Your Cosmopolitan binaries now include an --ftrace flag which logs C function calls to standard error. Please read the Logging C Functions blog post which explains more. You need to use the -pg (and hopefully also -mnop-mcount) flag for this to work. If you don't want this functionality in your runtime, use MODE=tiny or MODE=rel.
  • Your Cosmopolitan binaries now include an --strace flag which logs system calls to standard error. This works consistently across platforms. It's especially helpful for ZIP-related system calls, which aren't handled by the kernel. Please read the Logging C Functions blog post which explains more. If you don't want this functionality in your runtime, use MODE=tiny or MODE=rel. 14e192e
  • You can now use Actually Portable Python by building o//third_party/python/python.com which includes an import cosmo module that lets you use our best features too.
  • New closefrom() system call for Linux 5.9+, FreeBSD 8+, and OpenBSD.
  • The clock_gettime and gettimeofday functions now go 10x faster on Linux via the vDSO.
  • Our ASAN module is now able to trace the origin of memory allocations when generating reports.
  • Complex math functions are now available, thanks to Musl Libc.
  • Many math functions, e.g. pow(), now go faster, thanks to ARM.
  • New nointernet() function which is similar in spirit to djb's disablenetwork() function.
  • New string appending library. See appendd, appendf, appendr, appends, appendw, appendz, kappendf, kvappendf, and vappendf. What makes this library good is it's (a) fast, and (b) strings made by these functions can be passed to free().
  • We now offer a bulletproof unbreakable kprintf() family of functions as part of the privileged runtime.
  • SSL performance is now significantly improved. See 398f0c1 and f3e28aa and similar changes where we've added x86 optimizations for computing SHA faster, Intel ADX code that makes RSA multiplication faster, clean up code to make Everest curve25519 faster, and wrote an assembly implementation of NIST curve quasi-reduction.

Bug Fixes

  • Fork on Windows now works reliably 0cb6b6f 98909b1 e5314de
  • Memory maps on Windows now work reliably
  • Signals on Windows now works well enough for Redbean to offer a web server with a repl 072e1d2
  • Fix %c with nul character 3c28533
  • There's been a lot of fixes and fine tuning to the system call support magnums in consts.sh and syscalls.sh
  • Many system call polyfills have been improved, e.g. sysinfo, statfs, pselect, ppoll, sleep, sched_yield, utimensat, setsockopt, clock_gettime, sigsuspend, etc.
  • We now polyfill ENOENT vs. ENOTDIR on Windows
  • Daemonization now works on Windows

Cosmopolitan v1.0

17 May 04:51
Compare
Choose a tag to compare

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 or UEFI with the best possible performance and the tiniest footprint imaginable.

Changes

Getting Started

If you're doing your development work on Linux or BSD then you need just five files to get started. Here's what you do on Linux:

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

You now have a portable program. Please note that your APE binary will assimilate itself as a conventional resident of your platform after the first run, so it can be fast and efficient for subsequent executions.

./hello.com
bash -c './hello.com'  # zsh/fish workaround (we upstreamed patches)

So if you intend to copy the binary to Windows or Mac then please do that before you run it, not after.

If you're developing on MacOS you can install the GNU compiler collection for x86_64-elf via homebrew:

brew install x86_64-elf-gcc

Then in the above scripts just replace gcc and objcopy with x86_64-elf-gcc and x86_64-elf-objcopy to compile your APE binary.

If you're developing on Windows then you need to download an x86_64-pc-linux-gnu toolchain beforehand. See the Compiling on Windows tutorial. It's needed because the ELF object format is what makes universal binaries possible.

Cosmopolitan can also be compiled from source on any Linux distro.

wget https://justine.lol/cosmopolitan/cosmopolitan-1.0.tar.gz
tar xf cosmopolitan-1.0.tar.gz  # see releases page
cd cosmopolitan
make -j8  # should take ~30 seconds
o//examples/hello.com
o/third_party/lua/lua.com -e 'print(2 + 2)'
o/third_party/quickjs/qjs.com -e 'console.log(2+2)'
echo select 2 + 2 | o/third_party/sqlite3/sqlite3.com
printf 'GET /404.html\n\n' | o//examples/nc.com redbean.justine.lol 80
o//tool/viz/life.com

Contributing

We have automated Travis CI testing. Any pull request you send is going to get feedback in 2 minutes and 16 seconds. That's how long Travis CI takes to test this whole repository, which builds 14,507 objects, 68 libraries, and 461 static executables, 289 of which are test executables which are run too. On a real PC, building and testing everything from scratch takes 34 seconds instead of two minutes. If the hostnames freebsd, openbsd, netbsd, rhel7, rhel5, xnu, win7, and win10 can be ssh'd into, then make test -j8 takes 15 additional seconds to deploy and run all 300 test executables on those operating systems too. See CONTRIBUTING.md for further details.

Support Vector

Platform Min Version Circa
AMD K8 Venus 2005
Intel Core 2006
New Technology Vista 2006
GNU/Systemd 2.6.18 2007
XNU's Not UNIX! 15.6 2018
FreeBSD 12 2018
OpenBSD 6.4 2018
NetBSD 9.1 2020
GNU Make 3.80 2010

Cosmopolitan v0.3

29 Mar 18:39
Compare
Choose a tag to compare

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.

This release adds features such as Lua server pages to redbean (which last month became the third most popular "Show HN" thread). There's been a number of performance enhancements, improvements to compatibility, and bug fixes. We also managed to port several high-level languages to Cosmopolitan with passing test suites. This project has also received its first thirty sponsors. Thank you for your support!

Changes

Getting Started

If you're doing your development work on Linux or BSD then you need just five files to get started. Here's what you do on Linux:

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

You now have a portable program. Please note that your APE binary will assimilate itself as a conventional resident of your platform after the first run, so it can be fast and efficient for subsequent executions.

./hello.com
bash -c './hello.com'  # zsh/fish workaround (we upstreamed a patch)

So if you intend to copy the binary to Windows or Mac then please do that before you run it, not after.

If you're developing on Windows or MacOS then you need to download an x86_64-pc-linux-gnu toolchain beforehand. See the Compiling on Windows tutorial. It's needed because the ELF object format is what makes universal binaries possible.

Cosmopolitan can also be compiled from source on any Linux distro.

wget https://justine.lol/cosmopolitan/cosmopolitan-0.3.tar.gz
tar xf cosmopolitan-0.3.tar.gz  # see releases page
cd cosmopolitan
make -j16
o//examples/hello.com
find o -name \*.com | xargs ls -rShal | less

Contributing

We now have automated Travis CI testing. That means any pull request you send is going to get feedback in two minutes, which is how long it takes to build and test this whole repository inside a tiny VM.

Support Vector

Platform Min Version Circa
AMD K8 Venus 2005
Intel Core 2006
New Technology Vista 2006
GNU/Systemd 2.6.18 2007
XNU's Not UNIX! 15.6 2018
FreeBSD 12 2018
OpenBSD 6.4 2018
NetBSD 9.1 2020

Cosmopolitan v0.2

10 Feb 05:06
Compare
Choose a tag to compare
  • VSCode support #40
  • Your executables now run on NetBSD too b2cd58a 23ae9df
  • You can now compile your programs on BSD using the amalgamated release binaries
  • You can now build Cosmopolitan from source using LLVM e75ffde
  • You can now tune the source build to cherry pick which operating systems you want to support at compile time. By default, all seven are supported. To change that, simply redefine make CPPFLAGS=-DSUPPORT_VECTOR=0xFF which is a bitset defined by libc/dce.h. For example, -DSUPPORT_VECTOR=1 will ask Cosmopolitan's Makefile to produce conventional ELF binaries that only run on Linux.
  • Numerous bug fixes

Cosmopolitan v0.1.2

30 Jan 18:15
Compare
Choose a tag to compare
  • Increase Windows stack size 393a642
  • Implement getcwd() for XNU 9517364
  • Support dirfd relative iops for Windows 417797d
  • Fix fork on Windows after chdir b8d26e2

Cosmopolitan v0.1.1

29 Jan 09:37
Compare
Choose a tag to compare

This release fixes a few issues with the 0.1 release.

  • Refix readdir() on OpenBSD a5f3456
  • Make PATH search do the right thing w/ empty path caee314
  • Remove accidental printf debugging statement in windows signal handling code b2260c2