[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can b
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can be compiled on hosts that require -lm |
Date: |
Tue, 01 Jul 2014 11:26:38 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
On 07/01/2014 02:26 AM, Peter Maydell wrote:
> On 1 July 2014 09:22, Paolo Bonzini <address@hidden> wrote:
>> From: Alexey Kardashevskiy <address@hidden>
>>
>> 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.
>
>> --- 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)); }
>> +double x; int main(void) {return isnan(sin(x));}
>> EOF
>> if compile_prog "" "" ; then
>> :
>
> This looks to me like we're leaving ourselves open for
> a smarter compiler with linktime optimisation to complain
> that x is used uninitialized.
If that's your worry, what about:
int main(int argc, char **argv) { return isnan(sin(argc > 1)); }
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature