back

by schmorptron·2y ago·view on hn ↗
For those who don't want to click through to the main github description: "Cosmopolitan Libc makes C a build-anywhere 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 on AMD64 and ARM64 with the best possible performance. "
3 comments
> runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS on AMD64 and ARM64 with the best possible performance

Is it possible that a single binary will run on both AMD64 and ARM64?

As long as the subset of compatible instructions exist, it is likely possible to program a binary version of

    If you speak english, go to page 7.
    Si hablas español, ve a la página 25.
Note that the instructions don't have to be completely equivalent - all that's required is for some set of bytes to be arranged such that the same pattern will be interpreted by AMD64 as jump to X and by ARM64 as jump to Y.

Afterwards, it's all about segmenting the instructions in blocks, one for each OS/architecture.

If this means the end of libc version errors, then count me in.

One question, is C++ supported?

Absolutely. Just download and extract cosmocc-3.5.8.zip and use its cosmoc++ command instead of g++. By default it'll use LLVM's libcxx STL although we've been working on our own versions of classes like std::set (called ctl::set) that are better. For example, just using ctl::vector alone might help your C++ code compile noticeably faster. https://github.com/jart/cosmopolitan/tree/master/ctl
That should've been in the title:

"Cosmopolitan Libc makes C a build-anywhere run-anywhere language"

Let the furious downvoting begin.