2.1
版本发布时间: 2022-09-20 20:50:34
jart/cosmopolitan最新发布版本:3.8.0(2024-08-31 11:52:21)
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) 3fdb1c14f1e245d9ea16d72ce0d247d1cba3659a
- 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 6cc9e08f1b6355381182dd9ff6261b27527c6072
- Add lchown(), lchmod(), statvfs(), fstatvfs() 5a632cf72d5c6116a5c62ae0b9730476900b4df7
- Add sigpending() a849a6377130a4ab63ae994f05a833637b7d0082
- Add getgroups() and setgroups() 4c40c500b82be387a33ad5c65f084198211507f5
- Implement inet_pton for AF_INET6 d213a481906ce7edf485009ebb486735caada9ed
- The _gc() garbage collector is now thread safe 0e2b1bfeed2654fa425a70f7d88e5d1306611a6d
- Use OpenBSD qsort() which is faster (quicksort) and secure (heapsort fallback) d861d2787b0decc5776db8922a68da960db16bc9
- Add notpossible keyword and _npassert() 0c70e8963db77e4db2ee7de2da3139fa4b558171
- IPv6 is now polyfilled on non-Linux 0547eabcd6b32cfe0335924e91ca8436fe66d3cc
- Introduce
MODE=fastbuild
and shorthand notationm=fastbuild
Bug Fixes
- Upgrade to the latest Chromium Zlib. This improves security and performance 224c12f54d58abdcc73cec60ec761814fcc219f3 775944a2d03f3f24357e90394a2bc4df0103bcff
- Fix out of bounds read in IP address parser 775944a2d03f3f24357e90394a2bc4df0103bcff
- APE binaries now work better with BusyBox 0305194d9854556e2bbef1fdcfda6e76910b1baf
- Numerous fixes to bare metal support 3733b43a8fa011331fcb733680d0783dc1321384 8569704c1ddcff3403502d84ca66d65b5f22c347 e0fabd1d497fb3ffcbdb674667812aaf26d84261
- Fix bug where SIG_IGN and SIG_DFL weren't working as advertised on BSDs c5c4dfcd218d834b94d4a73ab952f65c1a8b93d4
- Improve quality of raise(), abort(), and tkill() c5c4dfcd218d834b94d4a73ab952f65c1a8b93d4
- Improve quality of uname(), gethostname(), and getdomainname() b66bd064d8b026696fe1523d699724c0fe7f35fb
- Improve quality of clock() 12d9e1e12859398c1698fcf073aa0d3c67f31a0c
- Improve quality of copy_file_range(), sendfile(), splice(), openpty(), closefrom(), close_range(), fadvise() and posix_fadvise() c7a8cd21e90ab84be4caf5bd865ec90f17bd7017 9fa672506738cd210cb819e3fd05d2dd7d3f2997
- Fix _Thread_local with fork() on Windows bf757c46469a5361fb00c6c3483858242087251f
- Improve zipos path handling 1ef955c33b3092e62d5d05855b13c1fe6204006a
- Fix preadv() and pwritev() for old distros 3f4988984183dae5bf8a39b9fcbb8cdf78ce10c7
- Support fcntl(F_DUPFD_CLOEXEC) on more systems 3f4988984183dae5bf8a39b9fcbb8cdf78ce10c7
- Fix POSIX advisory locks on Windows 3f4988984183dae5bf8a39b9fcbb8cdf78ce10c7
- Fix race condition in makedirs() 571c2c3c698f31426c5ef5614745ba11e70e0783
- Fix pledge() thread kill semantics 1ea01fc9055fae058ce1589593fb8bfbeacb5418
- Improve open source compatibility b73e35c6fac2960b3a5fb082a712145318e2218b dbf12c30b05e8bffaa73356c229391538fd0b322 55c6297e13b49387708208d86cd0fc5d23e01678
- Make
SIG_DFL
andSIG_IGN
C++ compatible 8cd4248f7f74e2ea91a8ea22c6d685d5b13a0fcb - Discard ignored signals on New Technology 7de2f229a7e9f19074342010d57155d4fa4cc451
- Fix inability to add some signals to mask on NT 598640864aadfe3bad418bceb9ae2fef3a0c825b
- Fix issue with ZipOS file descriptors in MODE=asan 3265324e00634e8e9d659ba705da5b0ce88e78ef
- The virtual memory layout is now more optimized b69f3d2488dbaf9dcc541e699f5b7c09fbf046e0
- Repository is now buildable by GCC11
Breaking changes
- Underscore added to many non-standard APIs to improve open source compatibility 6f7d0cb1c3962f7cb474b04de75df7cd82a3e5d3
- Windows 7 and Vista support has now been moved to our vista branch 134ffee51900a4d70e8e68b598374856ceec8355
- Add sys_ prefix to unwrapped system calls to improve open source compatibility aab4ee407299c5282b71a175045aa5c526ed6852
- 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 1ad2f530f9c6197dfca199fc67a2296bbaac856e - 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
- We built an online game (https://ipv4.games/) based on Redbean that handled 600 qps on just 2 vcpu (Loam and https://github.com/shamblesides/turfwar/)
- We got Actually Portable Perl 96% passing test suites (G4Vi https://github.com/G4Vi/perl5/blob/cosmo/README.cosmo)
- We got Actually Portable Python 3.11.0rc1 passing 96% test suites (ahgamut https://github.com/ahgamut/cpython/tree/cosmo_py311)
- We got 176 Actually Portable Rust demo programs to build (ahgamut https://github.com/ahgamut/rust-ape-example)
1、 cosmopolitan-2.1.tar.gz 61.58MB
2、 cosmopolitan-amalgamation-2.1.zip 7.13MB
3、 cosmopolitan-amalgamation-dbg-2.1.zip 11.47MB
4、 cosmopolitan-amalgamation-rel-2.1.zip 7.07MB
5、 cosmopolitan-amalgamation-tiny-2.1.zip 2.58MB