The Samba-Bugzilla – Bug 10672
Build fails trying to link to >=systemd-209 libraries
Last modified: 2016-02-12 00:08:44 UTC
Samba tries to directly link libsystemd-dameon.so, but that doesn't exist any more as of systemd-209. The library that should be linked is libsystemd.so, see:
You probably need to detect the library name to support both versions.
Unable to attach log, here is the relevant output:
11:26:26 runner x86_64-pc-linux-gnu-gcc default/nsswitch/libwbclient/wbc_guid_1.o default/nsswitch/libwbclient/wbc_idmap_1.o default/nsswitch/libwbclient/wbclient_1.o default/nsswitch/libwbclient/wbc_pam_1.o default/nsswitch/libwbclient/wbc_pwd_1.o default/nsswitch/libwbclient/wbc_sid_1.o default/nsswitch/libwbclient/wbc_util_1.o -o /var/tmp/portage/net-fs/samba-4.1.8/work/samba-4.1.8/bin/default/nsswitch/libwbclient/libwbclient.so -march=native -O2 -pipe -Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -fstack-protector -Wl,-no-undefined -Wl,--export-dynamic -lpthread -shared -Wl,--version-script=/var/tmp/portage/net-fs/samba-4.1.8/work/samba-4.1.8/bin/default/nsswitch/libwbclient/wbclient.vscript -Wl,-h,libwbclient.so.0 -Ldefault/lib/replace -Ldefault/nsswitch -L/usr/local/lib -Wl,-Bdynamic -lwinbind-client -lreplace -lattr -lnsl -ldl -lcrypt -lrt
default/lib/util/become_daemon_1.o: In function `become_daemon':
become_daemon.c:(.text+0x200): undefined reference to `sd_notifyf'
default/lib/util/become_daemon_1.o: In function `exit_daemon':
become_daemon.c:(.text+0x231): undefined reference to `sd_notifyf'
default/lib/util/become_daemon_1.o: In function `daemon_ready':
become_daemon.c:(.text+0x2b1): undefined reference to `sd_notifyf'
collect2: error: ld returned 1 exit status
Alexander, any idea how to solve this nicely?
Created attachment 10053 [details]
Attached is a patch for master. I haven't tried it as I don't have systemd-209 yet but this is what should help.
The patch does allow Samba to compile on my system.
I spoke too soon, it does not enable systemd:
Checking for libsystemd-daemon: yes
Checking for header systemd/sd-daemon.h: yes
Checking for library systemd-daemon: no
Let me know if you want any more info.
Ok, I need to see build logs. Please attach a file named bin/config.log (you can compress it as it is ~15Mb large).
also, can you post your pkg-config systemd*.pc files? On my distribution the systemd-*.pc pkg-config files have been patched to add the required new linker flags.
Created attachment 10058 [details]
FYI, I was trying to patch 4.1.8. I had to modify it a bit to apply the patch here is that section to check to make sure I didn't mess it up.
if Options.options.enable_systemd != False:
r = conf.check_cfg(package='libsystemd-daemon', args='--cflags --libs',
msg='Checking for libsystemd-daemon', uselib_store="SYSTEMD-DAEMON")
if not r:
conf.check_cfg(package='libsystemd', args='--cflags --libs',
msg='Checking for libsystemd', uselib_store="SYSTEMD-DAEMON")
if (conf.CONFIG_SET('HAVE_SYSTEMD_SD_DAEMON_H') and
conf.env['ENABLE_SYSTEMD'] = True
Created attachment 10059 [details]
Ok, looking at your config.log, I can see that the way systemd team did transition is by keeping the same pkg-config package name (libsystemd-daemon) but providing a different library underneath. This is a sensible approach.
So, can you try this patch instead? It only adds a check for additional library, libsystemd. This library does not exist in case of systemd < 2.0.9 but for that case we have libsystemd-daemon. Both of them would be covered by the same pkg-config package, called libsystemd-daemon.
Created attachment 10074 [details]
Created attachment 10075 [details]
Fix systemd build
This seems to fix the build, probably not not the correct fix, but hopefully it helps point you guys in the right direction.
(In reply to Alexander Bokovoy from comment #9)
> Ok, looking at your config.log, I can see that the way systemd team did transition is by keeping the same pkg-config package name (libsystemd-daemon) but providing a different library underneath. This is a sensible approach.
That's not accurate. The systemd build system does NOT install libsystemd-deamon.pc by default. On Gentoo Linux, we install it as a hack to avoid breaking lots of packages that look for it.
To be compatible with systemd as shipped by default, you would need to check for libsystemd.pc and libsystemd-daemon.pc as a fall back.
The currently attached patches can't work properly because of how samba build system works.
Long story short:
219 conf.check_cfg(package='libsystemd-daemon', args='--cflags --libs',
220 msg='Checking for libsystemd-daemon', uselib_store="SYSTEMD-DAEMON")
This gets --libs from pkg-config and puts them in LIBS_SYSTEMD-DAEMON.
221 conf.CHECK_HEADERS('systemd/sd-daemon.h', lib='systemd-daemon')
222 conf.CHECK_LIB('systemd-daemon', shlib=True)
And this checks for '-lsystemd-daemon' (ignoring --libs above). If it is found, it is written to LIBS_SYSTEMD-DAEMON, therefore overwriting the result of pkg-config. If it is not, 'systemd-daemon' becomes EMPTY target, effectively making the pkg-config result irrelevant.
Created attachment 10571 [details]
Patch for git HEAD, supporting both new and old names
This patch specifically:
1. checks both for libsystemd and libsystemd-daemon via pkg-config,
2. checks both for -lsystemd and -lsystemd-daemon using lib checks,
3. enables systemd support if either of the two is found, and names both as deps of the util library.
So on systems having libsystemd, the first check will succeed and the other target will be EMPTY. On systems having libsystemd-daemon, the second check will succeed and 'systemd' will be EMPTY.
Created attachment 10572 [details]
The patch modified for v4-1-test branch
Michał's patch is confirmed working for me. I also notice that Gentoo picked up this patch.
(In reply to Michał Górny from comment #15)
Can you please provide a tested patch against Samba git master?
That way we can get this into 4.4.
Looks like this is fixed as of 5ee27b4ead57c15db7168d80f6fdf821663c44fc at Wed Apr 8 15:06:26 CEST 2015
*** This bug has been marked as a duplicate of bug 11200 ***