# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1300205433 0
# Node ID 4446ee65519b4fcd894b08cf091c5aed935d0e74
# Parent 75db4a775805fbdcb5013427661d94db1b7b17fc
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>
diff -r 75db4a775805 -r 4446ee65519b tools/Rules.mk
--- a/tools/Rules.mk Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/Rules.mk Tue Mar 15 16:10:33 2011 +0000
@@ -11,6 +11,7 @@ XEN_INCLUDE = $(XEN_ROOT)/tools/i
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_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,10 +39,16 @@ ifeq ($(LIBXL_BLKTAP),y)
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)
diff -r 75db4a775805 -r 4446ee65519b tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/blktap2/drivers/Makefile Tue Mar 15 16:10:33 2011 +0000
@@ -28,10 +28,6 @@ LBLIBS_img := $(LDLIBS_libxenctrl) $(CRY
LBLIBS_img := $(LDLIBS_libxenctrl) $(CRYPT_LIB) -lpthread -lz -lm
LIBS += -L$(LIBVHDDIR) -lvhd
-
-ifeq ($(CONFIG_Linux),y)
-LIBS += -luuid
-endif
REMUS-OBJS := block-remus.o
REMUS-OBJS += hashtable.o
diff -r 75db4a775805 -r 4446ee65519b tools/blktap2/vhd/Makefile
--- a/tools/blktap2/vhd/Makefile Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/blktap2/vhd/Makefile Tue Mar 15 16:10:33 2011 +0000
@@ -22,9 +22,6 @@ endif
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 75db4a775805 -r 4446ee65519b tools/libxl/Makefile
--- a/tools/libxl/Makefile Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/libxl/Makefile Tue Mar 15 16:10:33 2011 +0000
@@ -15,10 +15,16 @@ CFLAGS += -I. -fPIC
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)
@@ -81,7 +87,7 @@ libxenlight.so.$(MAJOR): libxenlight.so.
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 @@ libxlutil.so.$(XLUMAJOR): libxlutil.so.$
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 75db4a775805 -r 4446ee65519b tools/python/setup.py
--- a/tools/python/setup.py Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/python/setup.py Tue Mar 15 16:10:33 2011 +0000
@@ -6,119 +6,98 @@ XEN_ROOT = "../.."
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 @@ setup(name = 'xen',
'xen.sv',
'xen.xsview',
'xen.remus',
-
'xen.xend.tests',
'xen.xend.server.tests',
'xen.xend.xenstore.tests',
diff -r 75db4a775805 -r 4446ee65519b tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c Tue Mar 15 16:10:33 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 75db4a775805 -r 4446ee65519b tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Tue Mar 15 15:15:08 2011 +0000
+++ b/tools/python/xen/lowlevel/xs/xs.c Tue Mar 15 16:10:33 2011 +0000
@@ -30,7 +30,6 @@
#include <fcntl.h>
#include <errno.h>
-#include <xenctrl.h>
#include "xs.h"
/** @file
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|