Compile-fix with --as-needed. To ensure correct output when --as-needed are in the linker flags, the order of flags to the linker (directly or via the compiler) must explictly only include libraries and objects AFTER all compiler flags, linker flags and linker directory arguments. X-Gentoo-Bug: #217644 Signed-off-by: Robin H. Johnson Signed-off-by: Christian Ruppert (idl0r) diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/daemons/clogd/Makefile LVM2.2.02.48/daemons/clogd/Makefile --- LVM2.2.02.48.orig/daemons/clogd/Makefile 2009-01-08 09:12:33.000000000 -0800 +++ LVM2.2.02.48/daemons/clogd/Makefile 2009-07-05 14:33:03.799446085 -0700 @@ -45,12 +45,12 @@ LDFLAGS += $(shell if [ -e /usr/lib64/op else \ echo '-L/usr/lib/openais -L/usr/lib'; \ fi) -LDFLAGS += -lcpg -lSaCkpt -lext2fs +LIBS += -lcpg -lSaCkpt -lext2fs all: ${TARGET} clogd: ${SOURCES} - ${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS} + ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^ no_clogd_kernel_headers: echo "Unable to find clogd kernel headers" diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/daemons/clvmd/Makefile.in LVM2.2.02.48/daemons/clvmd/Makefile.in --- LVM2.2.02.48.orig/daemons/clvmd/Makefile.in 2009-03-10 05:10:12.000000000 -0700 +++ LVM2.2.02.48/daemons/clvmd/Makefile.in 2009-07-05 14:41:22.633723993 -0700 @@ -101,7 +101,7 @@ INSTALL_TARGETS = \ install_clvmd clvmd: $(OBJECTS) $(top_srcdir)/lib/liblvm-internal.a - $(CC) -o clvmd $(OBJECTS) $(CFLAGS) $(LDFLAGS) \ + $(CC) $(CFLAGS) $(LDFLAGS) -o clvmd $(OBJECTS) \ $(LVMLIBS) $(LMLIBS) $(LIBS) .PHONY: install_clvmd diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/daemons/dmeventd/Makefile.in LVM2.2.02.48/daemons/dmeventd/Makefile.in --- LVM2.2.02.48.orig/daemons/dmeventd/Makefile.in 2009-07-05 14:32:41.000000000 -0700 +++ LVM2.2.02.48/daemons/dmeventd/Makefile.in 2009-07-05 14:40:43.094941107 -0700 @@ -41,12 +41,12 @@ include $(top_srcdir)/make.tmpl all: dmeventd device-mapper: dmeventd $(LIB_STATIC) -LDFLAGS += -ldl -ldevmapper -lpthread -CLDFLAGS += -ldl -ldevmapper -lpthread +LIBS += -ldl -ldevmapper -lpthread dmeventd: $(LIB_SHARED) $(LIB_STATIC) $(VERSIONED_SHLIB) dmeventd.o - $(CC) -o $@ dmeventd.o $(CFLAGS) $(LDFLAGS) \ - -L. -ldevmapper-event $(LIBS) -rdynamic + $(CC) $(CFLAGS) $(LDFLAGS) -L. \ + -o $@ dmeventd.o \ + -ldevmapper-event $(LIBS) -rdynamic .PHONY: install_dynamic install_static install_include \ install_pkgconfig install_dmeventd diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/daemons/dmeventd/plugins/mirror/Makefile.in LVM2.2.02.48/daemons/dmeventd/plugins/mirror/Makefile.in --- LVM2.2.02.48.orig/daemons/dmeventd/plugins/mirror/Makefile.in 2009-05-11 03:28:46.000000000 -0700 +++ LVM2.2.02.48/daemons/dmeventd/plugins/mirror/Makefile.in 2009-07-05 14:33:03.801620744 -0700 @@ -17,7 +17,8 @@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ INCLUDES += -I${top_srcdir}/tools -CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@ +CLDFLAGS += -L${top_srcdir}/tools +LIBS += -ldevmapper -lpthread @LVM2CMD_LIB@ SOURCES = dmeventd_mirror.c diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/daemons/dmeventd/plugins/snapshot/Makefile.in LVM2.2.02.48/daemons/dmeventd/plugins/snapshot/Makefile.in --- LVM2.2.02.48.orig/daemons/dmeventd/plugins/snapshot/Makefile.in 2009-05-11 03:28:46.000000000 -0700 +++ LVM2.2.02.48/daemons/dmeventd/plugins/snapshot/Makefile.in 2009-07-05 14:33:03.801620744 -0700 @@ -17,7 +17,8 @@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ INCLUDES += -I${top_srcdir}/tools -CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@ +CLDFLAGS += -L${top_srcdir}/tools +LIBS += -lpthread -ldevmapper @LVM2CMD_LIB@ SOURCES = dmeventd_snapshot.c diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/lib/Makefile.in LVM2.2.02.48/lib/Makefile.in --- LVM2.2.02.48.orig/lib/Makefile.in 2009-07-17 11:16:40.572301218 +0200 +++ LVM2.2.02.48/lib/Makefile.in 2009-07-17 11:17:55.035551029 +0200 @@ -137,7 +137,8 @@ ifeq ("@HAVE_LIBDL@", "yes") endif ifeq ("@DMEVENTD@", "yes") - CLDFLAGS += -ldevmapper-event + CLDFLAGS += -L../daemons/dmeventd + LIBS += -ldevmapper-event endif LIB_NAME = liblvm-internal diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/make.tmpl.in LVM2.2.02.48/make.tmpl.in --- LVM2.2.02.48.orig/make.tmpl.in 2009-05-11 03:28:45.000000000 -0700 +++ LVM2.2.02.48/make.tmpl.in 2009-07-05 14:33:03.801620744 -0700 @@ -28,7 +28,7 @@ GENHTML = @GENHTML@ LN_S = @LN_S@ SED = @SED@ -LIBS = @LIBS@ +LIBS += @LIBS@ $(LVMLIBS) $(LMLIBS) DEFS += @DEFS@ CFLAGS += @CFLAGS@ CLDFLAGS += @CLDFLAGS@ @@ -203,19 +203,19 @@ $(TARGETS): $(OBJECTS) ifeq ("@LIB_SUFFIX@","so") $(LIB_SHARED): $(OBJECTS) $(LDDEPS) $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \ - $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ + $(CFLAGS) $(CLDFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ endif ifeq ("@LIB_SUFFIX@","dylib") $(LIB_SHARED): $(OBJECTS) $(LDDEPS) $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \ - $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ + $(CFLAGS) $(CLDFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ endif %.so: %.a $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \ - $(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \ - @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@ + $(CFLAGS) $(CLDFLAGS) $(LDFLAGS) -o $@ \ + @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@ $(LIBS) $(LIB_STATIC): $(OBJECTS) $(RM) $@ diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/test/api/Makefile.in LVM2.2.02.48/test/api/Makefile.in --- LVM2.2.02.48.orig/test/api/Makefile.in 2009-05-22 07:45:00.000000000 -0700 +++ LVM2.2.02.48/test/api/Makefile.in 2009-07-05 14:39:19.353146953 -0700 @@ -36,5 +36,5 @@ LDFLAGS = -L$(top_srcdir)/libdm -L$(top_ CLDFLAGS = -L$(top_srcdir)/libdm -L$(top_srcdir)/liblvm test: $(OBJECTS) $(top_srcdir)/liblvm/liblvm2app.so $(top_srcdir)/libdm/libdevmapper.so - $(CC) -o test $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o test $(OBJECTS) $(LVMLIBS) $(LIBS) diff -Nuarp --exclude '*.rej' --exclude '*.orig' LVM2.2.02.48.orig/tools/Makefile.in LVM2.2.02.48/tools/Makefile.in --- LVM2.2.02.48.orig/tools/Makefile.in 2009-07-17 11:16:40.579301663 +0200 +++ LVM2.2.02.48/tools/Makefile.in 2009-07-21 19:27:05.526972872 +0200 @@ -106,24 +106,29 @@ include $(top_srcdir)/make.tmpl device-mapper: $(TARGETS_DM) dmsetup: dmsetup.o $(top_srcdir)/libdm/libdevmapper.$(LIB_SUFFIX) - $(CC) -o $@ dmsetup.o $(CFLAGS) $(LDFLAGS) \ - -L$(top_srcdir)/libdm -ldevmapper $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) \ + -L$(top_srcdir)/libdm \ + -o $@ dmsetup.o \ + -ldevmapper $(LIB_PTHREAD) dmsetup.static: dmsetup.o $(interfacedir)/libdevmapper.a - $(CC) -o $@ dmsetup.o $(CFLAGS) $(LDFLAGS) -static \ - -L$(interfacedir) -ldevmapper $(LIBS) \ - $(LIB_PTHREAD) + $(CC) $(CFLAGS) $(LDFLAGS) -static \ + -L$(interfacedir) \ + -o $@ dmsetup.o \ + -ldevmapper $(LIB_PTHREAD) all: device-mapper lvm: $(OBJECTS) lvm.o $(top_srcdir)/lib/liblvm-internal.a - $(CC) -o $@ $(CFLAGS) $(OBJECTS) lvm.o \ - $(LDFLAGS) $(LVMLIBS) $(LIBS) -rdynamic + $(CC) $(CFLAGS) $(LDFLAGS) \ + -o $@ $(OBJECTS) lvm.o \ + $(LVMLIBS) $(LIBS) -rdynamic LIB_PTHREAD = @LIB_PTHREAD@ lvm.static: $(OBJECTS) lvm-static.o $(top_srcdir)/lib/liblvm-internal.a $(interfacedir)/libdevmapper.a - $(CC) -o $@ $(CFLAGS) $(OBJECTS) lvm-static.o -static \ - -L$(interfacedir) $(LDFLAGS) $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) -rdynamic + $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacedir) \ + -o $@ $(OBJECTS) lvm-static.o \ + $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) -rdynamic liblvm2cmd.a: $(top_srcdir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o cat $(top_srcdir)/lib/liblvm-internal.a > $@