WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] tools: do not link against unused librari

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools: do not link against unused libraries.
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sun, 20 Mar 2011 06:40:27 +0000
Delivery-date: Sat, 19 Mar 2011 23:44:18 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1300390685 0
# Node ID 265106fce6530e242ab83f11676434f54f3e8091
# Parent  1c1ecbcf4100b02a058b51488c71265f6d394a03
tools: do not link against unused libraries.

A fair few things under tools link against libraries which they don't
even use.

Most of this appears to come from copy-and-pasting previous Makefile
snippets and cargo-culting plus the tendency to define global $(LIBS)
even for Makefiles which build multiple separate utilities or
libraries.

Identified by comparing a build with --as-needed to one without by
looking at the NEEDED header of all ELF objects.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r 1c1ecbcf4100 -r 265106fce653 tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile    Thu Mar 17 19:15:42 2011 +0000
+++ b/tools/blktap2/drivers/Makefile    Thu Mar 17 19:38:05 2011 +0000
@@ -23,11 +23,7 @@
 CFLAGS            += -fPIC
 endif
 
-LIBS      += -lrt -lz
-
-LBLIBS_img := $(LDLIBS_libxenctrl) $(CRYPT_LIB) -lpthread -lz -lm
-
-LIBS += -L$(LIBVHDDIR) -lvhd
+VHDLIBS    := -L$(LIBVHDDIR) -lvhd
 
 REMUS-OBJS  := block-remus.o
 REMUS-OBJS  += hashtable.o
@@ -88,26 +84,26 @@
 all: $(IBIN) lock-util qcow-util
 
 
-tapdisk2: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk2.c
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
+tapdisk2: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk2.o
+       $(CC) -o $@ $^ $(LDFLAGS) -lrt -lz $(VHDLIBS) $(AIOLIBS) $(MEMSHRLIBS) 
-lm 
 
 tapdisk-client: tapdisk-client.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LBLIBS_img)
+       $(CC) -o $@ $^ $(LDFLAGS) -lrt
 
 tapdisk-stream tapdisk-diff: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
+       $(CC) -o $@ $^ $(LDFLAGS) -lrt -lz $(VHDLIBS) $(AIOLIBS) $(MEMSHRLIBS) 
-lm
 
 td-util: td.o tapdisk-utils.o tapdisk-log.o $(PORTABLE-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LBLIBS_img)
+       $(CC) -o $@ $^ $(LDFLAGS) $(VHDLIBS)
 
 lock-util: lock.c
-       $(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LDFLAGS)
 
 .PHONY: qcow-util
 qcow-util: img2qcow qcow2raw qcow-create
 
 img2qcow qcow2raw qcow-create: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
+       $(CC) -o $@ $^ $(LDFLAGS) -lrt -lz $(VHDLIBS) $(AIOLIBS) $(MEMSHRLIBS) 
-lm
 
 install: all
        $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
diff -r 1c1ecbcf4100 -r 265106fce653 tools/console/Makefile
--- a/tools/console/Makefile    Thu Mar 17 19:15:42 2011 +0000
+++ b/tools/console/Makefile    Thu Mar 17 19:38:05 2011 +0000
@@ -1,4 +1,3 @@
-
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
@@ -8,9 +7,10 @@
 CFLAGS  += $(CFLAGS_libxenstore)
 LDLIBS += $(LDLIBS_libxenctrl)
 LDLIBS += $(LDLIBS_libxenstore)
-LDLIBS += $(UTIL_LIBS)
 LDLIBS += $(SOCKET_LIBS)
-LDLIBS += -lrt
+
+LDLIBS_xenconsoled += $(UTIL_LIBS)
+LDLIBS_xenconsoled += -lrt
 
 BIN      = xenconsoled xenconsole
 
@@ -23,10 +23,10 @@
        $(RM) client/*.o daemon/*.o
 
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
+       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(LDLIBS_xenconsoled)
 
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
-       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
+       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(LDLIBS_xenconsole)
 
 .PHONY: install
 install: $(BIN)
diff -r 1c1ecbcf4100 -r 265106fce653 tools/misc/Makefile
--- a/tools/misc/Makefile       Thu Mar 17 19:15:42 2011 +0000
+++ b/tools/misc/Makefile       Thu Mar 17 19:38:05 2011 +0000
@@ -15,6 +15,14 @@
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
+LDLIBS_xenperf      := $(LDLIBS_libxenctrl)
+LDLIBS_xenpm        := $(LDLIBS_libxenctrl)
+LDLIBS_xenlockprof  := $(LDLIBS_libxenctrl)
+LDLIBS_xenwatchdogd := $(LDLIBS_libxenctrl)
+LDLIBS_xen-hvmctx   := $(LDLIBS_libxenctrl)
+LDLIBS_xen-hvmcrash := $(LDLIBS_libxenctrl)
+LDLIBS_xen-hptool   := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
$(LDLIBS_libxenstore)
+
 SUBDIRS-$(CONFIG_LOMOUNT) += lomount
 SUBDIRS-$(CONFIG_MINITERM) += miniterm
 SUBDIRS := $(SUBDIRS-y)
@@ -52,7 +60,7 @@
        $(CC) -c $(CFLAGS) -o $@ $<
 
 xen-hvmctx xen-hvmcrash xenperf xenpm gtracestat xenlockprof xen-hptool 
xenwatchdogd: %: %.o Makefile
-       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) 
$(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
+       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_$*)
 
 gtraceview: %: %.o Makefile
        $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(CURSES_LIBS)
diff -r 1c1ecbcf4100 -r 265106fce653 tools/xcutils/Makefile
--- a/tools/xcutils/Makefile    Thu Mar 17 19:15:42 2011 +0000
+++ b/tools/xcutils/Makefile    Thu Mar 17 19:38:05 2011 +0000
@@ -11,12 +11,20 @@
 XEN_ROOT       = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
-CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 
 PROGRAMS = xc_restore xc_save readnotes lsevtchn
 
-LDLIBS   = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
+CFLAGS += -Werror
+
+CFLAGS_xc_restore := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
+CFLAGS_xc_save    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) 
$(CFLAGS_libxenstore)
+CFLAGS_readnotes  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
+CFLAGS_lsevtchn   := $(CFLAGS_libxenctrl)
+
+LDLIBS_xc_restore := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+LDLIBS_xc_save    := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
$(LDLIBS_libxenstore)
+LDLIBS_readnotes  := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+LDLIBS_lsevtchn   := $(LDLIBS_libxenctrl)
 
 .PHONY: all
 all: build
@@ -24,8 +32,11 @@
 .PHONY: build
 build: $(PROGRAMS)
 
+%.o: %.c
+       $(CC) $(CFLAGS) $(CFLAGS_$*) -c $^ -o $@
+
 $(PROGRAMS): %: %.o
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_$*) -o $@
 
 .PHONY: install
 install: build
diff -r 1c1ecbcf4100 -r 265106fce653 tools/xcutils/lsevtchn.c
--- a/tools/xcutils/lsevtchn.c  Thu Mar 17 19:15:42 2011 +0000
+++ b/tools/xcutils/lsevtchn.c  Thu Mar 17 19:38:05 2011 +0000
@@ -4,9 +4,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include <xs.h>
 #include <xenctrl.h>
-#include <xenguest.h>
 
 int main(int argc, char **argv)
 {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] tools: do not link against unused libraries., Xen patchbot-unstable <=