News for hackers. Stuff that matters.
Re:Oasis: a small statically-linked Linux system by arendtio on Tuesday December 01, 2020 @11:56AM (#25266954)
> So I'd love an ecosystem where things tend to be statically linked unless there is a good reason not to.

Well, every time there is a bug fix in one of your dependencies you/your distribution would have to recompile everything that depends on it. Which will use quite some resources.

So to actually use this you would have to reinstall (nearly) all programs once a week or so (no matter if source or binary distribution). While that is quite possible with modern internet connections, I am not sure if it solves all the problems you might think it solves. After all, even nowadays application authors could provide static packages, but many don't do it.

After using quite a few distributions over the years, I like Arch Linux best at the moment, as the combination of binary distribution, with frequent updates, and the source based AUR, with the very large amount of packages, suits my needs very good.

Re:Oasis: a small statically-linked Linux system by retrac on Tuesday December 01, 2020 @12:14PM (#25267179)
> every time there is a bug fix in one of your dependencies you/your distribution would have to recompile everything that depends on it

Back in the dark ages, some mainframe operating systems like MVS normally stored executables as object files, and would link the program every time you executed it.

Has the on-disk space savings and updateable libraries of dynamic linking, without most of the complexity. I believe the original motivation was to allow an executable to run at an arbitrary address on systems without virtual memory though.

Re:Oasis: a small statically-linked Linux system by robocat on Tuesday December 01, 2020 @04:09PM (#25269926)
It was for personal operating systems (and ancient mainframes) that had a multitasking OS but without any MMU support in the hardware. Relocatable executables were required so that you could load multiple executables at different addresses within the single address space of the memory. This is now called Position Independent Code[1].

Modern MMUs meant that the OS would define specific addresses for use by a program, so for example all ELF programs in a distribution would have the same starting address in memory hard coded into the executable (one virtual address within a process is mapped to a different physical memory address for each process by the MMU).

[1] https://en.wikipedia.org/wiki/Position-independent_code

Re:Oasis: a small statically-linked Linux system by Someone on Tuesday December 01, 2020 @05:39PM (#25271005)
There’s a difference. Position independent means you can move the executable anywhere and run it.

Relocatable means the binary has enough information to fix any absolute addresses in the code after that move. That’s extra work, and means you cannot have the same physical memory mapped to different virtual addresses in different processes, and that you have to either swap out the relocated memory, or repeat the relocation when you swap in the code again (I’m not aware of any OS doing the latter, and don’t see a nice way to do it, but it is a possibility).

https://en.wikipedia.org/wiki/Position-independent_code:

“In computing, position-independent code[1] (PIC[1]) or position-independent executable (PIE)[2] is a body of machine code that, being placed somewhere in the primary memory, executes properly regardless of its absolute address.”

https://en.wikipedia.org/wiki/Relocation_(computing):

“Relocation is the process of assigning load addresses for position-dependent code and data of a program and adjusting the code and data to reflect the assigned addresses.”

Re:Oasis: a small statically-linked Linux system by 1996 on Tuesday December 01, 2020 @12:19PM (#25267237)
I would be surprised if there was not a way to take a dynamic executable, "add in" all the required libraries, and return a fat static executable
Re:Oasis: a small statically-linked Linux system by AnIdiotOnTheNet on Tuesday December 01, 2020 @12:37PM (#25267483)
If you know of such a utility I'd like to see it, because I've looked and never found it. The closest I've seen are things like AppImage.
Re:Oasis: a small statically-linked Linux system by efrecon on Tuesday December 01, 2020 @02:39PM (#25268937)
I have used exodus to do this in the past. https://github.com/intoli/exodus
Re:Oasis: a small statically-linked Linux system by AnIdiotOnTheNet on Tuesday December 01, 2020 @02:49PM (#25269061)
> Exodus handles bundling all of the binary's dependencies, compiling a statically linked wrapper for the executable that invokes the relocated linker directly, and installing the bundle in ~/.exodus/ on the remote machine. You can see it in action here.

That isn't really what is being described, or at least not what I'm referring to. It's more like a self-extractor.

Re:Oasis: a small statically-linked Linux system by efrecon on Wednesday December 02, 2020 @03:17PM (#25281005)
You are right. My mistake. I remembered it wrong.
Re:Oasis: a small statically-linked Linux system by throwaway894345 on Tuesday December 01, 2020 @02:14PM (#25268684)
It exists. I came across at least one such project last year, but I don't recall the name. :(
Re:Oasis: a small statically-linked Linux system by 1996 on Tuesday December 01, 2020 @01:35PM (#25268225)
Shell scripting and ld tools should allow you to make that yourself.

EDIT: people are apparently entitled to solutions for their problems...

> Care to elaborate?

> Show us a script then! Your internet fame awaits.

I'm not interested in fame, or in reinventing the wheel.

Apparently, you are unfamiliar with this process, so TLDR: there are basically 2 approaches, in order of complexity: 1. working with ldtools or 2. running the executable to find the various parts then dumping a binary, (3 if you consider putting the libraries in a directory then run with LD_LIBRARY_PATH=/thisdir myexecutable)

Let me google some existing tools for you:

https://github.com/systems-nuts/dynamic_to_static

http://bitwagon.com/jumpstart/jumpstart.html

http://statifier.sourceforge.net/

https://www.ucc.asn.au/~dagobah/things/make-static.html

https://web.archive.org/web/20130114222319if_/http://dagobah... with patch and explanation on https://stackoverflow.com/questions/17390722/how-can-i-conve...

A better approach from 15 years ago is slinky, so that you can "update" the libraries if needed: https://www.usenix.org/legacy/publications/library/proceedin...

There's nothing fancy in there. It just requires some effort.

Re:Oasis: a small statically-linked Linux system by AnIdiotOnTheNet on Tuesday December 01, 2020 @01:41PM (#25268291)
Care to elaborate? Because I'm not aware of any tool that could be used to combine a binary and all its .so dependencies (and all of theirs recursively) into a single statically-linked binary.
Re:Oasis: a small statically-linked Linux system by girvo on Wednesday December 02, 2020 @09:19AM (#25276511)
My admittedly poor understand of macOS application bundles, is that is basically how they work (modulo certain Frameworks in Library folders)
Re:Oasis: a small statically-linked Linux system by throwaway894345 on Tuesday December 01, 2020 @02:06PM (#25268597)
You won't have to recompile everything if you cache your build artifacts (e.g., object files); you'll only have to relink which is quite a lot better.
Re:Oasis: a small statically-linked Linux system by nmz on Tuesday December 01, 2020 @01:47PM (#25268363)
So long as I'm not the one building it, its fine. My internet can redownload everything. It also depends on what libraries are being used. musl does generate smaller binaries than glibc. and if you look at the massive project that is sqlite, building software should only take a couple of seconds. Of course, whether anyone actually goes to such lengths for easy compilation is another matter entirely.

https://sta.li/

Re:Oasis: a small statically-linked Linux system by CyberDildonics on Tuesday December 01, 2020 @03:08PM (#25269271)
Letting software have dependencies then making the user manage them in the off chance there is some bug in the foundational mostly frozen libraries should be an obviously bad decision at this point.

No other environment forces this kind of complexity on their users and almost no non-enthusiast user wants to deal with this structure.

Re:Oasis: a small statically-linked Linux system by gameswithgo on Tuesday December 01, 2020 @12:07PM (#25267094)
>Well, every time there is a bug fix in one of your dependencies you/your distribution would have to recompile everything that depends on it

Well no, I could opt not to apply the bug fix if it isn't affecting me. This again is sort of serve mentality, where of course you want to get a bug fix in as quick as possible in case it is a security issue. A desktop user, maybe you don't.

>After all, even nowadays application authors could provide static packages, but many don't do it.

Right, and really what I would like is for application authors to just static link more, more often, on linux. Or at the least ship their programs with installers that apply the needed deps if they are not already there! That the OS itself is statically linked doesn't really matter, but perhaps it would inspire an ecosystem that does this.

> I like Arch Linux best at the moment

Probably suggest arch linux to someone complaining about having to track down dependencies does not make sense, since such a person is more interested in the OS just working rather than making the OS a bit of a hobby that that they want to customize.

Which, is why I mostly use windows.

Re:Oasis: a small statically-linked Linux system by arendtio on Tuesday December 01, 2020 @12:49PM (#25267633)
> Probably suggest arch linux to someone complaining about having to track down dependencies does not make sense, since such a person is more interested in the OS just working rather than making the OS a bit of a hobby that that they want to customize.

Sure, in the beginning you have to spend some time to set it up, but due to the rolling releases it has a great longevity. And talking about application integration, I prefer the package management style (even through AUR) greatly to the chaotic download some binary and execute it way windows does it. Over time your windows always gets so messy because every device manufacturer seems to think that it is cool, to bundle his device driver with hundreds of megabytes of non-sense-ware (last weekend I installed some Logitech driver on Windows, because the default Windows driver didn't work (on Arch I didn't have to install anything extra, just saying... yes, anecdotal evidence)).

Re:Oasis: a small statically-linked Linux system by jcelerier on Tuesday December 01, 2020 @12:28PM (#25267387)
> Probably suggest arch linux to someone complaining about having to track down dependencies does not make sense, since such a person is more interested in the OS just working rather than making the OS a bit of a hobby that that they want to customize.

having used Red Hat, Mandrake, Ubuntu, Debian... Arch Linuxis by far the most "just works" distro I've used

Re:Oasis: a small statically-linked Linux system by thekyle on Tuesday December 01, 2020 @11:18PM (#25273201)
Do you really mean Arch Linux or something based on it like Manjaro? Pretty sure Arch Linux doesn't even come with an installer.
Re:Oasis: a small statically-linked Linux system by jcelerier on Wednesday December 02, 2020 @04:23AM (#25274774)
there are plenty of installers of archlinux - I use https://anarchyinstaller.org/ for instance
Re:Oasis: a small statically-linked Linux system by thekyle on Wednesday December 02, 2020 @08:05PM (#25283991)
But do any of those come with the ISO available at https://www.archlinux.org/download/? I don't see how you can say something "just works" if you have to go out of your way to choose an installer for it.
Re:Oasis: a small statically-linked Linux system by jcelerier on Thursday December 03, 2020 @02:36PM (#25293520)
ArchLinux is not defined by the ArchLinux ISO ? it will be arch as long as it installs packages from the arch repos, which is what those installer do. So you just burn this iso to an usb and be happy: https://gitlab.com/anarchyinstaller/installer/-/releases
Re:Oasis: a small statically-linked Linux system by pixl97 on Tuesday December 01, 2020 @01:07PM (#25267866)
>Which, is why I mostly use windows.

Oh, Windows can have dependency hell. And even worse is when you have a WinSXS blowout and you're trying to figure out why that subdirectory is using up 80GB of space for an unknown reason.

Re:Oasis: a small statically-linked Linux system by jbverschoor on Tuesday December 01, 2020 @05:47PM (#25271083)
DLLHell
Re:Oasis: a small statically-linked Linux system by boogies on Tuesday December 01, 2020 @01:13PM (#25267923)
> Probably suggest arch linux to someone complaining about having to track down dependencies does not make sense, since such a person is more interested in the OS just working rather than making the OS a bit of a hobby that that they want to customize.

Then recommend Manjaro, not an OS that “just” loads them down with ads, tracking, forced updates, and more unless — and to some extent still even after — they customize it.

Re:Oasis: a small statically-linked Linux system by Shared404 on Tuesday December 01, 2020 @03:11PM (#25269308)
At the risk of starting a distro war in the comments, I'll have to recommend Pop!_OS over Manjaro.

Pop has broken itself less often then Windows for me, while Manjaro has broken itself slightly more.

Re:Oasis: a small statically-linked Linux system by zarkov99 on Tuesday December 01, 2020 @01:01PM (#25267797)
> Well, every time there is a bug fix in one of your dependencies you/your distribution would have to recompile everything that depends on it. Which will use quite some resources.

This is far for more clear cut. Often some dependency bugs, might not impact my program. Even worse, sometimes by fixing a bug my program does not care about, a dependency might break my program in some subtle way. The author of the program is the best qualified person to make the upgrade/not upgrade decision.