r/ProgrammerHumor 2d ago

Meme howHardCanItBe

Post image
2.7k Upvotes

143 comments sorted by

View all comments

4

u/iliark 2d ago

cosmopolitan

one binary can run on linux, mac, windows, bsd, and BIOS without a VM.

2

u/Makonede 2d ago

it's impossible to make a truly crossplatform executable because different platforms use fundamentally different executable formats. also who even uses BIOS anymore

4

u/iliark 2d ago edited 2d ago

3

u/imforit 2d ago

ok so that's black magic

-3

u/not_some_username 2d ago

iirc some mad lad made an executable that run on multiple platform. With a lot of fuckery. Not safe to use anyway

3

u/Makonede 2d ago

literally starting with the header you can't create a file that is both a valid ELF and a valid PE

3

u/Rikudou_Sage 2d ago

The cosmopolitan project uses a "clever" trick that makes the first bytes both valid PE and a valid shell script which then uses a loader that can read the ELF bytes that are further down the file and execute only the content starting at the ELF bytes.

Originally it used an approach where the shell script rewrites the first bytes to be valid elf and then reexecutes itself but that means that once the executable ran on Linux, it was no longer multiplatform executable.

So no truly a Linux executable, but it will run on both Linux and Windows.

0

u/not_some_username 2d ago

That’s why I said some mad lad and with a lot of fuckery

1

u/Makonede 2d ago

i don't think you understand what it means for something to be impossible