Message ID | 1305552333-19351-1-git-send-email-alevy@redhat.com |
---|---|
State | New |
Headers | show |
On 05/16/2011 08:25 AM, Alon Levy wrote: > No flag to configure is required. Instead, added a libcacard.la target that > is not built by default, only when requested explicitly via: > > mkdir build > cd build > ../configure > make libcacard.la > make install-libcacard > > Uses libtool to do actual linking of object files and shared library, and > installing. Tested only under linux, but supposed to work on other systems as > well. > > If libtool isn't found you get a message complaining about that, only at build > time (since it is not a default target I did not add a message at configure > time). > > Note: please ignore the following warning message, it is harmless, and fixing > it would require using libtool to build trace-dtrace.lo which, since it isn't > built by gcc, I don't know how to do. > > *** Warning: Linking the shared library libcacard.la against the non-libtool > *** objects ../trace-dtrace.o is not portable! I don't think slipping in libtool like this is such a good idea. Why do you need this target? Isn't la just a static archive compiled with -fPIC? Doesn't the whole code base need to be compiled with -fPIC then (and isn't the warning above a legitimate concern?). Regards, Anthony Liguori > --- > Makefile | 17 +++++++++++++++++ > configure | 12 +++++++++++- > libcacard/Makefile | 38 ++++++++++++++++++++++++++++++++++---- > 3 files changed, 62 insertions(+), 5 deletions(-) > > diff --git a/Makefile b/Makefile > index 2b0438c..0215307 100644 > --- a/Makefile > +++ b/Makefile > @@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak > > version-obj-$(CONFIG_WIN32) += version.o > ###################################################################### > +# Support building shared library libcacard > + > +.PHONY: libcacard.la install-libcacard > +ifeq ($(LIBTOOL),) > +libcacard.la: > + @echo libtool is missing, please install and rerun configure > + > +install-libcacard: > + @echo libtool is missing, please install and rerun configure > +else > +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(trace-obj-y) > + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" libcacard.la,) > + > +install-libcacard: libcacard.la > + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" install-libcacard,) > +endif > +###################################################################### > > qemu-img.o: qemu-img-cmds.h > qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS) > diff --git a/configure b/configure > index 0627f1d..e62841e 100755 > --- a/configure > +++ b/configure > @@ -1276,6 +1276,15 @@ if ! has $pkg_config; then > fi > > ########################################## > +# libtool probe > + > +if ! has libtool; then > + libtool= > +else > + libtool=libtool > +fi > + > +########################################## > # Sparse probe > if test "$sparse" != "no" ; then > if has cgcc; then > @@ -3060,6 +3069,7 @@ echo "AR=$ar">> $config_host_mak > echo "OBJCOPY=$objcopy">> $config_host_mak > echo "LD=$ld">> $config_host_mak > echo "WINDRES=$windres">> $config_host_mak > +echo "LIBTOOL=$libtool">> $config_host_mak > echo "CFLAGS=$CFLAGS">> $config_host_mak > echo "QEMU_CFLAGS=$QEMU_CFLAGS">> $config_host_mak > echo "QEMU_INCLUDES=$QEMU_INCLUDES">> $config_host_mak > @@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then > # out of tree build > mkdir -p libcacard > rm -f libcacard/Makefile > - ln -s "$source_path/libcacard/Makefile" libcacard/Makefile > + symlink "$source_path/libcacard/Makefile" libcacard/Makefile > fi > > d=libuser > diff --git a/libcacard/Makefile b/libcacard/Makefile > index 1d34df0..3a5ad61 100644 > --- a/libcacard/Makefile > +++ b/libcacard/Makefile > @@ -4,15 +4,45 @@ > > $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) > > -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) > +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) > + > +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) > + > +# objects linked against normal qemu binaries, not compiled with libtool > +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) > + > +# objects linked into a shared library, built with libtool with -fPIC if required > +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) > + > +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_OBJS) > > QEMU_CFLAGS+=-I../ > > +libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y))) > + > vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o > - $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $(TARGET_DIR)$@") > + $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $@") > + > +clean: > + rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo .libs/* *.la > + rm -Rf .libs > > all: vscclient > > -clean: > - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient > +ifeq ($(LIBTOOL),) > +libcacard.la: > + @echo libtool is missing, please install and rerun configure > + > +install-libcacard: > + @echo libtool is missing, please install and rerun configure > +else > +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c > + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") > + > +libcacard.la: $(libcacard.lib-y) $(QEMU_OBJS_LIB) > + $(call quiet-command,libtool --mode=link --quiet --tag=CC $(CC) $(libcacard_libs) -lrt -rpath $(libdir) -o $@ $^," lt LINK $@") > > +install-libcacard: libcacard.la > + $(INSTALL_DIR) "$(DESTDIR)$(libdir)" > + libtool --mode=install $(INSTALL_PROG) libcacard.la "$(DESTDIR)$(libdir)" > +endif
On 05/16/2011 03:28 PM, Anthony Liguori wrote: >> >> >> *** Warning: Linking the shared library libcacard.la against the >> non-libtool >> *** objects ../trace-dtrace.o is not portable! > > I don't think slipping in libtool like this is such a good idea. I disagree but, the warning is indeed legitimate, so NACK > Isn't la just a static archive compiled with -fPIC? No, .la is a text file pointing (most importantly) to the static library, the shared library, and the dependencies of the static library. Alon, do you need this to comply with some packaging guidelines forbidding static libraries? Paolo
On 05/16/2011 07:37 PM, Alon Levy wrote: > I've settled on libtool > as the linker solution since it seems to be the de facto standard, please > correct me on this point if I'm wrong. We are not using autoconf, so > I've called it directly in it's various modes, compile, link and install. I agree. I don't dislike this particularly :) if at all. > Legitemacy of the warning: basically libtool is concerned about linking in position > dependant code. But the trace-dtrace.o contains no .rodata section and is not actually > a problem for the linker, I've verfied the resulting library works fine with spicec (the > spice client using it). I'm not sure, however, that glibc would still keep the sharing of .text. > I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. > Note that this building of a shared library is not something new - we've talked about > this before in relation to libcacard inclusion inside qemu git repository. Do you really need tracing besides as a dependency of qemu_malloc? Perhaps you can recompile qemu-malloc.o specially for libcacard, and force usage of the nop backend. Paolo
On Mon, May 16, 2011 at 03:59:53PM +0200, Paolo Bonzini wrote: > On 05/16/2011 03:28 PM, Anthony Liguori wrote: > >> > >> > >> *** Warning: Linking the shared library libcacard.la against the > >>non-libtool > >> *** objects ../trace-dtrace.o is not portable! > > > >I don't think slipping in libtool like this is such a good idea. > > I disagree but, the warning is indeed legitimate, so > > NACK > > >Isn't la just a static archive compiled with -fPIC? > > No, .la is a text file pointing (most importantly) to the static > library, the shared library, and the dependencies of the static > library. > > Alon, do you need this to comply with some packaging guidelines > forbidding static libraries? > <Answering both you and Anthony> I'm basically trying to replace the current shared object built by the standalone libcacard project. Since we are deprecating that on account of not wanting to maintain two code bases, I need a replacement shared object producing something somewhere. It seems best to do it within the project and not, say, as spec file for an rpm, for obvious reasons of wanting this to be distribution agnostic. I've settled on libtool as the linker solution since it seems to be the de facto standard, please correct me on this point if I'm wrong. We are not using autoconf, so I've called it directly in it's various modes, compile, link and install. Regarding your concerns from above: The libcacard.la target produces a shared object with the right version symlinks (libcacard.so.0.0.0, libcacard.so.0 and libcacard.so) thanks to libtool Legitemacy of the warning: basically libtool is concerned about linking in position dependant code. But the trace-dtrace.o contains no .rodata section and is not actually a problem for the linker, I've verfied the resulting library works fine with spicec (the spice client using it). I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. Note that this building of a shared library is not something new - we've talked about this before in relation to libcacard inclusion inside qemu git repository. > Paolo
On Mon, May 16, 2011 at 08:28:49AM -0500, Anthony Liguori wrote: > On 05/16/2011 08:25 AM, Alon Levy wrote: > >No flag to configure is required. Instead, added a libcacard.la target that > >is not built by default, only when requested explicitly via: > > > >mkdir build > >cd build > >../configure > >make libcacard.la > >make install-libcacard > > > >Uses libtool to do actual linking of object files and shared library, and > >installing. Tested only under linux, but supposed to work on other systems as > >well. > > > >If libtool isn't found you get a message complaining about that, only at build > >time (since it is not a default target I did not add a message at configure > >time). > > > >Note: please ignore the following warning message, it is harmless, and fixing > >it would require using libtool to build trace-dtrace.lo which, since it isn't > >built by gcc, I don't know how to do. > > > > *** Warning: Linking the shared library libcacard.la against the non-libtool > > *** objects ../trace-dtrace.o is not portable! > > I don't think slipping in libtool like this is such a good idea. Forgot from my reply to Paolo: libtool is complaining about the only object I didn't rebuild, trace-dtrace.o, the rest I've added rules specifically to rebuild into lo (-fPIC'ed) objects under libcacard (including specifically any qemu support code). I didn't do the same for trace-dtrace.o because a) I didn't find an easy way of doing it on account of it not being built by gcc b) it wasn't a real problem like I mentioned in the reply to Paolo. > > Why do you need this target? Answered in the reply to Paolo's email. > > Isn't la just a static archive compiled with -fPIC? Doesn't the > whole code base need to be compiled with -fPIC then (and isn't the > warning above a legitimate concern?). > > Regards, > > Anthony Liguori > > >--- > > Makefile | 17 +++++++++++++++++ > > configure | 12 +++++++++++- > > libcacard/Makefile | 38 ++++++++++++++++++++++++++++++++++---- > > 3 files changed, 62 insertions(+), 5 deletions(-) > > > >diff --git a/Makefile b/Makefile > >index 2b0438c..0215307 100644 > >--- a/Makefile > >+++ b/Makefile > >@@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak > > > > version-obj-$(CONFIG_WIN32) += version.o > > ###################################################################### > >+# Support building shared library libcacard > >+ > >+.PHONY: libcacard.la install-libcacard > >+ifeq ($(LIBTOOL),) > >+libcacard.la: > >+ @echo libtool is missing, please install and rerun configure > >+ > >+install-libcacard: > >+ @echo libtool is missing, please install and rerun configure > >+else > >+libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(trace-obj-y) > >+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" libcacard.la,) > >+ > >+install-libcacard: libcacard.la > >+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" install-libcacard,) > >+endif > >+###################################################################### > > > > qemu-img.o: qemu-img-cmds.h > > qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS) > >diff --git a/configure b/configure > >index 0627f1d..e62841e 100755 > >--- a/configure > >+++ b/configure > >@@ -1276,6 +1276,15 @@ if ! has $pkg_config; then > > fi > > > > ########################################## > >+# libtool probe > >+ > >+if ! has libtool; then > >+ libtool= > >+else > >+ libtool=libtool > >+fi > >+ > >+########################################## > > # Sparse probe > > if test "$sparse" != "no" ; then > > if has cgcc; then > >@@ -3060,6 +3069,7 @@ echo "AR=$ar">> $config_host_mak > > echo "OBJCOPY=$objcopy">> $config_host_mak > > echo "LD=$ld">> $config_host_mak > > echo "WINDRES=$windres">> $config_host_mak > >+echo "LIBTOOL=$libtool">> $config_host_mak > > echo "CFLAGS=$CFLAGS">> $config_host_mak > > echo "QEMU_CFLAGS=$QEMU_CFLAGS">> $config_host_mak > > echo "QEMU_INCLUDES=$QEMU_INCLUDES">> $config_host_mak > >@@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then > > # out of tree build > > mkdir -p libcacard > > rm -f libcacard/Makefile > >- ln -s "$source_path/libcacard/Makefile" libcacard/Makefile > >+ symlink "$source_path/libcacard/Makefile" libcacard/Makefile > > fi > > > > d=libuser > >diff --git a/libcacard/Makefile b/libcacard/Makefile > >index 1d34df0..3a5ad61 100644 > >--- a/libcacard/Makefile > >+++ b/libcacard/Makefile > >@@ -4,15 +4,45 @@ > > > > $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) > > > >-QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) > >+QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) > >+ > >+QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) > >+ > >+# objects linked against normal qemu binaries, not compiled with libtool > >+QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) > >+ > >+# objects linked into a shared library, built with libtool with -fPIC if required > >+QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) > >+ > >+QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_OBJS) > > > > QEMU_CFLAGS+=-I../ > > > >+libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y))) > >+ > > vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o > >- $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $(TARGET_DIR)$@") > >+ $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $@") > >+ > >+clean: > >+ rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo .libs/* *.la > >+ rm -Rf .libs > > > > all: vscclient > > > >-clean: > >- rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient > >+ifeq ($(LIBTOOL),) > >+libcacard.la: > >+ @echo libtool is missing, please install and rerun configure > >+ > >+install-libcacard: > >+ @echo libtool is missing, please install and rerun configure > >+else > >+$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c > >+ $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") > >+ > >+libcacard.la: $(libcacard.lib-y) $(QEMU_OBJS_LIB) > >+ $(call quiet-command,libtool --mode=link --quiet --tag=CC $(CC) $(libcacard_libs) -lrt -rpath $(libdir) -o $@ $^," lt LINK $@") > > > >+install-libcacard: libcacard.la > >+ $(INSTALL_DIR) "$(DESTDIR)$(libdir)" > >+ libtool --mode=install $(INSTALL_PROG) libcacard.la "$(DESTDIR)$(libdir)" > >+endif >
On Mon, May 16, 2011 at 04:44:03PM +0200, Paolo Bonzini wrote: > On 05/16/2011 07:37 PM, Alon Levy wrote: > >I've settled on libtool > >as the linker solution since it seems to be the de facto standard, please > >correct me on this point if I'm wrong. We are not using autoconf, so > >I've called it directly in it's various modes, compile, link and install. > > I agree. I don't dislike this particularly :) if at all. > > >Legitemacy of the warning: basically libtool is concerned about linking in position > >dependant code. But the trace-dtrace.o contains no .rodata section and is not actually > >a problem for the linker, I've verfied the resulting library works fine with spicec (the > >spice client using it). > > I'm not sure, however, that glibc would still keep the sharing of .text. > I'll check. > >I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. > >Note that this building of a shared library is not something new - we've talked about > >this before in relation to libcacard inclusion inside qemu git repository. > > Do you really need tracing besides as a dependency of qemu_malloc? > Perhaps you can recompile qemu-malloc.o specially for libcacard, and > force usage of the nop backend. Sounds like a very good idea for short term. Otoh if I'm already building libcacard with qemu dependencies, it would be nice if I could benefit from the tracing framework. I'll investigate building trace-dtrace.lo and if this doesn't work I'll try nop backend. > > Paolo >
diff --git a/Makefile b/Makefile index 2b0438c..0215307 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak version-obj-$(CONFIG_WIN32) += version.o ###################################################################### +# Support building shared library libcacard + +.PHONY: libcacard.la install-libcacard +ifeq ($(LIBTOOL),) +libcacard.la: + @echo libtool is missing, please install and rerun configure + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(trace-obj-y) + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" libcacard.la,) + +install-libcacard: libcacard.la + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" install-libcacard,) +endif +###################################################################### qemu-img.o: qemu-img-cmds.h qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS) diff --git a/configure b/configure index 0627f1d..e62841e 100755 --- a/configure +++ b/configure @@ -1276,6 +1276,15 @@ if ! has $pkg_config; then fi ########################################## +# libtool probe + +if ! has libtool; then + libtool= +else + libtool=libtool +fi + +########################################## # Sparse probe if test "$sparse" != "no" ; then if has cgcc; then @@ -3060,6 +3069,7 @@ echo "AR=$ar" >> $config_host_mak echo "OBJCOPY=$objcopy" >> $config_host_mak echo "LD=$ld" >> $config_host_mak echo "WINDRES=$windres" >> $config_host_mak +echo "LIBTOOL=$libtool" >> $config_host_mak echo "CFLAGS=$CFLAGS" >> $config_host_mak echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak @@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then # out of tree build mkdir -p libcacard rm -f libcacard/Makefile - ln -s "$source_path/libcacard/Makefile" libcacard/Makefile + symlink "$source_path/libcacard/Makefile" libcacard/Makefile fi d=libuser diff --git a/libcacard/Makefile b/libcacard/Makefile index 1d34df0..3a5ad61 100644 --- a/libcacard/Makefile +++ b/libcacard/Makefile @@ -4,15 +4,45 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) + +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) + +# objects linked against normal qemu binaries, not compiled with libtool +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) + +# objects linked into a shared library, built with libtool with -fPIC if required +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) + +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_OBJS) QEMU_CFLAGS+=-I../ +libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y))) + vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o - $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $(TARGET_DIR)$@") + $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^," LINK $@") + +clean: + rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo .libs/* *.la + rm -Rf .libs all: vscclient -clean: - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient +ifeq ($(LIBTOOL),) +libcacard.la: + @echo libtool is missing, please install and rerun configure + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + +libcacard.la: $(libcacard.lib-y) $(QEMU_OBJS_LIB) + $(call quiet-command,libtool --mode=link --quiet --tag=CC $(CC) $(libcacard_libs) -lrt -rpath $(libdir) -o $@ $^," lt LINK $@") +install-libcacard: libcacard.la + $(INSTALL_DIR) "$(DESTDIR)$(libdir)" + libtool --mode=install $(INSTALL_PROG) libcacard.la "$(DESTDIR)$(libdir)" +endif