Bot releases are visible (Hide)
Published by jart about 1 year ago
Release notes upcoming.
Published by jart almost 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.
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
Published by jart about 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.
This release fixes bugs and makes system call wrapper improvements:
struct sockaddr *
(#630)We're working to make every Cosmopolitan binary a true operating system by introducing features like VGA support:
Other changes:
Published by jart about 2 years ago
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.
Published by jart about 2 years ago
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.
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.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.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.
Published by jart about 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.
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
MODE=fastbuild
and shorthand notation m=fastbuild
SIG_DFL
and SIG_IGN
C++ compatible 8cd4248f7f74e2ea91a8ea22c6d685d5b13a0fcbMODE=tiny*
builds by defaulttestonly
keywordo//examples/script.com
can record and playback terminal screencasts on five OSes 1ad2f530f9c6197dfca199fc67a2296bbaac856esed
command is now available in third_party/sed/Published by jart about 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.
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
/zip/...
rather than zip:...
when open()'ing assets stored in the PKZIP structure of your executable program. 00611e9b06be11e8af3a05c5d60878377aa2b0bd/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.LOGF
to INFOF
in the logging API. 0584684a8202dbdfc2861a32bee3e73d0161a537intmax_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()
. 868af3f950c562baa1a73539703c6c78d51adcebnothrow
to dontthrow
and nodiscard
is now dontdiscard
. 868af3f950c562baa1a73539703c6c78d51adceb--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. 47a53e143b9baf1e25b7001dd377986f8fac2989ape/apeinstall.sh
program in this repository._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._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.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.--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
.--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
. 14e192e5ba820c60fa4aef48c1a646b151723603o//third_party/python/python.com
which includes an import cosmo
module that lets you use our best features too.closefrom()
system call for Linux 5.9+, FreeBSD 8+, and OpenBSD.clock_gettime
and gettimeofday
functions now go 10x faster on Linux via the vDSO.nointernet()
function which is similar in spirit to djb's disablenetwork()
function.privileged
runtime.Published by jart over 3 years 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 or UEFI with the best possible performance and the tiniest footprint imaginable.
OpenExecutable
for restoring APE bf03b2e64c1f38f2e20cbd0126dc858d31f9ead4 or alternatively ape-no-modify-self.o
da8a08fd58324a87f6ac673b7774512e861fe477If 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
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.
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 |
Published by jart over 3 years 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.
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!
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
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.
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 |
Published by jart over 3 years ago
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.Published by jart over 3 years ago
Published by jart over 3 years ago
This release fixes a few issues with the 0.1 release.
Published by jart over 3 years 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 to output a POSIX-approved polyglot format that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + BIOS with the best possible performance and the tiniest footprint imaginable.
This is our first official release. You may remember the pre-alpha demo that went viral on Hacker News last month. There's been a considerable number of bug fixes since then. Here's a curated list of what happened:
Here's how to get started with the freestanding hermetically-sealed monolithic source repository:
tar xf cosmopolitan-0.1.tar.gz
cd cosmo
make -j12
o//examples/hello.com
Here's how to get started with the amalgamated binaries, which let you bring your own build system:
unzip cosmopolitan-amalgamated-0.1.zip
echo 'main() { printf("hello world\n"); }' >hello.c
gcc -g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc \
-o hello.com.dbg hello.c -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd \
-Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a
objcopy -SO binary hello.com.dbg hello.com
./hello.com
Please note we assume that you compile your programs on Linux. If you want to compile your binaries on Windows, then please read our new tutorial on how you can use the x86_64-linux-gnu static exes we created. See https://justine.lol/cosmopolitan/windows-compiling.html and https://justine.lol/cosmopolitan/windows-debugging.html If you use XNU then we'll be sharing a prebuilt Linux toolchain for you too soon.
All 196 tests passing on the following systems is confirmed:
Thanks go out to @jillest, @probonopd, @nicholatian, @vshymanskyy, @PerfectProductions, @JesseRMeyer, @nikhedonia, @tpoindex, @maroneze, @zhengshuxin, @Phate6660, @Theldus, @severak, @paususe, @rhdxmr, @tankf33der, @nuclight, @nsauzede, @gavinhoward, and many others who've helped make this release possible.