On Thu, Mar 05, 2015 at 12:48:42PM +0100, Martin Lucina wrote:
> [adding -lm to endfile in specs]
> > > How is it needed?  Why isn't pixman linking the lib in?  In other words,
> > > what's the error without this patch?
> > 
> > Not I check again, for some reason libm is not listed in LDLIBS. I think
> > it belongs there?
> > 
> > The error is when linking QEMU, there are some undefined references
> > (IIRC sqrtf) in pixman (which is QEMU dependency).
> 
> sqrtf (and indeed any of the math functions) are explicitly documented as
> "link with -lm". 
> 
> I ran into similar issues when linking mysqld. What I think is happening
> here is developer laziness when things "just work" on Linux (e.g.  due to
> GCC substituting the calls for builtins, or the C++ toolchain always
> linking with -lm).
> 
> In the case of mysqld I "fixed" the problem by doing what the Linux
> C++ toolchain does and always link with -lm. However, I'm not convinced
> that is the right thing to do for the C toolchain.
> 
> Can you verify that a Linux build of qemu does not explicitly add -lm when
> linking qemu?
> 

Here is the error message if I don't have -lm:

 LINK  i386-softmmu/qemu-system-i386
 
/local/scratch/Rump-kernels/rumpuser-xen/platform/xen/rump/lib/librumpnet.a(net_stub.o):
 warning: multiple common of `rumpns_ifnet_list'
 
/local/scratch/Rump-kernels/rumpuser-xen/platform/xen/rump/lib/librumpnet_net.a(if.o):
 warning: previous common is here
 /local/scratch/Rump-kernels/prefix/lib/libpixman-1.a(pixman-radial-gradient.o):
 In function `radial_compute_color':
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-radial-gradient.c:124:
 undefined reference to `sqrt'
 /local/scratch/Rump-kernels/prefix/lib/libpixman-1.a(pixman-combine32.o):
 In function `blend_soft_light':
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine32.c:869:
 undefined reference to `sqrt'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine32.c:869:
 undefined reference to `sqrt'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine32.c:869:
 undefined reference to `sqrt'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine32.c:869:
 undefined reference to `sqrt'
 
/local/scratch/Rump-kernels/prefix/lib/libpixman-1.a(pixman-combine32.o):/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine32.c:869:
 more undefined references to `sqrt' follow
 /local/scratch/Rump-kernels/prefix/lib/libpixman-1.a(pixman-combine-float.o):
 In function `blend_soft_light':
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 undefined reference to `sqrtf'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 undefined reference to `sqrtf'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 undefined reference to `sqrtf'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 undefined reference to `sqrtf'
 
/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 undefined reference to `sqrtf'
 
/local/scratch/Rump-kernels/prefix/lib/libpixman-1.a(pixman-combine-float.o):/local/scratch/Rump-kernels/rump-build-script-junk/pixman-0.32.6/pixman/pixman-combine-float.c:459:
 more undefined references to `sqrtf' follow
 collect2: error: ld returned 1 exit status

And an excerpt form the actual rune:

  -lz -lm -pthread -L/local/scratch/Rump-kernels/prefix/lib -lgthread-2.0
  -lglib-2.0 -lintl    -lz -L/local/scratch/Rump-kernels/prefix/lib
  -lpixman-1   -lutil

Strictly speaking, QEMU does have -lm specified. However due to the
ordering of ld rune, -lm goes before -lpixman-1, so pixman cannot find the
symbols in libm.

I think pixman should be linked against libm when building. So I now
have a patch like this:

diff --git a/platform/xen/Makefile b/platform/xen/Makefile
index e9c8f11..0b9496d 100644
--- a/platform/xen/Makefile
+++ b/platform/xen/Makefile
@@ -35,7 +35,7 @@ RUMP_LIBS_NET+= -lrumpnet_net -lrumpxen_xendev -lrumpnet

 # Define some default flags for linking.
 RUMP_LDLIBS = --whole-archive ${RUMP_LIBS_FS} ${RUMP_LIBS_NET} 
${RUMP_LIBS_PCI} ${RUMP_LI
-RUMP_LDLIBS := ${RUMP_LDLIBS} -lpthread -lc
+RUMP_LDLIBS := ${RUMP_LDLIBS} -lpthread -lc -lm


> Martin

Reply via email to