Received: from eggs.gnu.org ([2001:4830:134:3::10]:44707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2EZB-0000m7-Cc for qemu-devel@nongnu.org; Wed, 02 Jul 2014 03:02:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2EZ6-0007gy-K2 for qemu-devel@nongnu.org; Wed, 02 Jul 2014 03:02:53 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:201:233:1::3]:43953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2EZ6-0007gu-DM for qemu-devel@nongnu.org; Wed, 02 Jul 2014 03:02:48 -0400 From: Markus Armbruster References: <1404202956-30657-1-git-send-email-pbonzini@redhat.com> <1404202956-30657-4-git-send-email-pbonzini@redhat.com> Date: Wed, 02 Jul 2014 09:02:45 +0200 In-Reply-To: (Peter Maydell's message of "Tue, 1 Jul 2014 09:26:47 +0100") Message-ID: <87y4wcjl9m.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can be compiled on hosts that require -lm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Alexey Kardashevskiy , Paolo Bonzini , QEMU Developers Peter Maydell writes: > On 1 July 2014 09:22, Paolo Bonzini wrote: >> From: Alexey Kardashevskiy >> >> 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 >> -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. x *is* initialized, to zero. A sufficiently smart compiler(TM) could figure out that x is still zero in main(), and constant fold the test away. Suggest to use argc.