Skip to contentSkip to conversation

erofs-utils: dump: fix linking when using --with-selinux

PATCH In review David Michael 2 participants 2 messages Oct 2, 2021 – Oct 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: dump: fix linking when using --with-selinux

The libselinux functions selabel_open and selabel_close are called by lib/config.c, so include libselinux in CFLAGS and LIBS to fix building dump.erofs.

---

Hi,

I tried building the dev branch with SELinux support and got this:

/bin/sh ../libtool --tag=CC --mode=link x86_64-pc-linux-gnu-gcc -Wall -Werror -I../include -O2 -pipe -Wl,-O1 -Wl,--as-needed -o dump.erofs dump_erofs-main.o ../lib/liberofs.la -luuid
libtool: link: x86_64-pc-linux-gnu-gcc -Wall -Werror -I../include -O2 -pipe -Wl,-O1 -o dump.erofs dump_erofs-main.o -Wl,--as-needed ../lib/.libs/liberofs.a -luuid /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/.libs/liberofs.a(liberofs_la-config.o): in function `erofs_exit_configure':
config.c:(.text+0xe2): undefined reference to selabel_close' /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/.libs/liberofs.a(liberofs_la-config.o): in function erofs_selabel_open':
config.c:(.text+0x180): undefined reference to `selabel_open'
collect2: error: ld returned 1 exit status

Should it just link libselinux to fix the build?

Thanks.

David

 dump/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dump/Makefile.am +1 -1
index 0bb7b4e..f0246d7 100644
@@ -6,4 +6,4 @@ bin_PROGRAMS     = dump.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 dump_erofs_SOURCES = main.c
 dump_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
-dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libuuid_LIBS}
\ No newline at end of file
+dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} ${libuuid_LIBS}
Signature · 1 line
2.31.1
#1 lore raw

Hi David,

Quoted 19 lines · David Michael

The libselinux functions selabel_open and selabel_close are called by lib/config.c, so include libselinux in CFLAGS and LIBS to fix building dump.erofs.

---

Hi,

I tried building the dev branch with SELinux support and got this:

/bin/sh ../libtool --tag=CC --mode=link x86_64-pc-linux-gnu-gcc -Wall -Werror -I../include -O2 -pipe -Wl,-O1 -Wl,--as-needed -o dump.erofs dump_erofs-main.o ../lib/liberofs.la -luuid
libtool: link: x86_64-pc-linux-gnu-gcc -Wall -Werror -I../include -O2 -pipe -Wl,-O1 -o dump.erofs dump_erofs-main.o -Wl,--as-needed ../lib/.libs/liberofs.a -luuid /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/.libs/liberofs.a(liberofs_la-config.o): in function `erofs_exit_configure':
config.c:(.text+0xe2): undefined reference to selabel_close' /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/.libs/liberofs.a(liberofs_la-config.o): in function erofs_selabel_open':
config.c:(.text+0x180): undefined reference to `selabel_open'
collect2: error: ld returned 1 exit status

Quoted 1 line

Should it just link libselinux to fix the build?

Many thanks for the patch! My nightly CI environment doesn't cover selinux build yet. It should be fixed.

Thanks,
Gao Xiang

Quoted 21 lines

Thanks.

David

 dump/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dump/Makefile.am +1 -1
index 0bb7b4e..f0246d7 100644
@@ -6,4 +6,4 @@ bin_PROGRAMS     = dump.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 dump_erofs_SOURCES = main.c
 dump_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
-dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libuuid_LIBS}
\ No newline at end of file
+dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} ${libuuid_LIBS}
Signature · 1 line
2.31.1