mirror of
https://github.com/postgres/postgres.git
synced 2026-06-08 16:26:30 -04:00
Move -ffast-math defense to float.c and remove the configure check.
We had defenses against -ffast-math in timestamp-related files, which is a pretty obsolete place for them since we've not supported floating-point timestamps in a long time. Remove those and instead put one in float.c, which is still broken by using this switch. Add some commentary to put more color on why it's a bad idea. Also remove the check from configure. That was just there to fail faster, but it doesn't really seem necessary anymore, and besides we have no corresponding check in meson.build. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Suggested-by: Andres Freund <andres@anarazel.de> Suggested-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/abFXfKC8zR0Oclon%40ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
parent
c675d80d72
commit
82ff54377e
7 changed files with 17 additions and 53 deletions
23
configure
vendored
23
configure
vendored
|
|
@ -7700,29 +7700,6 @@ fi
|
|||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
# Defend against gcc -ffast-math
|
||||
if test "$GCC" = yes; then
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#ifdef __FAST_MATH__
|
||||
choke me
|
||||
#endif
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
|
||||
else
|
||||
as_fn_error $? "do not put -ffast-math in CFLAGS" "$LINENO" 5
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
|
||||
# Defend against clang being used on x86-32 without SSE2 enabled. As current
|
||||
# versions of clang do not understand -fexcess-precision=standard, the use of
|
||||
# x87 floating point operations leads to problems like isinf possibly returning
|
||||
|
|
|
|||
|
|
@ -786,13 +786,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
|
|||
[AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([cannot proceed])])
|
||||
|
||||
# Defend against gcc -ffast-math
|
||||
if test "$GCC" = yes; then
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifdef __FAST_MATH__
|
||||
choke me
|
||||
@%:@endif])], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
|
||||
fi
|
||||
|
||||
# Defend against clang being used on x86-32 without SSE2 enabled. As current
|
||||
# versions of clang do not understand -fexcess-precision=standard, the use of
|
||||
# x87 floating point operations leads to problems like isinf possibly returning
|
||||
|
|
|
|||
|
|
@ -38,14 +38,6 @@
|
|||
#include "utils/skipsupport.h"
|
||||
#include "utils/sortsupport.h"
|
||||
|
||||
/*
|
||||
* gcc's -ffast-math switch breaks routines that expect exact results from
|
||||
* expressions like timeval / SECS_PER_HOUR, where timeval is double.
|
||||
*/
|
||||
#ifdef __FAST_MATH__
|
||||
#error -ffast-math is known to break this code
|
||||
#endif
|
||||
|
||||
|
||||
/* common code for timetypmodin and timetztypmodin */
|
||||
static int32
|
||||
|
|
|
|||
|
|
@ -29,6 +29,23 @@
|
|||
#include "utils/sortsupport.h"
|
||||
|
||||
|
||||
/*
|
||||
* Reject building with gcc's -ffast-math switch. It breaks our handling of
|
||||
* float Infinity and NaN values (via -ffinite-math-only), causes results to
|
||||
* be less accurate than expected (via -funsafe-math-optimizations and
|
||||
* -fexcess-precision=fast), and causes some math error reports to be missed
|
||||
* (via -fno-math-errno). Unfortunately we can't easily detect cases where
|
||||
* those options were given individually, but this at least catches the most
|
||||
* obvious case.
|
||||
*
|
||||
* We test this only here, not in any header file, to allow extensions to use
|
||||
* -ffast-math if they need to. But the inline functions in float.h will
|
||||
* misbehave in such an extension, so its authors had better be careful.
|
||||
*/
|
||||
#ifdef __FAST_MATH__
|
||||
#error -ffast-math is known to break this code
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configurable GUC parameter
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,13 +40,6 @@
|
|||
#include "utils/skipsupport.h"
|
||||
#include "utils/sortsupport.h"
|
||||
|
||||
/*
|
||||
* gcc's -ffast-math switch breaks routines that expect exact results from
|
||||
* expressions like timeval / SECS_PER_HOUR, where timeval is double.
|
||||
*/
|
||||
#ifdef __FAST_MATH__
|
||||
#error -ffast-math is known to break this code
|
||||
#endif
|
||||
|
||||
/* Set at postmaster start */
|
||||
TimestampTz PgStartTime;
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@
|
|||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __FAST_MATH__
|
||||
#error -ffast-math is known to break this code
|
||||
#endif
|
||||
|
||||
#include "common/string.h"
|
||||
#include "dt.h"
|
||||
#include "pgtypes_error.h"
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __FAST_MATH__
|
||||
#error -ffast-math is known to break this code
|
||||
#endif
|
||||
|
||||
#include "common/int.h"
|
||||
#include "dt.h"
|
||||
#include "pgtypes_date.h"
|
||||
|
|
|
|||
Loading…
Reference in a new issue