They also made cosmopolitan libc [0] which outputs a single binary that runs on many platforms.
> The above command fixes GCC so it outputs portable binaries that will run on every Linux distro in addition to Mac OS X, Windows NT, FreeBSD, OpenBSD, and NetBSD too. Your program will also boot on bare metal too. In other words, you've written a normal textbook C program, and thanks to Cosmopolitan's low-level linker magic, you've effectively created your own operating system which happens to run on all the existing ones as well.
Brought up recently here: "Debugging C with Cosmopolitan Libc" [1]
And introduced here "Cosmopolitan Libc: build-once run-anywhere C library" [2]
Can you build cross platform libs? So like say you have python or java that calls out to some native code (ex: high performance math routines), but that native code is actually "cosmopolitan"/crossplatform?
Why not? The difference between an executable and a dynamic library is that an executable has one entry point but a dynamic library can have more than one.
> It'll be nice to know that any normal PC program we write will "just work" on Raspberry Pi and Apple ARM. All we have to do embed an ARM build of the emulator above within our x86 executables, and have them morph and re-exec appropriately, similar to how Cosmopolitan is already doing doing with qemu-x86_64, except that this wouldn't need to be installed beforehand. The tradeoff is that, if we do this, binaries will only be 10x smaller than Go's Hello World, instead of 100x smaller.
…No mention of the fact that an interpreter is typically at least 10x slower than native execution. The readme does say "we're still likely to add something like jit in the near future", but for now this isn't very practical.
This project is interesting, but I looked at tests folder and there is not many tests despite software is so complex. Also I wonder, isn't it better to write tests in languages like Python?
Also, I don't see what's the use of Cosmopolitan Libc. In what situation does one need a CLI-only binary that can run on any system?
Author here. Right now it's being tested by running precompiled binaries. See https://github.com/jart/blink/tree/master/third_party/cosmo Most of these test binaries are sourced from the cosmopolitan repository, and many of those come from other projects like nsync, mbedtls, etc. I've recently started working on a unit testing method that's written in plain assembly, to hopefully catch more of the things that would show up in opcodes that compilers don't generate. See https://github.com/jart/blink/tree/master/test/asm
Having a copy of Perl, for example (https://computoid.com/APPerl/), on a USB stick means one could run scripts using the same version of Perl across multiple platforms, no need to wrestle with outdated instances.
Also, it's an awesome hack! C'mon, man, this is Hacker News!
There are specific comments already, but multiple successive slashes are treated as a single slash, in every case except when a path begins with exactly two slashes, in which case it's implementation dependent.
You can use it to configure the build mode: `build/bootstrap/make.com -j8 MODE=rel o/rel/blink/blink`; no MODE will build a default config. This is used across all cosmopolitan projects; for example, this is for redbean: https://redbean.dev/#source.
> The above command fixes GCC so it outputs portable binaries that will run on every Linux distro in addition to Mac OS X, Windows NT, FreeBSD, OpenBSD, and NetBSD too. Your program will also boot on bare metal too. In other words, you've written a normal textbook C program, and thanks to Cosmopolitan's low-level linker magic, you've effectively created your own operating system which happens to run on all the existing ones as well.
Brought up recently here: "Debugging C with Cosmopolitan Libc" [1]
And introduced here "Cosmopolitan Libc: build-once run-anywhere C library" [2]
[0] https://justine.lol/cosmopolitan/index.html
[1] https://news.ycombinator.com/item?id=33312012
[2] https://news.ycombinator.com/item?id=25556286