0.3
版本发布时间: 2021-03-30 02:39:54
jart/cosmopolitan最新发布版本:3.8.0(2024-08-31 11:52:21)
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
- Major improvements to redbean 09bcfa23 4d21cd31 dcbd2b86 a1677d60 3c19b6e3 1753b669
- Major improvements to stdio da36e7e2 c3ed8d6c aad84161
- Add socketpair thanks to @fabriziobertocci ca88ce50
- Numerous bug fixes, thanks to @alisonatwork 9c817290 6cd10376 8a6ac6dd f5da4efc 813e11b9 5d334b9c
- Add missing math functions, and fix isystem headers, thanks to @dosisod 8a236433 fb7b7c6e
- Fix APE error if unable to modify self, thanks to @tomberek 0eaad9dd
- UEFI support 537c2133
- Support proper %g, %f, and %a float formatting f0641836
- Add posix_spawn 5ce83b08
- Make pow() conform to standard definition 8af91bcb 43b2475a
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 |
1、 cosmopolitan-0.3.tar.gz 32.96MB
2、 cosmopolitan-amalgamation-0.3.zip 5.55MB