Replies: 1 comment 1 reply
-
Hello, Thanks for all your innovative work, @jart! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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.
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:
Breaking Changes
/zip/...
rather thanzip:...
when open()'ing assets stored in the PKZIP structure of your executable program. 00611e9/c/...
paths on Windows rather thanC:/...
. 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
toINFOF
in the logging API. 0584684intmax_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 forint128_t
. Functions likebsrmax()
are now calledbsr128()
. 868af3fnothrow
todontthrow
andnodiscard
is nowdontdiscard
. 868af3fFeatures
--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. 47a53e1ape/apeinstall.sh
program in this repository._spawn()
and_join()
functions. We're working on POSIX Threads support and recommend using our newpthread_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. 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 callingarch_prctl
. Please note if you use threads, this will makeerrno
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, useMODE=tiny
orMODE=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, useMODE=tiny
orMODE=rel
. 14e192eo//third_party/python/python.com
which includes animport cosmo
module that lets you use our best features too.closefrom()
system call for Linux 5.9+, FreeBSD 8+, and OpenBSD.clock_gettime
andgettimeofday
functions now go 10x faster on Linux via the vDSO.nointernet()
function which is similar in spirit to djb'sdisablenetwork()
function.privileged
runtime.Bug Fixes
This discussion was created from the release Cosmopolitan v2.0.
Beta Was this translation helpful? Give feedback.
All reactions