Skip to contentSkip to conversation

makefile: Fix tools compile

PATCH Applied Alexey Kardashevskiy 2 participants 4 messages Jul 1, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 makefile: Fix tools compile

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.

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is used instead

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 23ecb37..6dd44a9 100755
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat > $TMPC << EOF
 #include <math.h>
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog "" "" ; then
   :
Signature · 1 line
2.0.0
#1 lore raw

Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:

Quoted 26 lines

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.

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is used instead

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 23ecb37..6dd44a9 100755

configure fi · line 3459

Quoted 8 lines
configure +1 -1
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat > $TMPC << EOF
 #include <math.h>
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog "" "" ; then
   :

Can you please test with this hunk on top:

Makefile.target +0 -4
index 6089d29..137d0b0 100644
@@ -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,$^)

It should now be unnecessary.

Paolo

#2 lore raw
Quoted 54 lines · Paolo Bonzini

Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:

Quoted 26 lines

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.

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is used instead

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 23ecb37..6dd44a9 100755

configure fi · line 3459

Quoted 8 lines
configure +1 -1
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat > $TMPC << EOF
 #include <math.h>
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog "" "" ; then
   :

Can you please test with this hunk on top:

Makefile.target +0 -4
index 6089d29..137d0b0 100644
@@ -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,$^)
Quoted 1 line

It should now be unnecessary.

Tried, all good.

Signature · 1 line
Alexey
#3 lore raw

Il 01/07/2014 09:47, Alexey Kardashevskiy ha scritto:

Quoted 55 lines · Paolo Bonzini
Quoted 54 lines

Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:

Quoted 26 lines

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.

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is used instead

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 23ecb37..6dd44a9 100755

configure fi · line 3459

Quoted 8 lines
configure +1 -1
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat > $TMPC << EOF
 #include <math.h>
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog "" "" ; then
   :

Can you please test with this hunk on top:

Makefile.target +0 -4
index 6089d29..137d0b0 100644
@@ -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,$^)
Quoted 4 lines
Quoted 1 line

It should now be unnecessary.

Tried, all good.

Thanks, applied to scsi-next.

Paolo