diff mbox series

PR target/85904: Fix configure when cross compiling for netbsd

Message ID 20180524131430.GA3511@SDF.ORG
State New
Headers show
Series PR target/85904: Fix configure when cross compiling for netbsd | expand

Commit Message

Maya Rashish May 24, 2018, 1:14 p.m. UTC
In the past I was asked to post bugzilla patches here. I am doing this.
It fixes a build failure.

PR target/85904
libstdc++-v3/crossconfig.m4: test for aligned_alloc on netbsd
libstdc++-v3/configure: Regenerate

Attached is patch.
From ac7a1f364b0ca5e3a6a5a68a16266d1cb78ee5da Mon Sep 17 00:00:00 2001
From: Maya Rashish <coypu@sdf.org>
Date: Thu, 24 May 2018 16:05:27 +0300
Subject: [PATCH 1/1] check for aligned_alloc on netbsd crosscompilation.

Fixes build issue:
/home/fly/gcc/libstdc++-v3/libsupc++/new_opa.cc:62:1: error: 'void* aligned_alloc(std::size_t, std::size_t)' was declared 'extern' and later 'static' [-fpermissive]
 aligned_alloc (std::size_t al, std::size_t sz)
 ^~~~~~~~~~~~~
In file included from /tmp/build/alpha--netbsd/libstdc++-v3/include/cstdlib:75,
                 from /tmp/build/alpha--netbsd/libstdc++-v3/include/stdlib.h:36,
                 from /home/fly/gcc/libstdc++-v3/libsupc++/new_opa.cc:27:
/tmp/build/gcc/include-fixed/stdlib.h:254:7: note: previous declaration of 'void* aligned_alloc(size_t, size_t)'
 void *aligned_alloc(size_t, size_t);
       ^~~~~~~~~~~~~
---
 libstdc++-v3/configure      | 13 +++++++++++++
 libstdc++-v3/crossconfig.m4 |  1 +
 2 files changed, 14 insertions(+)

Comments

Jonathan Wakely May 24, 2018, 3:14 p.m. UTC | #1
On 24/05/18 13:14 +0000, coypu@sdf.org wrote:
>In the past I was asked to post bugzilla patches here. I am doing this.
>It fixes a build failure.
>
>PR target/85904
>libstdc++-v3/crossconfig.m4: test for aligned_alloc on netbsd
>libstdc++-v3/configure: Regenerate
>
>Attached is patch.

Thanks for the patch. We made a similar fix for FreeBSD recently, so
I'll commit this for you.

I think this should be backported to all branches that detect
aligned_alloc for native compilers, to allow cross-compiling too.



>>From ac7a1f364b0ca5e3a6a5a68a16266d1cb78ee5da Mon Sep 17 00:00:00 2001
>From: Maya Rashish <coypu@sdf.org>
>Date: Thu, 24 May 2018 16:05:27 +0300
>Subject: [PATCH 1/1] check for aligned_alloc on netbsd crosscompilation.
>
>Fixes build issue:
>/home/fly/gcc/libstdc++-v3/libsupc++/new_opa.cc:62:1: error: 'void* aligned_alloc(std::size_t, std::size_t)' was declared 'extern' and later 'static' [-fpermissive]
> aligned_alloc (std::size_t al, std::size_t sz)
> ^~~~~~~~~~~~~
>In file included from /tmp/build/alpha--netbsd/libstdc++-v3/include/cstdlib:75,
>                 from /tmp/build/alpha--netbsd/libstdc++-v3/include/stdlib.h:36,
>                 from /home/fly/gcc/libstdc++-v3/libsupc++/new_opa.cc:27:
>/tmp/build/gcc/include-fixed/stdlib.h:254:7: note: previous declaration of 'void* aligned_alloc(size_t, size_t)'
> void *aligned_alloc(size_t, size_t);
>       ^~~~~~~~~~~~~
>---
> libstdc++-v3/configure      | 13 +++++++++++++
> libstdc++-v3/crossconfig.m4 |  1 +
> 2 files changed, 14 insertions(+)
>
>diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
>index f3522ee6666..9fd6197169a 100755
>--- a/libstdc++-v3/configure
>+++ b/libstdc++-v3/configure
>@@ -66150,6 +66150,19 @@ done
>     ;;
>   *-netbsd*)
>     SECTION_FLAGS='-ffunction-sections -fdata-sections'
>+    for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc
>+do :
>+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
>+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
>+eval as_val=\$$as_ac_var
>+   if test "x$as_val" = x""yes; then :
>+  cat >>confdefs.h <<_ACEOF
>+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
>+_ACEOF
>+
>+fi
>+done
>+
>
>
>   # If we're not using GNU ld, then there's no point in even trying these
>diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
>index f0a55c68404..dcc807eb76a 100644
>--- a/libstdc++-v3/crossconfig.m4
>+++ b/libstdc++-v3/crossconfig.m4
>@@ -203,6 +203,7 @@ case "${host}" in
>     ;;
>   *-netbsd*)
>     SECTION_FLAGS='-ffunction-sections -fdata-sections'
>+    AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
>     AC_SUBST(SECTION_FLAGS)
>     GLIBCXX_CHECK_LINKER_FEATURES
>     AC_DEFINE(HAVE_FINITEF)
>-- 
>2.17.0
>
Jonathan Wakely May 24, 2018, 5:31 p.m. UTC | #2
On 24/05/18 16:14 +0100, Jonathan Wakely wrote:
>On 24/05/18 13:14 +0000, coypu@sdf.org wrote:
>>In the past I was asked to post bugzilla patches here. I am doing this.
>>It fixes a build failure.
>>
>>PR target/85904
>>libstdc++-v3/crossconfig.m4: test for aligned_alloc on netbsd
>>libstdc++-v3/configure: Regenerate
>>
>>Attached is patch.
>
>Thanks for the patch. We made a similar fix for FreeBSD recently, so
>I'll commit this for you.

For consistency with freebsd and mingw what I committed to trunk has
the AC_CHECK_FUNCS at the end of the netbsd section. Could you check
it still works please? (I'm unable to build a netbsd cross-compiler
for some reason).
commit 56c5a530fd7b6813ccdb712c7d37d89fa59a80f7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 24 16:33:50 2018 +0100

    PR target/85904 check for aligned_alloc on netbsd cross-compilation
    
    2018-05-24  Maya Rashish  <coypu@sdf.org>
    
            PR target/85904
            * crossconfig.m4: Test for aligned_alloc on netbsd.
            * configure: Regenerate.

diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index f0a55c68404..669d87f7602 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -218,6 +218,7 @@ case "${host}" in
       AC_DEFINE(HAVE_ISINFL)
       AC_DEFINE(HAVE_ISNANL)
     fi
+    AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
     ;;
   *-qnx6.1* | *-qnx6.2*)
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
Maya Rashish May 24, 2018, 6:43 p.m. UTC | #3
On Thu, May 24, 2018 at 06:31:25PM +0100, Jonathan Wakely wrote:
> On 24/05/18 16:14 +0100, Jonathan Wakely wrote:
> > On 24/05/18 13:14 +0000, coypu@sdf.org wrote:
> > > In the past I was asked to post bugzilla patches here. I am doing this.
> > > It fixes a build failure.
> > > 
> > > PR target/85904
> > > libstdc++-v3/crossconfig.m4: test for aligned_alloc on netbsd
> > > libstdc++-v3/configure: Regenerate
> > > 
> > > Attached is patch.
> > 
> > Thanks for the patch. We made a similar fix for FreeBSD recently, so
> > I'll commit this for you.
> 
> For consistency with freebsd and mingw what I committed to trunk has
> the AC_CHECK_FUNCS at the end of the netbsd section. Could you check
> it still works please? (I'm unable to build a netbsd cross-compiler
> for some reason).

It works, thank you!
diff mbox series

Patch

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index f3522ee6666..9fd6197169a 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -66150,6 +66150,19 @@  done
     ;;
   *-netbsd*)
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
+    for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
 
 
   # If we're not using GNU ld, then there's no point in even trying these
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index f0a55c68404..dcc807eb76a 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -203,6 +203,7 @@  case "${host}" in
     ;;
   *-netbsd*)
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
+    AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
     AC_SUBST(SECTION_FLAGS) 
     GLIBCXX_CHECK_LINKER_FEATURES
     AC_DEFINE(HAVE_FINITEF)