]> git.proxmox.com Git - mirror_qemu.git/commitdiff
configure: Fix -lm test, so that tools can be compiled on hosts that require -lm
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Tue, 1 Jul 2014 07:30:27 +0000 (17:30 +1000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 1 Jul 2014 08:36:28 +0000 (10:36 +0200)
The existing test whether "-lm" needs to be included or not is
insufficient as it reports false negative on Fedora20/ppc64.
This happens because sin(0.0) is a constant value which compiler
can safely throw away and therefore there is no need to add "-lm".
As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

This adds a global variable and uses it in the test to prevent
from optimization.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[Use Peter's improvement on the test to fool LTO, and remove the
 now useless -lm addition in Makefile.target. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile.target
configure

index 6089d290dfb31c278c4dd7f887c945e60935f916..137d0b05176a25a1b178fce15452dd0d3bcf12b9 100644 (file)
@@ -163,10 +163,6 @@ dummy := $(call unnest-vars,.., \
 all-obj-y += $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
-ifndef CONFIG_HAIKU
-LIBS+=-lm
-endif
-
 # build either PROG or PROGW
 $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
        $(call LINK,$^)
index 23ecb37c43511e32e7081fc03319d253716bba47..ed41eda4d3fc2a5294f7453c56b99bc3f031a7e5 100755 (executable)
--- a/configure
+++ b/configure
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat > $TMPC << EOF
 #include <math.h>
-int main(void) { return isnan(sin(0.0)); }
+int main(int argc, char **argv) { return isnan(sin((double)argc)); }
 EOF
 if compile_prog "" "" ; then
   :