-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd: build libudev.so "separately" #97051
Conversation
…xOS#96197" This reverts commit f6286de.
This reverts commit e02793d.
So far this is just a quick proof of concept, and in fact |
Note to self: libudev.so build is more tied to systemd than I expected (did I glimpse that it links statically against libsystemd?), so an approach like this might be more maintainable than really trying it to separate from our systemd expression. Of course, without too much work we could additionally reduce the build-time closure (partially) and build time (try instructing |
I think it would be easier to build libudev/libsystemd with ninja and than re-use those libraries when building systemd (replacing it with a symlink in postInstall?). Here is an example where I do it for |
I do plan that, but so far there are problems with something else apparently. |
We'd have to split systemd and libsystemd first before we can do the systemd and udev split.. |
Can you explain why? |
Libudev seems to not depend on libsystemd. |
But having a separate |
To be clear, it does not depend on dynamic libsystemd. I'm not sure why they link stuff this way ATM: https://github.com/systemd/systemd/blob/v246/src/udev/meson.build#L145 |
Yes, this attempted to separate just the library. |
Ignore my ramblings. I thought it was because of udev linking to libsystemd dynamically. For an initial effort; I wouldn't do too much fancy things; and just keep libudev statically linked to If we're building just the |
Roughly 100x smaller. EDIT: and as written now even libudev isn't twice in there, I think. |
But the cycle will be back If you set pkgs.udev to the libudev package. Which I assume is what we eventually want. However having two udevs (one with and one without cryptsetup) still is a lot better than 2 systemds... |
It seems that libudev was built with a static libsystemd before anyway so this is not big regression size wise. And I still think it should be possible to bring back this libudev in the systemd package by putting a symlink in the package from "$lib/lib/libudev.*" to libudev. Or is the issue that cryptsetup depends on libudev and the other way around? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd feel more comfortable if udev would be its own derivation, in a separate file (and not just an override), only building the udev-related targets (and we pass that into the systemd expression).
Both could use the same src
and patches
, though.
[ linuxHeaders libcap curl.dev kmod xz pam acl | ||
libuuid glib libgcrypt libgpgerror libidn2 | ||
pcre2 ] ++ | ||
stdenv.lib.optional withKexectools kexectools ++ | ||
stdenv.lib.optional withLibseccomp libseccomp ++ | ||
[ libffi audit lz4 bzip2 libapparmor | ||
iptables gnu-efi | ||
] ++ stdenv.lib.optional withSelinux libselinux; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these probably are not dependencies of just libudev, are they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was planning to do such reductions after the change actually works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Now it appears to work fine.)
I tried to start with empty mkDerivation
instead of overriding the systemd one, but I couldn't come with anything simple. Just making the meson configure pass isn't easy – it requires lots of stuff that's useless for libudev but I see no easy way of turning these off (*Inputs
, mesonFlags
, etc.) – honestly it feels that maintainability will be easiest when those two derivations only have minimal differences (full systemd and libudev).
While doing so, we should also remove the |
I suspect that splitting a |
We apparently didn't fit anymore. I don't think this test is meant to (also) check closure size.
@vcunat libudev is in I'm talking about the
in We currently use Instead of moving this to Of course we'd need to verify packages still build after that change (as things like lvm2 also want to see the In the longer run, having packages who only really need udev to declare I don't think resurrecting @andersk I don't really understand your comment. Why couldn't we (re-)symlink On the other side, why do we need to provide |
This PR provides The |
We /can't/ use aliases.nix, as it'd fail Creating a Given the dependency cycle has been resolved for now with #97008, and we don't need to rush this, can we give this some more research? I could envision |
I could see that... but as the derivations are written so far, to get |
Yeah, as written here, the |
For 20.09 I think it would be preferable to have some improvement in about one week. (than the current solution with two systemds in most closures) |
It's a 28MB closure size increase, yes. But it's probably fine to ship 20.09 even with that. Splitting udev and systemd is something that probably takes more time than we have to properly fix it before the 20.09 release, and I don't think the current proposed approach improves matters from a maintainability factor. IMHO, we should just go with the closure size increase for now, work on a proper fix in unstable, and if the fix is not too invasive, it can probably be backported (but I think it does require quite some changes in many packages). |
Perhaps you are reading the opposite of what I wrote? I said exactly that we can make such a symlink because the two This
The (Sorry if the emphasis and repetition comes across as patronizing…there are certainly things I could be wrong about here, but I want to make sure we’re communicating correctly so we can figure out where that might be.) |
@andersk right - splitting systemd-udevd from systemd won't probably work, and not sure how So after a second thought, calling this other derivation |
As I wrote above, it would be nice for it to be "independent" derivation, but I can't see how to do that. The configure phase isn't easy to satisfy, nor easy to cut down to just libudev. Or at least I didn't find such a way; maybe someone else will have an idea how to approach it. |
🤔 this PR actually seems very close to the currently merged workaround, only with the binaries "deduplicated" (i.e. anything but libudev deleted from the first result, and libudev replaced in the second result). |
Not only does nixos not have a split systemd.lib package, it also gets two copies of systemd in the image: NixOS/nixpkgs#97051 NixOS/nixpkgs#98094 Let's not include it for now, the only detraction is that the systemd/journald logger wont be available in uwsgi.
Not only does nixos not have a split systemd.lib package, it also gets two copies of systemd in the image: NixOS/nixpkgs#97051 NixOS/nixpkgs#98094 Let's not include it for now, the only detraction is that the systemd/journald logger wont be available in uwsgi. On the good side, the image went from 50MB to 30MB now.
Not only does nixos not have a split systemd.lib package, it also gets two copies of systemd in the image: NixOS/nixpkgs#97051 NixOS/nixpkgs#98094 Let's not include it for now, the only detraction is that the systemd/journald logger wont be available in uwsgi. On the good side, the image went from 50MB to 30MB now. The image is built against the `my-20.09` branch of nixpkgs, that is based on the release-20.09 branch with uwsgi fixes added.
The Arch package has a relatively simple approach to this, in its split package for systemd/systemd-libs. It boils down to these two lines, that copy the libraries that are then shipped in systemd-libs package: |
Well, yes... other distros don't have this strict automatic detection of references (cycle between systemd and some of its libs) and they can keep all output in the shared |
@flokli |
I marked this as stale due to inactivity. → More info |
I think the |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)