On 10/09/16 11:25 +0200, Marc Glisse wrote:
On Sat, 10 Sep 2016, Christophe Lyon wrote:
On aarch64*-elf and arm-eabi (using newlib), I'm seeing:
/gccsrc/libstdc++-v3/libsupc++/new_opa.cc:66: undefined reference to
`aligned_alloc'
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=f86afe5a3ac62a92e821c764a011e1625abdd326
"C11 aligned_alloc() implementation
aligned_alloc() is implemented in terms of posix_memalign() which is
only declared in <stdlib.h> but not defined in Newlib in general. At
least Linux and RTEMS implement this function."
If we don't want to provide a fallback implementation in libsupc++, we
can say that aligned new is unsupported on those platforms, but if we
are building a shared libstdc++.so that doesn't like undefined
symbols, we need a different failure mode than an undefined
aligned_alloc. Either not providing operator new(...aligned_val_t...)
in libstdc++ or providing one that just aborts I guess?
Or always fails with bad_alloc:
--- a/libstdc++-v3/libsupc++/new_opa.cc
+++ b/libstdc++-v3/libsupc++/new_opa.cc
@@ -49,8 +49,11 @@ aligned_alloc (std::size_t al, std::size_t sz)
#define aligned_alloc memalign
#else
// The C library doesn't provide any aligned allocation functions, declare
-// aligned_alloc and get a link failure if aligned new is used.
-extern "C" void *aligned_alloc(std::size_t, std::size_t);
+// an aligned_alloc that always fails.
+static void *aligned_alloc(std::size_t, std::size_t)
+{
+ _GLIBCXX_THROW_OR_ABORT(bad_alloc());
+}
#endif
#endif
That would work unless/until we get a fallback.