]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix freestanding build (PR 92376)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Feb 2020 14:20:55 +0000 (14:20 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 26 Feb 2020 14:24:06 +0000 (14:24 +0000)
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.

Backport from mainline
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.

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/c++config
libstdc++-v3/libsupc++/new_opa.cc

index 19ae4cef9fa59266441eca335dcbad930bac1401..a94334f8ab166f30d7c665f474dc11ae08bd7916 100644 (file)
@@ -1,5 +1,14 @@
 2020-02-26  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       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.
+
        Backport from mainline
        2019-10-09  Jonathan Wakely  <jwakely@redhat.com>
 
index 7a7e78819ba7d27374b86282002b65fecb7df29f..7e0962edd1996c91943840ad564628a0d0bad571 100644 (file)
@@ -668,6 +668,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 104
 // #define PSTL_VERSION_MAJOR (PSTL_VERSION/100)
@@ -686,6 +688,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.
index 8143c129bc62e7464117f4838a74639cd13db63f..9c7f53d7073c8679790a981e3c0abb039c2abff8 100644 (file)
@@ -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;