Name: pic-lib.patch Description: support PIC code generation Libraries have 2 methods of being compiled; a .so must contain non-pic objects, while the .a can contain standard objects. Signed-off-by: Adam Heath <doogie@brainfood.com> DiffStat: tools/libxc/Makefile | 33 +++++++++++++++++++++------------ tools/libxutil/Makefile | 12 +++++++++--- 2 files changed, 30 insertions(+), 15 deletions(-) --- xen-2.0.4.orig/tools/libxutil/Makefile +++ xen-2.0.4/tools/libxutil/Makefile @@ -24,6 +24,7 @@ LIB_SRCS += util.c LIB_OBJS := $(LIB_SRCS:.c=.o) +LIB_PIC_OBJS := $(LIB_SRCS:.c=.opic) CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing @@ -34,6 +35,7 @@ MAJOR := 2.0 MINOR := 0 LIB_NAME := libxutil +SO_NAME := $(LIB_NAME).so.$(MAJOR) LIB := $(LIB_NAME).so LIB += $(LIB_NAME).so.$(MAJOR) LIB += $(LIB_NAME).so.$(MAJOR).$(MINOR) @@ -42,14 +44,17 @@ all: check-for-zlib $(MAKE) $(LIB) +$(LIB_PIC_OBJS): %.opic: %.c + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< + $(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) ln -sf $^ $@ $(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) ln -sf $^ $@ -$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_OBJS) - $(CC) -Wl,-soname -Wl,$(LIB_NAME).so.$(MAJOR) -shared -o $@ $^ +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_PIC_OBJS) + $(CC) -Wl,-soname -Wl,$(SO_NAME) -shared -o $@ $^ $(LIB_NAME).a: $(LIB_OBJS) $(AR) rc $@ $^ @@ -65,11 +71,12 @@ install: all [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) -p $(DESTDIR)/usr/lib $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so clean: - $(RM) *.a *.so *.so.* *.o *.rpm + $(RM) *.a *.so *.so.* *.o *.opic *.rpm $(RM) *~ $(RM) $(DEPS) --- xen-2.0.4.orig/tools/libxc/Makefile +++ xen-2.0.4/tools/libxc/Makefile @@ -5,7 +5,8 @@ MAJOR = 2.0 MINOR = 0 -SONAME = libxc.so.$(MAJOR) +LIB_NAME = libxc +SONAME = $(LIB_NAME).so.$(MAJOR) CC = gcc @@ -39,9 +40,10 @@ CFLAGS += -Wp,-MD,.$(@F).d DEPS = .*.d -OBJS = $(patsubst %.c,%.o,$(SRCS)) +OBJS := $(patsubst %.c,%.o,$(SRCS)) +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS)) -LIB = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR) +LIB := $(LIB_NAME).a $(LIB_NAME).so $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR) all: check-for-zlib mk-symlinks $(MAKE) $(LIB) @@ -68,13 +70,14 @@ install: all [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include - $(INSTALL_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib - ln -sf libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/libxc.so.$(MAJOR) - ln -sf libxc.so.$(MAJOR) $(DESTDIR)/usr/lib/libxc.so + $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib + ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) + ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so $(INSTALL_DATA) xc.h $(DESTDIR)/usr/include clean: - rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen + rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen rpm: all rm -rf staging @@ -85,11 +87,17 @@ mv staging/i386/*.rpm . rm -rf staging -libxc.so: - ln -sf libxc.so.$(MAJOR) $@ -libxc.so.$(MAJOR): - ln -sf libxc.so.$(MAJOR).$(MINOR) $@ -libxc.so.$(MAJOR).$(MINOR): $(OBJS) +$(PIC_OBJS): %.opic: %.c + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< + +$(LIB_NAME).a: $(OBJS) + $(AR) rc $@ $^ + +$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) + ln -sf $< $@ +$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) + ln -sf $< $@ +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz -include $(DEPS) ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Xen-devel mailing list Xen-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
Hmm. We''re having second thoughts about this patch... Why is bulding the .so''s PIC important for Debian? In all the libraries I''ve ever built I can''t ever recall seeing one of these .opic files before. PIC code on x86 burns ebx, which causes a measurable slowdown (which we might even care about during save/restore/migrate). Further, I wander if all versions of gcc cope correctly with inline asm that uses ebx??? Why do you need this patch? Thanks, Ian> -----Original Message----- > From: xen-devel-admin@lists.sourceforge.net > [mailto:xen-devel-admin@lists.sourceforge.net] On Behalf Of Adam Heath > Sent: 05 February 2005 04:24 > To: xen-devel@lists.sourceforge.net > Subject: [Xen-devel] debian pic-lib.patch (4 of 5) > > Name: pic-lib.patch > Description: support PIC code generation > Libraries have 2 methods of being compiled; a .so must > contain non-pic > objects, while the .a can contain standard objects. > Signed-off-by: Adam Heath <doogie@brainfood.com> > DiffStat: > tools/libxc/Makefile | 33 +++++++++++++++++++++------------ > tools/libxutil/Makefile | 12 +++++++++--- > 2 files changed, 30 insertions(+), 15 deletions(-) > > --- xen-2.0.4.orig/tools/libxutil/Makefile > +++ xen-2.0.4/tools/libxutil/Makefile > @@ -24,6 +24,7 @@ > LIB_SRCS += util.c > > LIB_OBJS := $(LIB_SRCS:.c=.o) > +LIB_PIC_OBJS := $(LIB_SRCS:.c=.opic) > > CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing > > @@ -34,6 +35,7 @@ > MAJOR := 2.0 > MINOR := 0 > LIB_NAME := libxutil > +SO_NAME := $(LIB_NAME).so.$(MAJOR) > LIB := $(LIB_NAME).so > LIB += $(LIB_NAME).so.$(MAJOR) > LIB += $(LIB_NAME).so.$(MAJOR).$(MINOR) > @@ -42,14 +44,17 @@ > all: check-for-zlib > $(MAKE) $(LIB) > > +$(LIB_PIC_OBJS): %.opic: %.c > + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< > + > $(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) > ln -sf $^ $@ > > $(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) > ln -sf $^ $@ > > -$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_OBJS) > - $(CC) -Wl,-soname -Wl,$(LIB_NAME).so.$(MAJOR) -shared -o $@ $^ > +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_PIC_OBJS) > + $(CC) -Wl,-soname -Wl,$(SO_NAME) -shared -o $@ $^ > > $(LIB_NAME).a: $(LIB_OBJS) > $(AR) rc $@ $^ > @@ -65,11 +71,12 @@ > install: all > [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) -p > $(DESTDIR)/usr/lib > $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) > $(DESTDIR)/usr/lib > + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib > ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) > $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) > ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so > > clean: > - $(RM) *.a *.so *.so.* *.o *.rpm > + $(RM) *.a *.so *.so.* *.o *.opic *.rpm > $(RM) *~ > $(RM) $(DEPS) > > --- xen-2.0.4.orig/tools/libxc/Makefile > +++ xen-2.0.4/tools/libxc/Makefile > @@ -5,7 +5,8 @@ > > MAJOR = 2.0 > MINOR = 0 > -SONAME = libxc.so.$(MAJOR) > +LIB_NAME = libxc > +SONAME = $(LIB_NAME).so.$(MAJOR) > > CC = gcc > > @@ -39,9 +40,10 @@ > CFLAGS += -Wp,-MD,.$(@F).d > DEPS = .*.d > > -OBJS = $(patsubst %.c,%.o,$(SRCS)) > +OBJS := $(patsubst %.c,%.o,$(SRCS)) > +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS)) > > -LIB = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR) > +LIB := $(LIB_NAME).a $(LIB_NAME).so > $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR) > > all: check-for-zlib mk-symlinks > $(MAKE) $(LIB) > @@ -68,13 +70,14 @@ > install: all > [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib > [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) > $(DESTDIR)/usr/include > - $(INSTALL_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib > - ln -sf libxc.so.$(MAJOR).$(MINOR) > $(DESTDIR)/usr/lib/libxc.so.$(MAJOR) > - ln -sf libxc.so.$(MAJOR) $(DESTDIR)/usr/lib/libxc.so > + $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) > $(DESTDIR)/usr/lib > + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib > + ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) > $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) > + ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so > $(INSTALL_DATA) xc.h $(DESTDIR)/usr/include > > clean: > - rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen > + rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen > > rpm: all > rm -rf staging > @@ -85,11 +87,17 @@ > mv staging/i386/*.rpm . > rm -rf staging > > -libxc.so: > - ln -sf libxc.so.$(MAJOR) $@ > -libxc.so.$(MAJOR): > - ln -sf libxc.so.$(MAJOR).$(MINOR) $@ > -libxc.so.$(MAJOR).$(MINOR): $(OBJS) > +$(PIC_OBJS): %.opic: %.c > + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< > + > +$(LIB_NAME).a: $(OBJS) > + $(AR) rc $@ $^ > + > +$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) > + ln -sf $< $@ > +$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) > + ln -sf $< $@ > +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) > $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ > -L../libxutil -lxutil -lz > > -include $(DEPS) > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive > Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/xen-devel >------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Xen-devel mailing list Xen-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
On Sat, 5 Feb 2005, Ian Pratt wrote:> Hmm. We''re having second thoughts about this patch... > > Why is bulding the .so''s PIC important for Debian? In all the libraries > I''ve ever built I can''t ever recall seeing one of these .opic files > before.Shared libraries are required to be compiled with -fPIC. For one, some arches won''t work with it(i386, unfortunately, is not one; this is the reason this argument comes up so often. However, amd64 requires -fPIC). Second, if a library is not compiled with -fPIC, then when it is runtime-linked to binaries, it will be located at different addresses, and the kernel won''t be able to share pages with other apps that link to it. As for the .opic files, that''s not really a standard. Libraries are required to be pic. But static libraries libraries don''t have to be. So, files are required to be compiled twice, and .opic is just my personal preference. Some build systems build them in separate dirs. That works fine too. Note, that if you are going to link static code into *another* shared library(that isn''t also static), then you must link the pic versions. This very often means a shared lib(.so) has pic files, a normal .a has non-pic, but a -pic.a has the same pic files that the shared lib has. Running prelink is a good way to find these problem libraries. A command of the form: prelink --all --conserve-memory --random > /tmp/PRELINK 2>&1> PIC code on x86 burns ebx, which causes a measurable slowdown (which we > might even care about during save/restore/migrate). Further, I wander if > all versions of gcc cope correctly with inline asm that uses ebx???The inline asm needs to be compiled pic as well.> Why do you need this patch?If you don''t take it upstream, that''s fine. But that will force me to maintain it separately for debian, which is sub-optimal. Debian policy requires this of libraries. ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Xen-devel mailing list Xen-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel