Live data from Hacker News

The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

github.com

21–30 of 215 posts

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#21

Earlier quoted context omitted.

Yup. Just compile it as static executable. Static binaries are very undervalued imo.

The "just" is doing a lot of heavylifting here (as detailed in the article), especially for anything that's not a trivial cmdline tool.

Ack. I went down that rabbit hole to "just" build a static Python: https://beza1e1.tuxen.de/python_bazel.html

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#22

This seems interesting even regardless of go. Is it realistic to create an executable which would work on very different kinds of Linux distros? e.g. 32-bit and 64-bit? Or maybe some general framework/library for building an arbitrary program at least for "any libc"?

Yup. Just compile it as static executable. Static binaries are very undervalued imo.

As TFA points out at the beginning, it's not so simple if you want to use the GPU.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#23

Earlier quoted context omitted.

Cosmopolitan goes one further: [binaries] that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS on AMD64 and ARM64 https://justine.lol/cosmopolitan/

>Linux if you configure binfmt_misc >Windows if you disable Windows Defender >OpenBSD only older versions

Yeah while APE is a technically impressive trick, these issues far outweigh the minor convenience of having a single binary.

For most cases, a single Windows exe that targets the oldest version you want to support plus a single Glibc binary that dynamically links against the oldest version you want to support and so on is still the best option.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#24
post #5

Is there a tool that takes an executable, collects all the required .so files and produces either a static executable, or a package that runs everywhere?

I don't think you can link shared objects into a static binary because you'd have to patch all instances where the code reads the PLT/GOT, but this can be arbitrarily mangled by the optimizer, and turn them back into relocations for the linker to then resolve them. You can change the rpath though, which is sort of like an LD_LIBRARY_PATH baked into the object, which makes it relatively easy to bundle everything but l…

[deleted]

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#25

Earlier quoted context omitted.

Cosmopolitan goes one further: [binaries] that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS on AMD64 and ARM64 https://justine.lol/cosmopolitan/

Clearly a joke if it uses the .lol tld.

It's his personal website lol.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#27

This seems interesting even regardless of go. Is it realistic to create an executable which would work on very different kinds of Linux distros? e.g. 32-bit and 64-bit? Or maybe some general framework/library for building an arbitrary program at least for "any libc"?

Yup. Just compile it as static executable. Static binaries are very undervalued imo.

We had a time when static binaries where pretty much the only thing we had available.

Here is an idea, lets go back to pure UNIX distros using static binaries with OS IPC for any kind of application dynamism, I bet it will work out great, after all it did for several years.

Got to put that RAM to use.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#28
post #20
post #11

Earlier quoted context omitted.

There are things like this. The things I know of and can think of off the top of my head are: 1. appimage https://appimage.org/ 2. nix-bundle https://github.com/nix-community/nix-bundle 3. guix via guix pack 4. A small collection of random small projects hardly anyone uses for docker to do this (i.e. https://github.com/NilsIrl/dockerc ) 5. A docker image (a package that runs everywhere, assuming a docker runtime is a…

AppImage looks like what I need, thanks. I wonder though, if I package say a .so file from nVidia, is that allowed by the license?

Depends on the license and the specific piece of software. Redistribution of commercial software is may be restricted or require explicit approval.

You generally still also have to abide by license obligations for OSS too, e. G., GPL.

To be specific for the exampls, Nvidia has historically been quite restrictive (only on approval) here. Firmware has only recently been opened up a bit and drivers continue to be an issue iirc.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#29
post #11
post #5

Is there a tool that takes an executable, collects all the required .so files and produces either a static executable, or a package that runs everywhere?

There are things like this. The things I know of and can think of off the top of my head are: 1. appimage https://appimage.org/ 2. nix-bundle https://github.com/nix-community/nix-bundle 3. guix via guix pack 4. A small collection of random small projects hardly anyone uses for docker to do this (i.e. https://github.com/NilsIrl/dockerc ) 5. A docker image (a package that runs everywhere, assuming a docker runtime is a…

I wish AppImage was slightly more user friendly and did not require the user to specifically make it executable.

Re: The Holy Grail of Linux Binary Compatibility: Musl and Dlopen

#30
post #27

Earlier quoted context omitted.

Yup. Just compile it as static executable. Static binaries are very undervalued imo.

We had a time when static binaries where pretty much the only thing we had available. Here is an idea, lets go back to pure UNIX distros using static binaries with OS IPC for any kind of application dynamism, I bet it will work out great, after all it did for several years. Got to put that RAM to use.

I've been static linking my executables for years. The downside, that you might end up with an outdated library, is no match for the upsite: just take the binary and run it. As long as you're the only user of the system and the code is your own you're going to be just fine.
Post reply on HN