Skip to content

Commit

Permalink
build: put libraries in LDADD, not LDFLAGS
Browse files Browse the repository at this point in the history
Automake linking looks like this (I'm simplifying a bit):

    $(CC) $(foo_CFLAGS) $(foo_LDFLAGS) -ofoo $(objects) $(foo_LDADD)

The correct order is that if a library A is used to satisfy the symbol
requirements of an object or library B, then A must come after B on the
link line. Otherwise, static linking or linking with -Wl,--as-needed
will fail. As a result, libraries and the -L options used to locate them
should always be in LDADD (for executables) or LIBADD (for libraries),
never in LDFLAGS.

Ubuntu's linker defaults to the equivalent of -Wl,--as-needed, so
this causes failure to build on Ubuntu, which can be reproduced with

    ./autogen.sh CC="gcc -Wl,--as-needed" && make

on other distributions.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #75
Approved by: alexlarsson
  • Loading branch information
smcv authored and rh-atomic-bot committed Jun 9, 2016
1 parent 6ad6c24 commit f6ca369
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile-bwrap.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ bwrap_SOURCES = \
$(NULL)

bwrap_CFLAGS = $(AM_CFLAGS)
bwrap_LDFLAGS = $(SELINUX_LIBS)
bwrap_LDADD = $(SELINUX_LIBS)

0 comments on commit f6ca369

Please sign in to comment.