mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
mirror of https://github.com/jart/cosmopolitan
We always favor calling functions like openat(), fstatat(), etc. because Linux, XNU, FreeBSD, and OpenBSD all elected to support them, while some systems like Android love them so much, that they stopped supporting the old interfaces. This change ensures that when dirfd is actually a dirfd and not AT_FDCWD we'll do the right thing on Windows NT. We use an API that's been around since Vista to accomplish that. This change also adds exponential backoff to chdir() on Windows since it seems almost as flaky on Windows 7 as the rmdir() function. |
||
---|---|---|
.github | ||
ape | ||
build | ||
dsp | ||
examples | ||
libc | ||
net | ||
test | ||
third_party | ||
tool | ||
usr/share | ||
.clang-format | ||
.gitignore | ||
Makefile | ||
NOTICE | ||
README.md |
Cosmopolitan
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.
Background
For an introduction to this project, please read the αcτµαlly pδrταblε εxεcµταblε blog post and cosmopolitan libc website. We also have API documentation.
Getting Started
Here's how to get started with the freestanding hermetically-sealed monolithic source repository:
tar xf cosmopolitan-0.1.1.tar.gz # see our releases page
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.1.zip # see our releases page
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