News for hackers. Stuff that matters.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by amelius on Monday January 26, 2026 @04:47AM (#46763616)
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?
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by TheDong on Monday January 26, 2026 @05:00AM (#46763704)
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 available)

6. https://flatpak.org/

7. https://en.wikipedia.org/wiki/Snap_(software)

AppImage is the closest to what you want I think.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by gilli on Monday January 26, 2026 @05:54AM (#46764128)
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 Dl... by VadimPR on Monday January 26, 2026 @05:58AM (#46764157)
We fix this issue by distributing ours in a tar file with the executable bit set. Linux novices can just double click on the tar to exact it and double click again on the actual appimage.

Been doing it this way for years now, so it's well battle tested.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by account42 on Monday January 26, 2026 @06:57AM (#46764577)
That kind of defeats the point of an AppImage though - you could just as well have a tar archive with a c classic collection of binaries + optional launcher script.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by VadimPR on Tuesday January 27, 2026 @02:40AM (#46776662)
A single file is much better to manage on the eyes than a whole bunch of them, plus AppImages can be installed into the desktop using integration.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by amelius on Monday January 26, 2026 @05:35AM (#46763992)
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?

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mdavid626 on Monday January 26, 2026 @06:00AM (#46764166)
Don't forget - AppImage won't work if you package something with glibc, but run on musl/uclibc.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by c0balt on Monday January 26, 2026 @05:47AM (#46764080)
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 Dl... by direwolf20 on Monday January 26, 2026 @06:35AM (#46764416)
No, that's a copyright violation, and it won't run on AMD or Intel GPUs, or kernels with a different Nvidia driver version.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by amelius on Monday January 26, 2026 @07:01AM (#46764613)
But this ruins the entire idea of packaging software in a self-contained way, at least for a large class of programs.

It makes me wonder, does the OS still take its job of hardware abstraction seriously these days?

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by direwolf20 on Monday January 26, 2026 @07:46AM (#46764990)
It does, and one way it does that is by dynamically loading the right driver code for your hardware.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by holowoodman on Monday January 26, 2026 @07:09AM (#46764688)
The OS does. Nvidia doesn't.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by direwolf20 on Monday January 26, 2026 @07:46AM (#46764984)
Does Nvidia not support OpenGL?
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by holowoodman on Monday January 26, 2026 @07:51AM (#46765030)
Not really. Nvidia-OpenGL is incompatible to all existing OS OpenGL interfaces, so you need to ship a separate libGL.so if you want to run on Nvidia. In some cases you even need separate binaries, because if you dynamically link against Nvidia's libGL.so, it won't run with any other libGL.so. Sometimes also vice versa.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by direwolf20 on Monday January 26, 2026 @08:44AM (#46765553)
Does AMD use a statically linked OpenGL?
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by holowoodman on Monday January 26, 2026 @08:50AM (#46765603)
AMD uses the dynamically linked system libGL.so, usually Mesa.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by direwolf20 on Monday January 26, 2026 @11:18AM (#46767547)
So you still need dynamic linking to load the right driver for your graphics card.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by holowoodman on Monday January 26, 2026 @11:46AM (#46767918)
Most stuff like that uses some kind of "icd" mechanism that does 'dlopen' on the vendor-specific parts of the library. Afaik neither OpenGL nor Vulkan nor OpenCL are usable without at least dlopen, if not full dynamic linking.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by maccard on Monday January 26, 2026 @08:41AM (#46765518)
That’s a licensing problem not a packaging problem. A DLL is a DLL - only thing that changes is whether you’re allowed redistribute it
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by ValdikSS on Monday January 26, 2026 @09:18AM (#46765915)
AppImage is not what you need. It's just an executable wrapper for the archive. To make the software cross-distro, you need to compile it manually on an old distro with old glibc, make sure all the dependencies are there, and so on.

https://docs.appimage.org/reference/best-practices.html#bina...

There are several automation tools to make AppImages, but they won't magically allow you to compile on the latest Fedora and expect your executable to work on Debian Stable. It's still require quite a lot of manual labor.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by ndiddy on Monday January 26, 2026 @11:26AM (#46767653)
Yeah a lot of Appimage developers make assumptions about what their systems have as well (i.e. "if I depend on something that is installed by default on Ubuntu desktop then it's fine to leave out"). For example, a while ago I installed an Appimage GUI program on a headless server that I wanted to use via X11 forwarding. I ended up having to manually install a bunch of random packages (GTK stuff, fonts, etc) to get it to run. I see Appimage as basically the same as distributing Linux binaries via .tar.gz archives, except everything's in a single file.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by ValdikSS on Monday January 26, 2026 @09:20AM (#46765934)
>I wonder though, if I package say a .so file from nVidia, is that allowed by the license?

It won't work: drivers usually require exact (or more-or-less the same) kernel module version. That's why you need to explicitly exclude graphics libraries from being packaged into AppImage. This make it non-runnable on musl if you're trying to run it on glibc.

https://github.com/Zaraka/pkg2appimage/blob/master/excludeli...

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by saidinesh5 on Monday January 26, 2026 @04:27PM (#46771778)
Typically appimage packaging excludes the .so files that are expected to be provided by the base distro.

Any .so from nvidia is supposed to be one of those things. Because it also depends on the drivers etc.. provided by nvidia.

Also on a side note, a lot of .so files also depends on other files in /usr/share , /etc etc...

I recommend using an AppImage only for the happy path application frameworks they support (eg. Qt, Electron etc...). Otherwise you'd have to manually verify all the libraries you're bundling will work on your user's distros.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by a022311 on Monday January 26, 2026 @08:20AM (#46765303)
It should be noted that AppImages tend to be noticeably slower at runtime than other packaging methods and also very big for typical systems which include most libraries. They're good as a "compile once, run everywhere" approach but you're really accommodating edge cases here.

A "works in most cases" build should also be available for that that it would benefit. And if you can, why not provide specialized packages for the edge cases?

Of course, don't take my advice as-is, you should always thoroughly benchmark your software on real systems and choose the tradeoffs you're willing to make.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by saghm on Monday January 26, 2026 @11:20AM (#46767569)
IMO one of the best features of AppImage is that it makes it easy to extract without needing external tools. It's usually pretty easy for me to look at an AppImage and write a PKGBUILD to make a native Arch package; the format already encodes what things need to be installed where, so it's only a question of whether the libraries it contains are the same versions of what I can pull in as dependencies (either from the main repos or the AUR). If they are, my job is basically already done, and if they aren't, I can either choose to include them in the package itself assuming I don't have anything conflicting (which is fine for local use even if it's not something that's usually tolerated when publishing a package) or stick with using the AppImage.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by a022311 on Monday January 26, 2026 @12:34PM (#46768703)
I agree. I've seen quite a few AUR packages built that way and I'm using a few myself too. The end user shouldn't be expected to do this though! :D
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by saghm on Tuesday February 03, 2026 @10:18PM (#46881037)
I agree with you as well! I don't think AppImage is perfect by any means. I do prefer it overall to the other commonly mentioned "universal" package tools like snap and flatpak, but I think my ideal system would essentially be a middleware protocol between build tool "frontends" and package format "backends" and then an ecosystem of tooling around that. LLVM and LSP haven't magically solved every issue with compilers and editor support for languages by any means, but they have significantly moved the needle on the average experience for quite a large number of end users even if they never directly touch any of the underlying protocols.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by badsectoracula on Monday January 26, 2026 @01:14PM (#46769328)
> It should be noted that AppImages tend to be noticeably slower at runtime than other packaging methods

'Noticeably slower' at what? I've run, e.g. xemu (original xbox emulator) as both manually built from source and via AppImage-based released and i never noticed any difference in performance. Same with other AppImage-based apps i've been using.

Do you refer to launching the app or something like that? TBH i cannot think of any other way an AppImage would be "slower".

Also from my experience, applications released using AppImages has been the most consistent by far at "just working" on my distro.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by lizknope on Monday January 26, 2026 @07:10AM (#46764692)
15-30 years ago I managed a lot of commercial chip design EDA software that ran on Solaris and Linux. We had wrapper shell scripts for so many programs that used LD_LIBRARY_PATH and LD_PRELOAD to point to the specific versions of various libraries that each program needed. I used "ldd" which prints out the shared libraries a program uses.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mkoubaa on Monday January 26, 2026 @07:29AM (#46764853)
Sounds painful. Better to distrib a separate bundle per platform and use RPATH
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by ValdikSS on Monday January 26, 2026 @09:22AM (#46765956)
It you know what you're doing and scrupulous enough, you can package the software in a way that it works 25 years later.

https://xcancel.com/ValdikSS/status/1843044963443253678

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by fieu on Monday January 26, 2026 @06:01AM (#46764174)
Ermine: https://www.magicermine.com/

It works surprisingly well but their pricing is hidden and last time I contacted them as a student it was upwards of $350/year

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by alas44 on Monday January 26, 2026 @07:04AM (#46764645)
There is this project "actually portable executable"/cosmopolitan libc https://github.com/jart/cosmopolitan that allows a compile once execute anywhere style type of C++ binary
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by secure on Monday January 26, 2026 @06:55AM (#46764564)
https://github.com/gokrazy/freeze is a minimal take on this
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mdavid626 on Monday January 26, 2026 @04:51AM (#46763643)
You can "package" all .so files you need into one file, there are many tools which do this (like a zip file).

But you can't take .so files and make one "static" binary out of them.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by fc417fc802 on Monday January 26, 2026 @06:38AM (#46764442)
Well not a static binary in the sense that's commonly meant when speaking about static linking. But you can pack .so files into the executable as binary data and then dlopen the relevant memory ranges.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mdavid626 on Monday January 26, 2026 @07:08AM (#46764676)
Yes, that's true.

But I'm always a bit sceptical about such approaches. They are not universal. You still need glibc/musl to be the same on the target system. Also, if you compile againt new glibc version, but try to run on old glibc version, it might not work.

These are just strange and confusing from the end users' perspective.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by toast0 on Monday January 26, 2026 @11:33AM (#46767746)
> But I'm always a bit sceptical about such approaches. They are not universal. You still need glibc/musl to be the same on the target system. Also, if you compile againt new glibc version, but try to run on old glibc version, it might not work.

Why would you include most of your dynamic libraries but not your libc?

You could still run into problems if you (or your libraries) want to use syscalls that weren't available on older kernels or whatever.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mdavid626 on Monday January 26, 2026 @11:44AM (#46767883)
You can include it, but

- either you use chroot, proot or similar to make /lib path contain your executable’s loader

- or you hardcode different loader path into your executable

Both are difficult for an end user.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by toast0 on Monday January 26, 2026 @11:58AM (#46768104)
This isn't that hard. Your executable should be a statically linked stub loader with an awful lot of data, the stub loader dynamically links your real executable from the data and runs it.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by fc417fc802 on Monday January 26, 2026 @01:03PM (#46769167)
To add to this, in case of any remaining confusion. You can implement your own execve in userspace. [0] But the kernel's execve is a piece of machinery that invokes the loader so obviously it follows that you're free to make any changes you'd like to the overall process.

Bonus points if you add compression or encryption and manage to trip a virus scanner or three. [1]

[0] https://grugq.github.io/docs/ul_exec.txt

[1] https://blackhat.com/presentations/bh-usa-07/Yason/Whitepape...

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by X-Ryl669 on Wednesday January 28, 2026 @03:40AM (#46792621)
No you can't. dlopen signature takes a file path, not a memory range. And if you start to save the libraries to the filesystem before opening them, there's no difference to shipping an archive directly and skip the trouble of your own archive code.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by geocar on Monday January 26, 2026 @08:30AM (#46765397)
> But you can't take .so files and make one "static" binary out of them.

Yes you can!

This is more-or-less what unexec does

- https://news.ycombinator.com/item?id=21394916

For some reason nobody seems to like this sorcery, probably because it combines the worst of all worlds.

But there's almost[1] nothing special about what the dynamic linker is doing to get those .so files into memory that it can't arrange them in one big file ahead of time!

[1]: ASLR would be one of those things...

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by mdavid626 on Monday January 26, 2026 @11:29AM (#46767690)
What if the library you use calls dlopen later? That’ll fail.

There is no universal, working way to do it. Only some hacks which work in some special cases.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by geocar on Monday January 26, 2026 @02:10PM (#46770108)
> What if the library you use calls dlopen later? That’ll fail.

Nonsense. xemacs could absolutely call dlopen.

> There is no universal, working way to do it. Only some hacks which work in some special cases.

So you say, but I remember not too long ago you weren't even aware it was possible, and you clearly didn't check one of the most prominent users of this technique, so maybe you should also explain why I or anyone else should give a fuck about what you think is a "hack"?

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by formerly_proven on Monday January 26, 2026 @05:22AM (#46763891)
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 libc with your binary.

edit: Mild correction, there is this: https://sourceforge.net/projects/statifier/ But the way this works is that it has the dynamic linker load everything (without ASLR / in a compact layout, presumably) and then dumps an image of the process. Everything else is just increasingly fancy ways of copying shared objects around and making ld.so prefer the bundled libraries.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by aa-jv on Monday January 26, 2026 @05:09AM (#46763778)
AppImage comes close to fulfilling this need:

https://appimage.github.io/appimagetool/

Myself, I've committed to using Lua for all my cross-platform development needs, and in that regard I find luastatic very, very useful ..

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by ryan-c on Monday January 26, 2026 @09:00AM (#46765712)
(not an endorsement, I do not use it, but I know of it)

https://www.magicermine.com/

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by saghm on Monday January 26, 2026 @11:09AM (#46767402)
I don't think it's as simple as "run this one thing to package it", so if the process rather than the format is what you're looking for, this won't work, but that sounds a lot like how AppImages work from the user perspective. My understanding is that an AppImage is basically a static binary paired with a small filesystem image containing the "root" for the application (including the expected libraries under /usr/lib or wherever they belong). I don't line everything about the format, but overall it feels a lot less prescriptive than other "universal" packages like flatpak or snap, and the fact that you can easily extract it and pick out the pieces you want to repackage without needing any external tools (there are built-in flags on the binary like --appimage-extract) in helps a lot.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by jcalvinowens on Monday January 26, 2026 @11:20AM (#46767578)

  mkdir chroot
  cd chroot
  for lib in $(ldd ${executable} | grep -oE '/\S+'); do
    tgt="$(dirname ${lib})"
    mkdir -p .${tgt}
    cp ${lib} .${tgt}
  done
  mkdir -p .$(dirname ${executable})
  cp ${executable} .${executable}
  tar cf ../chroot-run-anywhere.tgz .
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by saidinesh5 on Monday January 26, 2026 @04:31PM (#46771849)
You're supposed to do this recursively for all the libs no?

Eg. Your App might just depend on libqt5gui.so but that libqt5gui.so might depend on some libxml etc...

Not to mention all the files from /usr/share etc... That your application might indirectly depend on.

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by jcalvinowens on Monday January 26, 2026 @06:14PM (#46773072)
> You're supposed to do this recursively

ldd works recursively.

> Not to mention all the files from /usr/share

Well yeah, there obviously cannot be a generic way to enumerate all the files a program might open...

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by Conscat on Monday January 26, 2026 @01:56PM (#46769937)
Someone already mentioned AppImage, but I'd like to draw attention to this alternate implementation that executes as a POSIX shell script, making it possible to dynamic dispatch different programs on different architectures. e.g. a fat binary for ARM and x64.

https://github.com/mgord9518/shappimage

Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by sekh60 on Monday January 26, 2026 @02:05PM (#46770049)
So autotools but for execution instead of compilation?
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by fdgdd on Monday January 26, 2026 @05:32PM (#46772532)
Exodus (https://github.com/intoli/exodus) used to be good for this but is giving me a Python error these days.
Re:The Holy Grail of Linux Binary Compatibility: Musl and Dl... by MrDrMcCoy on Tuesday January 27, 2026 @12:19PM (#46783061)