[libvirt] [PATCH v2] tests: Adding SELINUX_LIBS to fix viridentitytest linker bug.

In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile. Even if all the SELINUX libraries and depedencies are installed. See the error message below: [...] CC viridentitytest.o CCLD viridentitytest /usr/bin/ld: viridentitytest.o: undefined reference to symbol 'security_disable' //lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [viridentitytest] Error 1 Simply adding the variable SELINUX_LIBS in viridentitytest rules of Makefile.am to include SELINUX libraries into viridentitytest solved that compilation issue. A conditional was added to consider when libvirt is using or not SELINUX. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- tests/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4c3d4ef..363c902 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -926,11 +926,13 @@ virstoragetest_LDADD = $(LDADDS) \ viridentitytest_SOURCES = \ viridentitytest.c testutils.h testutils.c -viridentitytest_LDADD = $(LDADDS) if WITH_SELINUX +viridentitytest_LDADD = $(LDADDS) $(SELINUX_LIBS) viridentitytest_DEPENDENCIES = libsecurityselinuxhelper.la \ ../src/libvirt.la -endif WITH_SELINUX +else ! WITH_SELINUX +viridentitytest_LDADD = $(LDADDS) +endif ! WITH_SELINUX viriscsitest_SOURCES = \ viriscsitest.c testutils.h testutils.c -- 1.9.1

Just rewriting the commit message. The last one was too personal in my opinion.

On 10/24/2014 06:33 AM, Julio Faracco wrote:
In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile. Even if all the SELINUX libraries and depedencies are installed. See the error message below:
[...] CC viridentitytest.o CCLD viridentitytest /usr/bin/ld: viridentitytest.o: undefined reference to symbol 'security_disable' //lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [viridentitytest] Error 1
Simply adding the variable SELINUX_LIBS in viridentitytest rules of Makefile.am to include SELINUX libraries into viridentitytest solved that compilation issue. A conditional was added to consider when libvirt is using or not SELINUX.
The conditional was overkill:
-viridentitytest_LDADD = $(LDADDS) if WITH_SELINUX +viridentitytest_LDADD = $(LDADDS) $(SELINUX_LIBS)
If you leave the first line, then this can be: viridentitytest_LDADD += $(SELINUX_LIBS)
viridentitytest_DEPENDENCIES = libsecurityselinuxhelper.la \ ../src/libvirt.la -endif WITH_SELINUX +else ! WITH_SELINUX +viridentitytest_LDADD = $(LDADDS) +endif ! WITH_SELINUX
and you don't need an else branch. ACK with that tweak, so I pushed it in your name. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Julio Faracco