qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	QEMU Developers <qemu-devel@nongnu.org>
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	[thread overview]
Message-ID: <53B2EF4E.4050005@redhat.com> (raw)
In-Reply-To: <CAFEAcA8oZBAgM-yfB0BYFSASv9bnXqCkXkXGYQz9zCG8vxJr6w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

On 07/01/2014 02:26 AM, Peter Maydell wrote:
> On 1 July 2014 09:22, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> From: Alexey Kardashevskiy <aik@ozlabs.ru>
>>
>> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-07-01 17:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01  8:22 [Qemu-devel] [PULL for-2.1 0/3] virtio-scsi fixes, and block/iscsi compilation fix Paolo Bonzini
2014-07-01  8:22 ` [Qemu-devel] [PULL 1/3] virtio-scsi: virtio_scsi_push_event() lacks VirtIOSCSIReq parsing Paolo Bonzini
2014-07-01  8:22 ` [Qemu-devel] [PULL 2/3] virtio-scsi: scsi events must be converted to target endianness Paolo Bonzini
2014-07-01  8:22 ` [Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can be compiled on hosts that require -lm Paolo Bonzini
2014-07-01  8:26   ` Peter Maydell
2014-07-01 17:26     ` Eric Blake [this message]
2014-07-02  7:02     ` Markus Armbruster
2014-07-02  9:40       ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53B2EF4E.4050005@redhat.com \
    --to=eblake@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).