Follow

Cosmopolitan C Library: "build-once run-anywhere c without devops"

justine.lol/cosmopolitan/index

Purports to create small ~40kb executables that run on Linux, Mac, Windows, FreeBSD, and OpenBSD. In the same binary.

@saper sadly still limited by the physical properties of circuits :)

@saper however, you could probably stick an ARM binary in there alongside, somehow, or use a translation layer. I think one of the author's related pages mentions it.

@cancel well ARM I think has less ABI issues like Intel operating systems have. Thanks for posting it!

@saper @cancel more like less legacy ABIs :)

There is still some "funny" float ABI issues on ARM.
@cancel @saper
There were at least a couple magical place incantations that would let the same binary branch to different sections for x86 and 32-bit PowerPC. It might also be possible with x64 and Arm64 ...

@alice

Doesn't sounds too far fetched to me, but sure does looks like fun :333

@cancel

@cancel Almost works, but some examples need patching on Guix/Nix. Still, nice. I wonder if pack could generate binaries in this format.

@cancel wow, that's crazy. i never thought that would be possible

@replikvlt @cancel oh yeah. I doubt it's gonna work with GL but we have software renderer.

Also it's always nice to have alternative libc implementation that even works on Windows.

@cancel I was very curious what this community would think. Justine mentions it's not suited for gui development I think - I wonder how it would work with the SDL work various ppl in merveilles are doing. Or your own ripcord stuff

@metasyn There's not any practical way to do something like Ripcord with this, as it currently stands, because there's already so much platform-dependent code. Both in the Qt framework and in the application itself.

You could probably do GUI development with this on Linux using some of the tricks I saw the author of Zig trying recently. GUI development on Windows might also not be too hard... I haven't tried it yet so I don't know what its DLL capabilities are or could be.

@metasyn SDL is pretty big and it has lots of platform-dependent stuff. You could not really use SDL from this. Also, SDL is versioned, so you have to make sure you're building & linking against the correct version, which would mean statically linking in this case. And then you have problems with the C toolchain and GUI static linking on Linux, and also your program would be 10mb+ just for a hello world, probably.

@cancel makes sense. I recently have been trying out musl instead of libc for actually static binaries in Nim and it can definitely blow up the binary size. But that's what you get for "real" portability sorta?

@metasyn musl *is* a libc. You mean musl instead of glibc? :)

You should see if you can enable some compiler option to strip unused functions. It might make your final program binary smaller, if you're using musl.

@cancel yes I do mean that, oops. I was trying using both strip and upx which made a huge difference.

@metasyn I would avoid UPX, because it can really slow down startup time, and on Windows, it will trip antivirus constantly.

@cancel oh interesting. I saw actually I might be able to get a lot more milage just ensuring that debug symbols weren't included blog.johnnovak.net/2020/12/21/

@metasyn oh, uh, yeah... that will be far larger than your program itself. you should absolutely remove those.

@cancel didn't have time so obviously I spent that time I didn't have messing with this, and did a small test between Linux and FreeBSD, and it works...
save the mentioned zsh issue.
Bottom line: this is likely to go places and start something.
(And likely get mainstream attention when the first malware made with it hits.)

@cancel Unrelated, but that's a really nice looking website

@wiecek what do you want me to do about it? the alt text says that it's the same text as on the page.

@cancel I want you to post the original text instead of its screenshot.
@cancel Oh, I forgot that.

Well, you have an option to split the post into parts. Which is still better for users than the screenshot. #yet another fcking opinion in internet
@wiecek @cancel here is also more usable AP implementations with larger or even configurable limits.
Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.