aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-01-17 15:49:02 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-01-17 17:03:46 +0000
commit0ba6a850b597236832140bf57bf6083b6fab93f9 (patch)
tree5f6a89250fe3f2047c80343a21ee9091b5778049
parent2c2e9f7a5d4b5db97f268ae247b3a82b1610a543 (diff)
downloadgcc-0ba6a850b597236832140bf57bf6083b6fab93f9.zip
gcc-0ba6a850b597236832140bf57bf6083b6fab93f9.tar.gz
gcc-0ba6a850b597236832140bf57bf6083b6fab93f9.tar.bz2
libstdc++: Fix freestanding build PR 92376)
In a freestanding library we don't install the <pstl/pstl_config.h> header, so don't try to include it unless it exists. Explicitly declare aligned alloc functions for freestanding, because <cstdlib> doesn't declare them. PR libstdc++/92376 * include/bits/c++config: Only do PSTL config when the header is present, to fix freestanding. * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation functions if they were detected by configure.
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/c++config5
-rw-r--r--libstdc++-v3/libsupc++/new_opa.cc15
3 files changed, 27 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c37d3b1..f0d3b1c 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2020-01-17 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/92376
+ * include/bits/c++config: Only do PSTL config when the header is
+ present, to fix freestanding.
+ * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation
+ functions if they were detected by configure.
+
2020-01-16 Kai-Uwe Eckhardt <kuehro@gmx.de>
Matthew Bauer <mjbauer95@gmail.com>
Jonathan Wakely <jwakely@redhat.com>
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 875a5e7..b1fad59 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -666,6 +666,8 @@ namespace std
// PSTL configuration
#if __cplusplus >= 201703L
+// This header is not installed for freestanding:
+#if __has_include(<pstl/pstl_config.h>)
// Preserved here so we have some idea which version of upstream we've pulled in
// #define PSTL_VERSION 9000
@@ -684,6 +686,7 @@ namespace std
# define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition)
#include <pstl/pstl_config.h>
+#endif // __has_include
+#endif // C++17
-#endif
// End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
index 4e36fbf..8fac193 100644
--- a/libstdc++-v3/libsupc++/new_opa.cc
+++ b/libstdc++-v3/libsupc++/new_opa.cc
@@ -43,6 +43,21 @@ extern "C" void *memalign(std::size_t boundary, std::size_t size);
using std::new_handler;
using std::bad_alloc;
+#if ! _GLIBCXX_HOSTED
+extern "C"
+{
+# if _GLIBCXX_HAVE_ALIGNED_ALLOC
+ void *aligned_alloc(size_t alignment, size_t size);
+# elif _GLIBCXX_HAVE__ALIGNED_MALLOC
+ void *_aligned_malloc(size_t size, size_t alignment);
+# elif _GLIBCXX_HAVE_POSIX_MEMALIGN
+ void *posix_memalign(void **, size_t alignment, size_t size);
+# elif _GLIBCXX_HAVE_MEMALIGN
+ void *memalign(size_t alignment, size_t size);
+# endif
+}
+#endif
+
namespace __gnu_cxx {
#if _GLIBCXX_HAVE_ALIGNED_ALLOC
using ::aligned_alloc;