public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-9-branch)] libstdc++: Fix freestanding build (PR 92376)
@ 2020-03-17 19:15 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-03-17 19:15 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:1b522a79133037f04c8ffcdfbe6c885ccb3ddcd3

commit 1b522a79133037f04c8ffcdfbe6c885ccb3ddcd3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 26 14:20:55 2020 +0000

    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.
    
    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.

Diff:
---
 libstdc++-v3/ChangeLog              |  9 +++++++++
 libstdc++-v3/include/bits/c++config |  5 ++++-
 libstdc++-v3/libsupc++/new_opa.cc   | 15 +++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 19ae4cef9fa..a94334f8ab1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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>
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 7a7e78819ba..7e0962edd19 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -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.
diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
index 8143c129bc6..9c7f53d7073 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-17 19:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 19:15 [gcc(refs/vendors/redhat/heads/gcc-9-branch)] libstdc++: Fix freestanding build (PR 92376) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).