NetBSD Problem Report #54000
From gson@gson.org Fri Feb 22 08:40:10 2019
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1CB697A151
for <gnats-bugs@gnats.NetBSD.org>; Fri, 22 Feb 2019 08:40:10 +0000 (UTC)
Message-Id: <20190222084004.167F498A91B@guava.gson.org>
Date: Fri, 22 Feb 2019 10:40:04 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: FP tests failing on amd64 since gcc7 import
X-Send-Pr-Version: 3.95
>Number: 54000
>Category: port-amd64
>Synopsis: FP tests failing on amd64 since gcc7 import
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: port-amd64-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 22 08:45:00 +0000 2019
>Closed-Date: Thu Apr 25 12:49:31 +0000 2019
>Last-Modified: Thu Apr 25 12:49:31 +0000 2019
>Originator: Andreas Gustafsson
>Release: NetBSD-current
>Organization:
>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:
The following tests are failing on amd64 since the import of gcc 7:
lib/libc/gen/t_fpsetround/fpsetround_basic
lib/libm/t_fe_round/fe_nearbyint
lib/libm/t_fe_round/fe_round
They fail both under qemu and on real hardware, but not on i386.
For recent log output, see:
http://www.gson.org/netbsd/bugs/build/amd64-baremetal/2019/2019.02.21.14.56.23/test.html#lib_libc_gen_t_fpsetround_fpsetround_basic
http://www.gson.org/netbsd/bugs/build/amd64-baremetal/2019/2019.02.21.14.56.23/test.html#lib_libm_t_fe_round_fe_nearbyint
http://www.gson.org/netbsd/bugs/build/amd64-baremetal/2019/2019.02.21.14.56.23/test.html#lib_libm_t_fe_round_fe_round
http://releng.netbsd.org/b5reports/amd64/2019/2019.02.20.19.42.14/test.html#lib_libc_gen_t_fpsetround_fpsetround_basic
(etc)
>How-To-Repeat:
Run the ATF tests on amd64.
>Fix:
>Release-Note:
>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-amd64/54000: FP tests failing on amd64 since gcc7 import
Date: Fri, 22 Feb 2019 09:22:17 +0000
I built libm.so with some GCC versions:
GCC6 from pkgsrc: OK
GCC7 base: FAIL
GCC9 (snapshot): FAIL
It's sufficient to revert libm.so to get at least one of the failing
cases to succeed.
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-amd64/54000: FP tests failing on amd64 since gcc7 import
Date: Fri, 22 Feb 2019 09:38:45 +0000
The difference starts with s_nearbyint.o.
building this with GCC7 and -O0 also works.
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-amd64/54000: FP tests failing on amd64 since gcc7 import
Date: Fri, 22 Feb 2019 09:56:43 +0000
Also fixed by -fno-builtin-rint.
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-amd64/54000: FP tests failing on amd64 since gcc7 import
Date: Fri, 22 Feb 2019 16:38:47 +0000
--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Attached is a standalone test case (non-netbsd-specific)
#!/bin/sh
cat << EOF > round.c
#include <assert.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define INT 9223L
#define EPSILON 0.001
static const struct {
int round_mode;
double input;
long int expected;
} values[] = {
{ FE_DOWNWARD, -3.7, -4},
};
double my_nearbyint(double x)
{
double ret;
fenv_t env;
fegetenv(&env);
ret = rint(x);
fesetenv(&env);
return ret;
}
int main(void)
{
double received;
fesetround(values[0].round_mode);
received = my_nearbyint(values[0].input);
if (!(fabs(received - values[0].expected) < EPSILON))
printf("nearbyint rounding wrong, difference too large\n"
"input: %f (index %d): got %f, expected %ld\n",
values[0].input, 0, received, values[0].expected);
assert((fabs(received - values[0].expected) < EPSILON));
/* Do we get the same rounding mode out? */
if (!((fegetround() == values[0].round_mode)))
printf("Didn't get the same rounding mode out!\n"
"(index %d) fed in %d rounding mode, got %d out\n",
0, values[0].round_mode, fegetround());
assert((fegetround() == values[0].round_mode));
}
EOF
gcc -lm round.c -O2 -o round
echo "Executing regular -O2 build:"
./round
echo "returned " $?
gcc -lm round.c -O2 -fno-builtin-rint -o round2
echo "Executing -O2 -fno-builtin-rint build:"
./round2
echo "returned " $?
State-Changed-From-To: open->analyzed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Fri, 22 Feb 2019 18:00:20 +0000
State-Changed-Why:
Not really a bug. GCC defaults to -fno-rounding-math, we can get correct behaviour with -frounding-math.
From: Jason Thorpe <thorpej@me.com>
To: "gnats-bugs@netbsd.org" <gnats-bugs@NetBSD.org>
Cc: port-amd64-maintainer@netbsd.org,
netbsd-bugs@netbsd.org,
gnats-admin@netbsd.org,
"maya@netbsd.org" <maya@NetBSD.org>,
Andreas Gustafsson <gson@gson.org>
Subject: Re: port-amd64/54000 (FP tests failing on amd64 since gcc7 import)
Date: Fri, 22 Feb 2019 10:03:45 -0800
> On Feb 22, 2019, at 10:00 AM, maya@netbsd.org <maya@NetBSD.org> wrote:
>=20
> Synopsis: FP tests failing on amd64 since gcc7 import
>=20
> State-Changed-From-To: open->analyzed
> State-Changed-By: maya@NetBSD.org
> State-Changed-When: Fri, 22 Feb 2019 18:00:20 +0000
> State-Changed-Why:
> Not really a bug. GCC defaults to -fno-rounding-math, we can get =
correct behaviour with -frounding-math.
Is this a change in GCC=E2=80=99s default? If so, it seems like this is =
a binary compatibility issue and that we should switch the default back.
-- thorpej
From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54000 CVS commit: src/lib/libm
Date: Fri, 22 Feb 2019 18:17:23 +0000
Module Name: src
Committed By: maya
Date: Fri Feb 22 18:17:23 UTC 2019
Modified Files:
src/lib/libm: Makefile
Log Message:
Default our libm to -frounding-math, if built with GCC.
The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.
Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import
To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/lib/libm/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Andreas Gustafsson <gson@gson.org>
To: "Maya Rashish" <maya@netbsd.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: PR/54000 CVS commit: src/lib/libm
Date: Sat, 23 Feb 2019 12:58:44 +0200
Maya,
You wrote:
> Default our libm to -frounding-math, if built with GCC.
>
> The long-standing GCC default is to not respect rounding mode.
> it looks like GCC 7 optimizes rint to a builtin, causing our few
> rounding mode tests to fail.
>
> Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import
Thanks for working on this. Your commit seems to have fixed the
fe_nearbyint and fe_round tests, but the fpsetround_basic test is
still failing for me (on real amd64 hardware).
--
Andreas Gustafsson, gson@gson.org
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54000 CVS commit: src/tests/lib/libc/gen
Date: Wed, 24 Apr 2019 11:12:09 -0400
Module Name: src
Committed By: christos
Date: Wed Apr 24 15:12:09 UTC 2019
Modified Files:
src/tests/lib/libc/gen: Makefile
Log Message:
PR/54000: Andreag Gustafsson: Compile the rounding test with
-fround-math since with gcc-7, the default mode ignores fenv settings
(the same effect can be achieved with -O0 :-)
https://gcc.gnu.org/wiki/FloatingPointMath
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/tests/lib/libc/gen/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: analyzed->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Thu, 25 Apr 2019 12:49:31 +0000
State-Changed-Why:
Two of the failures were fixed by maya and the third by christos, thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.