On Sat, 31 Aug 2019 at 00:31:12 +0200, Michael Biebl wrote: > Simon, have you tried building systemd with -Dstatic-libsystemd=true > -Dstatic-libudev=true ? Does this produce something useful?
I haven't tried it. > Upstream doesn't seem to be too keen on supporting static builds, so if > we divert here downstream, I'd be interested if there is actual demand > from users of such a libsystemd.a or if this all mostly hyphothetical. This is hypothetical, and if you want to say "no" and mark this as wontfix or close it, that's fine; but I wanted to ask the question rather than making an assumption about the likely answer. The context is that I have been trying to write autopkgtests for -dev packages, on the basis that if we have a feature, we should prove that it works; and I've found that when a library in the dependency stack is shared-only (for example libdbus depends on libsystemd), it is not at all obvious how to link statically to the depending library (libdbus). The obvious rune cc -Wl,--no-as-needed -static -otest test.c `pkg-config --static --cflags --libs dbus-1` fails, because there is no libsystemd.a to link. (I'm using -Wl,--no-as-needed because the test.c that I'm currently playing with doesn't actually call into libdbus, and I don't want to invalidate the test results by having the linker decide not to link libdbus or libsystemd after all; in real autopkgtests I try to call at least a harmless function like dbus_get_version().) It is still possible to link libsystemd and libc dynamically, but libdbus statically, with something like cc -Wl,--no-as-needed -otest test.c `pkg-config --static --cflags --libs dbus-1 | perl -pe 's,(^|\s)-ldbus-1(\s|$), /usr/lib/x86_64-linux-gnu/libdbus-1\.a ,'` but that requires you to know the physical location of the library, and once you have to rely on *anything* with shared linkage, you might as well bundle *everything* with shared linkage (and -Wl,-rpath,'$ORIGIN' or similar), at which point you've gained nothing from static libraries. That would point towards a conclusion that if a library like libdbus has shared-only dependencies like libsystemd, then libdbus should also become shared-only, which would reduce the size of the binary archive and the time taken to compile, but would harm the possibly-hypothetical use cases that are the reason Policy tells us to build static libraries? Another possible direction would be to disable static libraries in general, except in cases where a bug report indicates that a real user genuinely wants them (and has a recipe for testing that they work). smcv