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: link each shared library or binary

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools: link each shared library or binary only against the libraries it uses
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sun, 20 Mar 2011 06:40:26 +0000
Delivery-date: Sat, 19 Mar 2011 23:44:28 -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 1300389318 0
# Node ID a73a35527763b451191d3b56035bf4caa74220d0
# Parent  cf8ba07727b3c8e262a44c58c1ae1fb25f3f6fe8
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 <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r cf8ba07727b3 -r a73a35527763 tools/Rules.mk
--- a/tools/Rules.mk    Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/Rules.mk    Thu Mar 17 19:15:18 2011 +0000
@@ -11,6 +11,7 @@
 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 @@
 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 @@
 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__
diff -r cf8ba07727b3 -r a73a35527763 tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile    Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/blktap2/drivers/Makefile    Thu Mar 17 19:15:18 2011 +0000
@@ -29,10 +29,6 @@
 
 LIBS += -L$(LIBVHDDIR) -lvhd
 
-ifeq ($(CONFIG_Linux),y)
-LIBS += -luuid
-endif
-
 REMUS-OBJS  := block-remus.o
 REMUS-OBJS  += hashtable.o
 REMUS-OBJS  += hashtable_itr.o
diff -r cf8ba07727b3 -r a73a35527763 tools/blktap2/vhd/Makefile
--- a/tools/blktap2/vhd/Makefile        Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/blktap2/vhd/Makefile        Thu Mar 17 19:15:18 2011 +0000
@@ -22,9 +22,6 @@
 endif
 
 LIBS              := -Llib -lvhd
-ifeq ($(CONFIG_Linux),y)
-LIBS              += -luuid
-endif
 
 # Get gcc to generate the dependencies for us.
 CFLAGS            += -Wp,-MD,.$(@F).d
diff -r cf8ba07727b3 -r a73a35527763 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/libxl/Makefile      Thu Mar 17 19:15:18 2011 +0000
@@ -15,11 +15,17 @@
 CFLAGS += -I. -fPIC
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) 
$(CFLAGS_libblktapctl)
 
-LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) 
$(LDLIBS_libblktapctl) $(UTIL_LIBS)
 ifeq ($(CONFIG_Linux),y)
-LIBS += -luuid
+LIBUUID_LIBS += -luuid
 endif
 
+LIBXL_LIBS =
+LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) 
$(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS)
+
+LIBXLU_LIBS =
+
+CLIENT_LIBS = $(LDLIBS_libxenlight)
+
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
 ifeq ($(LIBXL_BLKTAP),y)
 LIBXL_OBJS-y += libxl_blktap2.o
@@ -81,7 +87,7 @@
        ln -sf $< $@
 
 libxenlight.so.$(MAJOR).$(MINOR): $(LIBXL_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) -Wl,-rpath-link -Wl,$(XEN_ROOT)/tools/libxc $(LDFLAGS) 
-Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ 
$(LIBXL_LIBS)
 
 libxenlight.a: $(LIBXL_OBJS)
        $(AR) rcs libxenlight.a $^
@@ -93,13 +99,13 @@
        ln -sf $< $@
 
 libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXLU_LIBS)
 
 libxlutil.a: $(LIBXLU_OBJS)
        $(AR) rcs libxlutil.a $^
 
 $(CLIENTS): $(XL_OBJS) libxlutil.so libxenlight.so
-       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+       $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so 
$(CLIENT_LIBS)
 
 .PHONY: install
 install: all
diff -r cf8ba07727b3 -r a73a35527763 tools/python/setup.py
--- a/tools/python/setup.py     Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/python/setup.py     Thu Mar 17 19:15:18 2011 +0000
@@ -6,119 +6,98 @@
 
 extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
 
-include_dirs = [ XEN_ROOT + "/tools/libxc",
-                 XEN_ROOT + "/tools/xenstore",
-                 XEN_ROOT + "/tools/include",
-                 XEN_ROOT + "/tools/libxl",
-                 ]
-
-library_dirs = [ XEN_ROOT + "/tools/libxc",
-                 XEN_ROOT + "/tools/xenstore",
-                 XEN_ROOT + "/tools/libxl"
-                 ]
-
-libraries = [ "xenctrl", "xenguest", "xenstore" ]
-
-depends = [ XEN_ROOT + "/tools/libxc/libxenctrl.so",
-            XEN_ROOT + "/tools/libxc/libxenguest.so",
-            XEN_ROOT + "/tools/xenstore/libxenstore.so"
-            ]
-
-plat = os.uname()[0]
-if plat == 'Linux':
-    uuid_libs = ["uuid"]
-    blktap_ctl_libs = ["blktapctl"]
-    library_dirs.append(XEN_ROOT + "/tools/blktap2/control")
-    blktab_ctl_depends = [ XEN_ROOT + "/tools/blktap2/control/libblktapctl.so" 
]
-else:
-    uuid_libs = []
-    blktap_ctl_libs = []
-    blktab_ctl_depends = []
+PATH_XEN      = XEN_ROOT + "/tools/include"
+PATH_LIBXC    = XEN_ROOT + "/tools/libxc"
+PATH_LIBXL    = XEN_ROOT + "/tools/libxl"
+PATH_XENSTORE = XEN_ROOT + "/tools/xenstore"
 
 xc = Extension("xc",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/xc" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries,
-               depends            = depends,
+               include_dirs       = [ PATH_XEN, PATH_LIBXC, "xen/lowlevel/xc" 
],
+               library_dirs       = [ PATH_LIBXC ],
+               libraries          = [ "xenctrl", "xenguest" ],
+               depends            = [ PATH_LIBXC + "/libxenctrl.so", 
PATH_LIBXC + "/libxenguest.so" ],
                sources            = [ "xen/lowlevel/xc/xc.c" ])
 
 xs = Extension("xs",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/xs" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries,
-               depends            = depends,
+               include_dirs       = [ PATH_XEN, PATH_XENSTORE, 
"xen/lowlevel/xs" ],
+               library_dirs       = [ PATH_XENSTORE ],
+               libraries          = [ "xenstore" ],
+               depends            = [ PATH_XENSTORE + "/libxenstore.so" ],
                sources            = [ "xen/lowlevel/xs/xs.c" ])
 
 scf = Extension("scf",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/scf" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries,
-               depends            = depends,
+               include_dirs       = [ "xen/lowlevel/scf" ],
+               library_dirs       = [ ],
+               libraries          = [ ],
+               depends            = [ ],
                sources            = [ "xen/lowlevel/scf/scf.c" ])
-             
+
 process = Extension("process",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/process" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries + [ "contract" ],
-               depends            = depends,
+               include_dirs       = [ "xen/lowlevel/process" ],
+               library_dirs       = [ ],
+               libraries          = [ "contract" ],
+               depends            = [ ],
                sources            = [ "xen/lowlevel/process/process.c" ])
 
 acm = Extension("acm",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/acm" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries,
-               depends            = depends,
+               include_dirs       = [ PATH_XEN, PATH_LIBXC, "xen/lowlevel/acm" 
],
+               library_dirs       = [ PATH_LIBXC ],
+               libraries          = [ "xenctrl" ],
+               depends            = [ PATH_LIBXC + "/libxenctrl.so" ],
                sources            = [ "xen/lowlevel/acm/acm.c" ])
 
 flask = Extension("flask",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/flask" ] + 
-                                        [ "../flask/libflask/include" ],
-               library_dirs       = library_dirs + [ "../flask/libflask" ],
-               libraries          = libraries + [ "flask" ],
-               depends            = depends + [ XEN_ROOT + 
"/tools/flask/libflask/libflask.so" ],
+               include_dirs       = [ PATH_XEN, PATH_LIBXC, 
"xen/lowlevel/flask",
+                                      "../flask/libflask/include" ],
+               library_dirs       = [ PATH_LIBXC, "../flask/libflask" ],
+               libraries          = [ "xenctrl", "flask" ],
+               depends            = [ PATH_LIBXC + "/libxenctrl.so",
+                                      XEN_ROOT + 
"/tools/flask/libflask/libflask.so" ],
                sources            = [ "xen/lowlevel/flask/flask.c" ])
 
 ptsname = Extension("ptsname",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "ptsname" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries,
-               depends            = depends,
+               include_dirs       = [ "ptsname" ],
+               library_dirs       = [ ],
+               libraries          = [ ],
+               depends            = [ ],
                sources            = [ "ptsname/ptsname.c" ])
 
 checkpoint = Extension("checkpoint",
-                       extra_compile_args = extra_compile_args,
-                       include_dirs       = include_dirs,
-                       library_dirs       = library_dirs,
-                       libraries          = libraries + [ "rt" ],
-                       depends            = depends,
-                       sources            = [ 
"xen/lowlevel/checkpoint/checkpoint.c",
-                                              
"xen/lowlevel/checkpoint/libcheckpoint.c"])
+               extra_compile_args = extra_compile_args,
+               include_dirs       = [ PATH_XEN, PATH_LIBXC, PATH_XENSTORE ],
+               library_dirs       = [ PATH_LIBXC, PATH_XENSTORE ],
+               libraries          = [ "xenctrl", "xenguest", "xenstore", "rt" 
],
+               depends            = [ PATH_LIBXC + "/libxenctrl.so",
+                                      PATH_LIBXC + "/libxenguest.so",
+                                      PATH_XENSTORE + "/libxenstore.so" ],
+               sources            = [ "xen/lowlevel/checkpoint/checkpoint.c",
+                                      
"xen/lowlevel/checkpoint/libcheckpoint.c"])
 
 netlink = Extension("netlink",
-                    extra_compile_args = extra_compile_args,
-                    include_dirs       = include_dirs,
-                    library_dirs       = library_dirs,
-                    libraries          = libraries,
-                    depends            = depends,
-                    sources            = [ "xen/lowlevel/netlink/netlink.c",
-                                           
"xen/lowlevel/netlink/libnetlink.c"])
+               extra_compile_args = extra_compile_args,
+               include_dirs       = [ ],
+               library_dirs       = [ ],
+               libraries          = [ ],
+               depends            = [ ],
+               sources            = [ "xen/lowlevel/netlink/netlink.c",
+                                      "xen/lowlevel/netlink/libnetlink.c"])
 
 xl = Extension("xl",
                extra_compile_args = extra_compile_args,
-               include_dirs       = include_dirs + [ "xen/lowlevel/xl" ],
-               library_dirs       = library_dirs,
-               libraries          = libraries + ["xenlight" ] + 
blktap_ctl_libs + uuid_libs,
-               depends            = depends + blktab_ctl_depends +
-                                    [ XEN_ROOT + "/tools/libxl/libxenlight.so" 
],
+               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, 
PATH_XENSTORE, "xen/lowlevel/xl" ],
+               library_dirs       = [ PATH_LIBXL ],
+               libraries          = [ "xenlight" ],
+               depends            = [ PATH_LIBXL + "/libxenlight.so" ],
                sources            = [ "xen/lowlevel/xl/xl.c", 
"xen/lowlevel/xl/_pyxl_types.c" ])
 
+plat = os.uname()[0]
 modules = [ xc, xs, ptsname, acm, flask, xl ]
 if plat == 'SunOS':
     modules.extend([ scf, process ])
@@ -143,7 +122,6 @@
                          'xen.sv',
                          'xen.xsview',
                          'xen.remus',
-
                          'xen.xend.tests',
                          'xen.xend.server.tests',
                          'xen.xend.xenstore.tests',
diff -r cf8ba07727b3 -r a73a35527763 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c Thu Mar 17 19:15:18 2011 +0000
@@ -35,7 +35,6 @@
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <arpa/inet.h>
-#include <xenctrl.h>
 #include <ctype.h>
 #include <inttypes.h>
 
diff -r cf8ba07727b3 -r a73a35527763 tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Thu Mar 17 19:14:57 2011 +0000
+++ b/tools/python/xen/lowlevel/xs/xs.c Thu Mar 17 19:15:18 2011 +0000
@@ -30,7 +30,6 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#include <xenctrl.h>
 #include "xs.h"
 
 /** @file

_______________________________________________
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: link each shared library or binary only against the libraries it uses, Xen patchbot-unstable <=