aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-08-31 16:56:11 -0700
committerAndres Freund <andres@anarazel.de>2018-08-31 17:10:52 -0700
commit1f349aa7d9a6633e87db071390c73a39ac279ba4 (patch)
tree82c0a4e360c40bcb43baba89404ddfe6ce412ecd
parented9c336b0f6bcf08e7b6bbe7080fdb63640a680e (diff)
downloadpostgresql-1f349aa7d9a6633e87db071390c73a39ac279ba4.tar.gz
postgresql-1f349aa7d9a6633e87db071390c73a39ac279ba4.zip
Fix 8a934d677 for libc++ and make more include order resistant.
The previous definition was used in C++ mode, which causes problems when using clang with libc++ (rather than libstdc++), due to bugs therein. So just avoid in C++ mode. A second problem is that depending on include order and implicit includes the previous definition did not guarantee that the current hack was effective by the time isinf was used, fix that by forcing math.h to be included. This can cause clang using builds, or gcc using ones with JIT enabled, to slow down noticably. It's likely that we at some point want a better solution for the performance problem, but while it's there it should better work. Reported-By: Steven Winfield Bug: #15270 Discussion: https://postgr.es/m/153116283147.1401.360416241833049560@wrigleys.postgresql.org Author: Andres Freund Backpatch: 11, like the previous commit.
-rw-r--r--src/include/port.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/include/port.h b/src/include/port.h
index 74a9dc4d4d5..0ce72e50e5e 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -347,15 +347,18 @@ extern int isinf(double x);
/*
* Glibc doesn't use the builtin for clang due to a *gcc* bug in a version
* newer than the gcc compatibility clang claims to have. This would cause a
- * *lot* of superfluous function calls, therefore revert when using clang.
+ * *lot* of superfluous function calls, therefore revert when using clang. In
+ * C++ there's issues with libc++ (not libstdc++), so disable as well.
*/
-#ifdef __clang__
+#if defined(__clang__) && !defined(__cplusplus)
/* needs to be separate to not confuse other compilers */
#if __has_builtin(__builtin_isinf)
+/* need to include before, to avoid getting overwritten */
+#include <math.h>
#undef isinf
#define isinf __builtin_isinf
#endif /* __has_builtin(isinf) */
-#endif /* __clang__ */
+#endif /* __clang__ && !__cplusplus*/
#endif /* !HAVE_ISINF */
#ifndef HAVE_MKDTEMP