systemd: use pkg-config to determine systemd library availability
PATCH 1/1 systemd: use pkg-config to determine systemd library availability
AC_CHECK_LIB fails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. Use PKG_CHECK_MODULES instead.
Tested on Debian Jessie and Arch Linux.
Please rerun autogen.sh after applying this patch.
--- m4/systemd.m4 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
m4/systemd.m4 +2 -10
@@ -42,13 +42,6 @@ AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [ ]) AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ - AC_CHECK_HEADER([systemd/sd-daemon.h], [ - AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [libsystemddaemon="y"]) - ]) - AS_IF([test "x$libsystemddaemon" = x], [ - AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library]) - ]) - PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon]) dnl pkg-config older than 0.24 does not set these for dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
@@ -98,9 +91,8 @@ AC_DEFUN([AX_CHECK_SYSTEMD], [ ]) AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [ - AC_CHECK_HEADER([systemd/sd-daemon.h], [ - AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [systemd="y"]) - ]) + PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon], [systemd="y"], + [systemd="n"]) ]) dnl Enables systemd by default and requires a --disable-systemd option flag
Signature · 1 line
2.1.3
Quoted 8 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
Please rerun
autogen.shafter applying this patch.
Quoted 7 lines
Reported-by Mark Pryor <[email protected]>Signed-off-by Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Anthony Perard <[email protected]>Cc Luis R. Rodriguez <[email protected]>Cc Mark Pryor <[email protected]>
I think you should make reference in the commit log to the fact that the library has change name upstream but that a compatibility pkg-config is provided for the old name.
It'd be nice if there was a less repetitive way to handle defaults + overriding in the autoconf stuff, but for a freeze exception this is the way to go.
Ian.
Quoted 5 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
And Fedora and SuSE? CC-ing the other distro maintainers for their input.
Quoted 47 lines
Please rerun
autogen.shafter applying this patch.Reported-by Mark Pryor <[email protected]>Signed-off-by Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Anthony Perard <[email protected]>Cc Luis R. Rodriguez <[email protected]>Cc Mark Pryor <[email protected]>--- m4/systemd.m4 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)m4/systemd.m4 +2
-10@@ -42,13 +42,6 @@ AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [ ]) AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ - AC_CHECK_HEADER([systemd/sd-daemon.h], [ - AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [libsystemddaemon="y"]) - ]) - AS_IF([test "x$libsystemddaemon" = x], [ - AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library]) - ]) - PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon]) dnl pkg-config older than 0.24 does not set these for dnl PKG_CHECK_MODULES() worth also noting is that as of version 208@@ -98,9 +91,8 @@ AC_DEFUN([AX_CHECK_SYSTEMD], [ ]) AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [ - AC_CHECK_HEADER([systemd/sd-daemon.h], [ - AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [systemd="y"]) - ]) + PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon], [systemd="y"], + [systemd="n"]) ]) dnl Enables systemd by default and requires a --disable-systemd option flagSignature · 1 line
2.1.3
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
And Fedora and SuSE? CC-ing the other distro maintainers for their input.
I'm fine with that. But:
It seems be that sd_listen_fds() is new in v209. It was backported to v208 in openSUSE 13.1. So there should be some detection if sd_listen_fds() is really available. Looks like this patch removes the check.
I get this from pkg-config:
root@optiplex:/work/olaf/13.1/github/olafhering/xen.git # pkg-config --cflags libsystemd-daemon ; echo $?
0
root@optiplex:/work/olaf/13.1/github/olafhering/xen.git # pkg-config --libs libsystemd-daemon ; echo $? -lsystemd-daemon
0
Olaf
Quoted 12 lines · Olaf Hering
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
And Fedora and SuSE? CC-ing the other distro maintainers for their input.
Quoted 6 lines
I'm fine with that. But:
It seems be that
sd_listen_fds()is new in v209. It was backported to v208 in openSUSE 13.1. So there should be some detection ifsd_listen_fds()is really available. Looks like this patch removes the check.
Ah I didn't know about the sd_listen_fds thing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.
Ian.
Quoted 11 lines
I get this from pkg-config:
root@optiplex:/work/olaf/13.1/github/olafhering/xen.git # pkg-config --cflags libsystemd-daemon ; echo $?
0
root@optiplex:/work/olaf/13.1/github/olafhering/xen.git # pkg-config --libs libsystemd-daemon ; echo $? -lsystemd-daemon
0Olaf
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.
Correction: sd_listen_fds is available since at least v1.
git describe --contains abbbea81a8fa70badb7a05e518d6b07c360fc09d v1~390
Olaf
Quoted 11 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.Correction:
sd_listen_fdsis available since at least v1.
git describe --containsabbbea81a8fa70badb7a05e518d6b07c360fc09dv1~390
In that case I don't think we realistically need to check for it?
Ian.
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.
Quoted 5 lines
Quoted 3 lines
Correction:
sd_listen_fdsis available since at least v1.
git describe --containsabbbea81a8fa70badb7a05e518d6b07c360fc09dv1~390In that case I don't think we realistically need to check for it?
Yes. Anything before 208 is stale. At least I dont have anything older around for testing.
Olaf
Quoted 11 lines · Olaf Hering
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Correction:
sd_listen_fdsis available since at least v1.
git describe --containsabbbea81a8fa70badb7a05e518d6b07c360fc09dv1~390In that case I don't think we realistically need to check for it?
Yes. Anything before 208 is stale. At least I dont have anything older around for testing.
And for Fedora it is Fedora 21 or later. F20 has 208 so we are OK there.
Quoted 2 lines
Olaf
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 15 lines · Olaf Hering
Quoted 13 lines · Ian Campbell
Quoted 11 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.Correction:
sd_listen_fdsis available since at least v1.
git describe --containsabbbea81a8fa70badb7a05e518d6b07c360fc09dv1~390
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
In that case I don't think we realistically need to check for it?
Yes. Anything before 208 is stale. At least I dont have anything older around for testing.
And for Fedora it is Fedora 21 or later. F20 has 208 so we are OK there.
Fedora 21 is going through its final release candidates now so it will stick to Xen 4.4 . The first Fedora release that might use this code (if I decide to use it - at the moment I have reservations) would be Fedora 22.
Michael Young
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Ah I didn't know about the
sd_listen_fdsthing, so I think that what we need then is to use pkg-config first to determine if systemd-daemon is present at all, and then check for specific symbols we require using the pkg-config supplied CFLAGS and LDFLAGS rather than assuming -lsystemd-daemon.
Quoted 5 lines
Quoted 3 lines
Correction:
sd_listen_fdsis available since at least v1.
git describe --containsabbbea81a8fa70badb7a05e518d6b07c360fc09dv1~390In that case I don't think we realistically need to check for it?
The implication here being that Wei's original patch is correct. Konrad, do you think this is OK for the release?
Quoted 9 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
I just tested this and got this failure. The reason is that the LDFLAGS come before the objects. If I move LDFLAGS after $^ linking works. Will send a patch to fix the failure.
Olaf
make[3]: Entering directory '/work/olaf/factory/github/olafhering/xen.git/tools/xenstore'
gcc -Wl,-rpath,/opt/xen/upstream/staging-honor_prefix/lib64 -lsystemd xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o xenstored_posix.o /work/olaf/factory/github/olafhering/xen.git/tools/xenstore/../../tools/libxc/libxenctrl.so -o xenstored
xenstored_core.o: In function `xs_validate_active_socket':
xenstored_core.c:(.text.unlikely+0x38): undefined reference to sd_notifyf' xenstored_core.c:(.text.unlikely+0x59): undefined reference to sd_is_socket_unix' xenstored_core.c:(.text.unlikely+0x77): undefined reference to sd_is_socket_unix' xenstored_core.o: In function main':
xenstored_core.c:(.text.startup+0x1df): undefined reference to sd_booted' xenstored_core.c:(.text.startup+0x23c): undefined reference to sd_booted' xenstored_core.c:(.text.startup+0x25b): undefined reference to sd_listen_fds' xenstored_core.c:(.text.startup+0x563): undefined reference to sd_booted' xenstored_core.c:(.text.startup+0x8f9): undefined reference to sd_notifyf' xenstored_core.c:(.text.startup+0x958): undefined reference to sd_notifyf' xenstored_core.c:(.text.startup+0xb0d): undefined reference to `sd_notify'
collect2: error: ld returned 1 exit status
Makefile:80: recipe for target 'xenstored' failed
make[3]: *** [xenstored] Error 1
Quoted 11 lines · Olaf Hering
Quoted 5 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.Tested on Debian Jessie and Arch Linux.
I just tested this and got this failure. The reason is that the LDFLAGS come before the objects. If I move LDFLAGS after $^ linking works. Will send a patch to fix the failure.
Was this a new failure with this change? AFAICT LDFLAGS is still set (via SYSTEMD_LIBS) in the same place relative to non-systemd stuff.
FWIW the reason I don't see this in my pre-commit test is that I don't have the systemd headers installed.
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Olaf Hering
Quoted 4 lines · Wei Liu
AC_CHECK_LIBfails on Debian Jessie since the ld flag it generates is incorrect, even in the event systemd library is available. UsePKG_CHECK_MODULESinstead.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Tested on Debian Jessie and Arch Linux.
I just tested this and got this failure. The reason is that the LDFLAGS come before the objects. If I move LDFLAGS after $^ linking works. Will send a patch to fix the failure.
Was this a new failure with this change? AFAICT LDFLAGS is still set (via
SYSTEMD_LIBS) in the same place relative to non-systemd stuff.
No, happens even without it. I just realized that I missed a git rebase. My own packages do not have systemd-devel yet, so I did not spot this earlier. Maybe it just happens with the latest toolchain in Factory. Last time it worked well in 13.1 at least, SLE12 was ok as well.
Olaf