From 10128bdb23b42d84545c29c5e6864463183fd9b4 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 17 Mar 2011 19:15:18 +0000 Subject: tools: link each shared library or binary only against the libraries it uses In particular if binary A uses libB and libB uses libC entirely internally then A does not need to link against libC only libB. However when linking binary A the linker does need to have visibility of the libraries which libB links against (libC in this example). For out of tree uses this is achieved without fuss due because the libraries are installed in a standard path. However in the case of in-tree users the linker needs a hint in the form of the -rpath-link option. Therefore a new class of build variable, $(SHLIB_FOO), is introduced which includes the linker options needed to link against a library which uses libFOO. The intention is that $(LDLIBS_bar) will include the $(SHLIB_foo)s which it uses where necessary rather requiring that users are aware of this. For the python extensions this change appears particularly large since previously each of python bindings were linked against the union of all possible libraries used by all bindings instead of just what they individually needed. This change removes a dependency on libdl.so from nearly everything in the system, only libxenctrl actually uses it. In the context of xl/libxl the intention of libxl is to remove any need for a user of libxl to know about libxenstore or libxenctrl, however in the current build it is xl which links against those libraries rather than libxl (which only links against libc). After this change libxl correctly depends on the libraries it uses and xl does not depend on libraries which it is not support to be required to know about. Note that xl does depend on libxenctrl.so since it uses xtl_* directly. Signed-off-by: Ian Campbell Committed-by: Ian Jackson --- tools/Rules.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tools/Rules.mk') diff --git a/tools/Rules.mk b/tools/Rules.mk index f7dda356b5..6249573c5b 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -11,6 +11,7 @@ INSTALL = $(XEN_ROOT)/tools/cross-install XEN_INCLUDE = $(XEN_ROOT)/tools/include XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc XEN_LIBXC = $(XEN_ROOT)/tools/libxc +XEN_XENLIGHT = $(XEN_ROOT)/tools/libxl XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore XEN_LIBXENSTAT = $(XEN_ROOT)/tools/xenstat/libxenstat/src XEN_BLKTAP2 = $(XEN_ROOT)/tools/blktap2 @@ -18,13 +19,16 @@ XEN_BLKTAP2 = $(XEN_ROOT)/tools/blktap2 CFLAGS_include = -I$(XEN_INCLUDE) CFLAGS_libxenctrl = -I$(XEN_LIBXC) $(CFLAGS_include) -LDLIBS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl $(DLOPEN_LIBS) +LDLIBS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl +SHLIB_libxenctrl = -Wl,-rpath-link=$(XEN_LIBXC) CFLAGS_libxenguest = -I$(XEN_LIBXC) $(CFLAGS_include) LDLIBS_libxenguest = -L$(XEN_LIBXC) -lxenguest +SHLIB_libxenguest = -Wl,-rpath-link=L$(XEN_LIBXC) CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include) LDLIBS_libxenstore = -L$(XEN_XENSTORE) -lxenstore +SHLIB_libxenstore = -Wl,-rpath-link=$(XEN_XENSTORE) ifeq ($(CONFIG_Linux),y) LIBXL_BLKTAP = y @@ -35,11 +39,17 @@ endif ifeq ($(LIBXL_BLKTAP),y) CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include $(CFLAGS_include) LDLIBS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl +SHLIB_libblktapctl = -Wl,-rpath-link=$(XEN_BLKTAP2)/control else CFLAGS_libblktapctl = LDLIBS_libblktapctl = +SHLIB_libblktapctl = endif +CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_include) +LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight +SHLIB_libxenlight = -Wl,-rpath-link=$(XEN_XENLIGHT) + X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR) CFLAGS += -D__XEN_TOOLS__ -- cgit v1.2.3