Skip to contentSkip to conversation

libmount/buildsys: move SELINUX_LIBS to LDFLAGS

PATCH In review Andreas Henriksson 2 participants 5 messages Aug 2, 2014 – Aug 4, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libmount/buildsys: move SELINUX_LIBS to LDFLAGS

According to a bug report filed in the Debian bug tracking system an unknown version of the package failed to cross-build because of the -lfoo flags for SELinux being placed in LIBADD rather then LDFLAGS. The build system still looks similar in this regard so it's possible the problem still remains and hopefully this change should make things more correct even if I still don't know if it solves the entire problem.

Addresses-Debian-Bug: #721431

---
 libmount/src/Makemodule.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libmount/src/Makemodule.am +2 -1
index 54ab51d..afe5cfa 100644
@@ -30,7 +30,7 @@ libmount_la_SOURCES = \
 
 nodist_libmount_la_SOURCES = libmount/src/mountP.h
 
-libmount_la_LIBADD = libcommon.la libblkid.la $(SELINUX_LIBS)
+libmount_la_LIBADD = libcommon.la libblkid.la
 
 libmount_la_CFLAGS = \
 	$(SOLIB_CFLAGS) \
@@ -46,6 +46,7 @@ libmount_la_DEPENDENCIES = \
 
 libmount_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
+	$(SELINUX_LIBS) \
 	-Wl,--version-script=$(top_srcdir)/libmount/src/libmount.sym \
 	-version-info $(LIBMOUNT_VERSION_INFO)
 
Signature · 1 line
2.0.1
#1 lore raw
Quoted 6 lines · On Sat 02 Aug 2014 22:11:01 Andreas Henriksson wrote:

According to a bug report filed in the Debian bug tracking system an unknown version of the package failed to cross-build because of the -lfoo flags for SELinux being placed in LIBADD rather then LDFLAGS. The build system still looks similar in this regard so it's possible the problem still remains and hopefully this change should make things more correct even if I still don't know if it solves the entire problem.

please post the full details here. linkage (like -lselinux) are not ldflags. -mike

#2 lore raw

Hello Mike Frysinger!

On Sun, Aug 03, 2014 at 09:34:25AM -0400, Mike Frysinger wrote:
[...]

Quoted 1 line

please post the full details here.

I have no more details then those found in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721431

Maybe YunQiang Su can help out and provide some additional information here....

Quoted 1 line

linkage (like -lselinux) are not ldflags.

Works for me, but likely I got LIBADD/LDFLAGS/LDADD wrong (again).

Regards,
Andreas Henriksson

#3 lore raw
Quoted 9 lines · On Sun 03 Aug 2014 22:23:09 Andreas Henriksson wrote:

Hello Mike Frysinger!

On Sun, Aug 03, 2014 at 09:34:25AM -0400, Mike Frysinger wrote:
[...]

Quoted 1 line

please post the full details here.

I have no more details then those found in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721431

well, that thing has barely 6 lines (and even then requires some esoteric knowledge from the reader), so you could have just pasted it here :p
------
In libmount/src/Makefile.am

libmount_la_LIBADD = $(ul_libblkid_la) $(SELINUX_LIBS)

libmount_la_DEPENDENCIES = $(libmount_la_LIBADD) libmount.sym libmount.h.in

While $(SELINUX_LIBS) is '-lselinux -lsepol'

They are not files or makefile tag, so cannot build-depends on.
------

the problem is that libmount_la_DEPENDENCIES shows up in the Makefile like:
libmount.la: ... $(libmount_la_DEPENDENCIES) ...

which means make evaluates it like so:
libmount.la: ... -lselinux -lsepol ...

which triggers the builtin library path searching of make itself:
https://www.gnu.org/software/make/manual/make.html#Libraries_002fSearch

which means it'll rewrite -lselinux into /usr/lib/libselinux.so (if it can find it) which is bad for multilib and cross-compiling.

the easy answer is to not add LIBADD to DEPENDENCIES. which has been done already -- see dbf7043ea1d090d283cfd36280bb14189d8e35b1.

Quoted 3 lines
Quoted 1 line

linkage (like -lselinux) are not ldflags.

Works for me, but likely I got LIBADD/LDFLAGS/LDADD wrong (again).

it often works in the common case, but the edges break down. we know putting -lflags into LDFLAGS is such a scenario :).
-mike

#4 lore raw

Version: 2.25-1

Hello Mike!

Thank you very much for the followup and for identifying the relevant commit for me!
(BCCing the debian bug tracking system to close the bug report...)

On Mon, Aug 04, 2014 at 03:40:56AM -0400, Mike Frysinger wrote:
[...]

Quoted 6 lines

the problem is that libmount_la_DEPENDENCIES shows up in the Makefile like:
libmount.la: ... $(libmount_la_DEPENDENCIES) ...

which means make evaluates it like so:
libmount.la: ... -lselinux -lsepol ...

Quoted 9 lines

which triggers the builtin library path searching of make itself:
https://www.gnu.org/software/make/manual/make.html#Libraries_002fSearch

which means it'll rewrite -lselinux into /usr/lib/libselinux.so (if it can find it) which is bad for multilib and cross-compiling.

the easy answer is to not add LIBADD to DEPENDENCIES. which has been done already -- see dbf7043ea1d090d283cfd36280bb14189d8e35b1.

[...]

Regards,
Andreas Henriksson