Commit 28f3c814 by Ian Lance Taylor

math: adjust compilation flags, use them when testing

    
    We were using special compilation flags for the math package, but we
    weren't using them when testing.  That meant that our tests were not
    checking the real code we were providing.  Fix that.
    
    Fixing that revealed that we were not using a good set of flags, or at
    least were not using flags that let the tests pass.  Adjust the flags
    to stop using -funsafe-math-optimizations on x86.  Instead always use
    -ffp-contract=off -fno-math-errno -fno-trapping-math for all targets.
    
    Fixes golang/go#23647
    
    Reviewed-on: https://go-review.googlesource.com/91355

From-SVN: r257312
parent d15f0fa7
...@@ -1138,6 +1138,7 @@ $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))) ...@@ -1138,6 +1138,7 @@ $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package)))
# Pass -ffp-contract=off, or 386-specific options, when building the # Pass -ffp-contract=off, or 386-specific options, when building the
# math package. MATH_FLAG is defined in configure.ac. # math package. MATH_FLAG is defined in configure.ac.
math_lo_GOCFLAGS = $(MATH_FLAG) math_lo_GOCFLAGS = $(MATH_FLAG)
math_check_GOCFLAGS = $(MATH_FLAG)
# Add the generated file runtime_sysinfo.go to the runtime package. # Add the generated file runtime_sysinfo.go to the runtime package.
extra_go_files_runtime = runtime_sysinfo.go sigtab.go extra_go_files_runtime = runtime_sysinfo.go sigtab.go
......
...@@ -1175,6 +1175,7 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ ...@@ -1175,6 +1175,7 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \
# Pass -ffp-contract=off, or 386-specific options, when building the # Pass -ffp-contract=off, or 386-specific options, when building the
# math package. MATH_FLAG is defined in configure.ac. # math package. MATH_FLAG is defined in configure.ac.
math_lo_GOCFLAGS = $(MATH_FLAG) math_lo_GOCFLAGS = $(MATH_FLAG)
math_check_GOCFLAGS = $(MATH_FLAG)
# Add the generated file runtime_sysinfo.go to the runtime package. # Add the generated file runtime_sysinfo.go to the runtime package.
extra_go_files_runtime = runtime_sysinfo.go sigtab.go extra_go_files_runtime = runtime_sysinfo.go sigtab.go
......
...@@ -15076,10 +15076,9 @@ fi ...@@ -15076,10 +15076,9 @@ fi
$as_echo "$libgo_cv_c_fancymath" >&6; } $as_echo "$libgo_cv_c_fancymath" >&6; }
MATH_FLAG= MATH_FLAG=
if test "$libgo_cv_c_fancymath" = yes; then if test "$libgo_cv_c_fancymath" = yes; then
MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations -fno-math-errno" MATH_FLAG="-mfancy-math-387"
else
MATH_FLAG="-ffp-contract=off"
fi fi
MATH_FLAG="${MATH_FLAG} -ffp-contract=off -fno-math-errno -fno-trapping-math"
CFLAGS_hold=$CFLAGS CFLAGS_hold=$CFLAGS
......
...@@ -649,8 +649,7 @@ fi ...@@ -649,8 +649,7 @@ fi
AC_SUBST(STRINGOPS_FLAG) AC_SUBST(STRINGOPS_FLAG)
dnl For x86 we want to compile the math library with -mfancy-math-387 dnl For x86 we want to compile the math library with -mfancy-math-387
dnl -funsafe-math-optimizations so that we can use the builtin dnl so that we can use the builtin instructions directly.
dnl instructions directly.
AC_CACHE_CHECK([whether compiler supports -mfancy-math-387], AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
[libgo_cv_c_fancymath], [libgo_cv_c_fancymath],
[CFLAGS_hold=$CFLAGS [CFLAGS_hold=$CFLAGS
...@@ -661,10 +660,9 @@ AC_COMPILE_IFELSE([int i;], ...@@ -661,10 +660,9 @@ AC_COMPILE_IFELSE([int i;],
CFLAGS=$CFLAGS_hold]) CFLAGS=$CFLAGS_hold])
MATH_FLAG= MATH_FLAG=
if test "$libgo_cv_c_fancymath" = yes; then if test "$libgo_cv_c_fancymath" = yes; then
MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations -fno-math-errno" MATH_FLAG="-mfancy-math-387"
else
MATH_FLAG="-ffp-contract=off"
fi fi
MATH_FLAG="${MATH_FLAG} -ffp-contract=off -fno-math-errno -fno-trapping-math"
AC_SUBST(MATH_FLAG) AC_SUBST(MATH_FLAG)
CFLAGS_hold=$CFLAGS CFLAGS_hold=$CFLAGS
......
...@@ -128,7 +128,7 @@ var cbrt = []float64{ ...@@ -128,7 +128,7 @@ var cbrt = []float64{
var ceil = []float64{ var ceil = []float64{
5.0000000000000000e+00, 5.0000000000000000e+00,
8.0000000000000000e+00, 8.0000000000000000e+00,
0.0000000000000000e+00, Copysign(0, -1),
-5.0000000000000000e+00, -5.0000000000000000e+00,
1.0000000000000000e+01, 1.0000000000000000e+01,
3.0000000000000000e+00, 3.0000000000000000e+00,
...@@ -644,7 +644,7 @@ var tanh = []float64{ ...@@ -644,7 +644,7 @@ var tanh = []float64{
var trunc = []float64{ var trunc = []float64{
4.0000000000000000e+00, 4.0000000000000000e+00,
7.0000000000000000e+00, 7.0000000000000000e+00,
-0.0000000000000000e+00, Copysign(0, -1),
-5.0000000000000000e+00, -5.0000000000000000e+00,
9.0000000000000000e+00, 9.0000000000000000e+00,
2.0000000000000000e+00, 2.0000000000000000e+00,
...@@ -2134,7 +2134,7 @@ func TestCbrt(t *testing.T) { ...@@ -2134,7 +2134,7 @@ func TestCbrt(t *testing.T) {
func TestCeil(t *testing.T) { func TestCeil(t *testing.T) {
for i := 0; i < len(vf); i++ { for i := 0; i < len(vf); i++ {
if f := Ceil(vf[i]); ceil[i] != f { if f := Ceil(vf[i]); !alike(ceil[i], f) {
t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i]) t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
} }
} }
...@@ -2361,7 +2361,7 @@ func TestDim(t *testing.T) { ...@@ -2361,7 +2361,7 @@ func TestDim(t *testing.T) {
func TestFloor(t *testing.T) { func TestFloor(t *testing.T) {
for i := 0; i < len(vf); i++ { for i := 0; i < len(vf); i++ {
if f := Floor(vf[i]); floor[i] != f { if f := Floor(vf[i]); !alike(floor[i], f) {
t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i]) t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
} }
} }
...@@ -2884,7 +2884,7 @@ func TestTanh(t *testing.T) { ...@@ -2884,7 +2884,7 @@ func TestTanh(t *testing.T) {
func TestTrunc(t *testing.T) { func TestTrunc(t *testing.T) {
for i := 0; i < len(vf); i++ { for i := 0; i < len(vf); i++ {
if f := Trunc(vf[i]); trunc[i] != f { if f := Trunc(vf[i]); !alike(trunc[i], f) {
t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i]) t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment