Patchwork [4/5] configure: move common libraries to config-host.mak

login
register
mail settings
Submitter Paolo Bonzini
Date April 2, 2013, 2:44 p.m.
Message ID <1364913860-25159-5-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/233020/
State New
Headers show

Comments

Paolo Bonzini - April 2, 2013, 2:44 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Makefile.target | 2 +-
 configure       | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Peter Maydell - April 2, 2013, 5:01 p.m.
On 2 April 2013 15:44, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

I think this may perturb the order of the link line slightly,
but hopefully not in any way that matters. (Did you test a
static build?)

-- PMM
Paolo Bonzini - April 2, 2013, 5:26 p.m.
Il 02/04/2013 19:01, Peter Maydell ha scritto:
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> 
> I think this may perturb the order of the link line slightly,
> but hopefully not in any way that matters. (Did you test a
> static build?)

I don't have static versions of half of the prerequisites of system
emulators...

Paolo
Peter Maydell - April 2, 2013, 6:17 p.m.
On 2 April 2013 18:26, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 02/04/2013 19:01, Peter Maydell ha scritto:
>> I think this may perturb the order of the link line slightly,
>> but hopefully not in any way that matters. (Did you test a
>> static build?)
>
> I don't have static versions of half of the prerequisites of system
> emulators...

Really? Ubuntu provides them, maybe you should complain to your
distro vendor :-)

Anyway, I did a compile test of everything with --static and it
does turn out to be busted:

ccache gcc -Werror -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall
-Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing
-fstack-protector-all -Wendif-labels -Wmissing-include-dirs
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k
-Winit-self -Wignored-qualifiers -Wold-style-declaration
-Wold-style-definition -Wtype-limits -I/usr/include/libpng12
-I/usr/include/pixman-1   -DHAS_AUDIO -DHAS_AUDIO_CHOICE  -I. -I.
-I../linux-headers -I..
-I/home/petmay01/linaro/qemu-from-laptop/qemu/target-i386 -DNEED_CPU_H
-I/home/petmay01/linaro/qemu-from-laptop/qemu/include -pthread
-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-g  -Wl,--warn-common -m64 -static -g   -o qemu-system-i386
../aio-posix.o [.o list elided] translate-all.o xen-stub.o
../libqemuutil.a ../libqemustub.a  -lrt -pthread -lgthread-2.0
-lglib-2.0 -lrt -lpcre     -lm -lutil -lbluetooth   -lncurses -ltinfo
  -lvdeplug -luuid -lpng12 -lz -lm    -lz -laio -lfdt -lpixman-1
[usual complaints about glibc functions needing the libraries
at runtime for NSS stuff elided]
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-radial-gradient.o):
In function `radial_compute_color':
(.text+0x16f): undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-combine32.o):
In function `combine_soft_light_ca':
(.text+0xa1e7): undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-combine32.o):
In function `combine_soft_light_ca':
(.text+0xa25e): undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-combine32.o):
In function `combine_soft_light_ca':
(.text+0xa2cc): undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-combine32.o):
In function `combine_soft_light_u':
(.text+0xab46): undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpixman-1.a(pixman-combine32.o):(.text+0xabfc):
more undefined references to `sqrt' follow
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-i386] Error 1
make[1]: Leaving directory
`/home/petmay01/linaro/qemu-from-laptop/qemu/i386-softmmu'
make: *** [subdir-i386-softmmu] Error 2

This is because we seem to have lost the trailing "-lm -lz"; here's
the tail end of the link command from a build on master for
comparison:

translate-all.o xen-stub.o ../libqemuutil.a ../libqemustub.a  -lrt
-pthread -lgthread-2.0 -lglib-2.0 -lrt -lpcre    -lutil -lbluetooth
-lncurses -ltinfo    -lvdeplug -luuid -lpng12 -lz -lm    -laio -lfdt
-lpixman-1    -lm -lz

thanks
-- PMM

Patch

diff --git a/Makefile.target b/Makefile.target
index 2bd6d14..c8513f1 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -119,7 +119,7 @@  obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o
 obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
 obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o
 obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o
-LIBS+=-lz
+LIBS+=$(libs_softmmu)
 
 # xen support
 obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
diff --git a/configure b/configure
index 629f70b..da0e8aa 100755
--- a/configure
+++ b/configure
@@ -1455,6 +1455,7 @@  EOF
         exit 1
     fi
 fi
+libs_softmmu="$libs_softmmu -lz"
 
 ##########################################
 # libseccomp check
@@ -3479,6 +3480,7 @@  echo "qemu_helperdir=$libexecdir" >> $config_host_mak
 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
+echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
 
 echo "ARCH=$ARCH" >> $config_host_mak
 
@@ -4192,7 +4194,7 @@  if test "$target_bigendian" = "yes" ; then
 fi
 if test "$target_softmmu" = "yes" ; then
   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
-  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
+  echo "LIBS+=$target_libs_softmmu" >> $config_target_mak
   case "$target_arch2" in
     i386|x86_64)
       echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak