Re: Cross compilation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



В Пт, 10/11/2017 в 23:03 +0000, Jonathan Wakely пишет:
> On 10 November 2017 at 21:09, Kai Ruottu <kai.ruottu@xxxxxxxxxxx>
> wrote:
> > Kai Ruottu kirjoitti 10.11.2017 klo 18:14:
> > > 
> > > Kai Ruottu kirjoitti 10.11.2017 klo 11:21:
> > > > 
> > > > RAVI DEWANGAN kirjoitti 10.11.2017 klo 4:56:
> > > > > 
> > > > > Hi GNU Team,
> > > > > 
> > > > > Could you please guide me regarding cross compilation.
> > > > > 
> > > > > I am trying to cross compile the toolchain for
> > > > > FreeBSD11(target) using
> > > > > Ubuntu16.04(host).
> > > > > 
> > > 
> > > ../../../../libstdc++-v3/libsupc++/new_opa.cc: In function 'void*
> > > aligned_alloc(std::size_t, std::size_t)':
> > > ../../../../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
> > > /home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-
> > > v3/include/cstdlib:75:0,
> > >                  from
> > > /home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-
> > > v3/include/stdlib.h:36,
> > >                  from ../../../../libstdc++-
> > > v3/libsupc++/new_opa.cc:27:
> > > /home/src-old/gcc-7.2.0/build/gcc/include-fixed/stdlib.h:178:8:
> > > note:
> > > previous declaration of 'void* aligned_alloc(size_t, size_t)'
> > >  void * aligned_alloc(size_t, size_t) __malloc_like
> > > __alloc_align(1)
> > >         ^~~~~~~~~~~~~
> > > make[4]: *** [new_opa.lo] Virhe 1
> > > make[4]: Poistutaan hakemistosta
> > > "/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-
> > > v3/libsupc++"
> > > make[3]: *** [all-recursive] Virhe 1
> > > 
> > > Seemingly the same problem was with the x86_64-freebsd10.1 target
> > > which I
> > > tried first after updating the
> > > earlier gcc-4.9.2 to gcc-4.9.3 with it. No problems in that
> > > build. Will
> > > check the FreeBSD 11.1 with gcc-4.9.3
> > > too...
> > 
> > 
> > Yes, just the same error came with gcc-7.2.0 sources and FreeBSD
> > 10.1
> > target. But builds with gcc-4.9.3,
> > gcc-5.3.0 and gcc-6.3.0 sources worked OK for FreeBSD 11.1 target.
> > Unfortunately my C++ skills are rusty so
> > I cannot tell what to fix in this issue with gcc-7.2.0 :(
> 
> No C++ is needed. That function is only declared when #if
> !_GLIBCXX_HAVE_ALIGNED_ALLOC
> 
> Why does autoconf test say that FreeBSD doesn't have aligned_alloc,
> if
> it does have it?
> 
> The test is done by:
> 
>   AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign
> _aligned_malloc)
> 
> Maybe that test checks for the function using -std=c++98, so the C11
> function isn't defined? Check the config.log to see what happened
> when
> testing for that function.
> 
> If FreeBSD defines it, we need to detect that, and use the FreeBSD
> version, not the static version defined in new_opa.cc
> 
> (It's possible FreeBSD has always defined it, but only GCC 7.2 gives
> an error for the mismatched static/extern, but that isn't really
> important -- either way we should use the OS version if it exists)

I encountered the same error when trying to cross compile GCC 7.3.0 for
FreeBSD. The autoconf check for aligned_alloc function doesn't exist
for FreeBSD target in libstdc++-v3/crossconfig.m4. When I added this
check I could successfully compile GCC targeting FreeBSD 9.3. See my
patch below.

--- a/libstdc++-v3/crossconfig.m4       2018-02-12 19:54:24.323673272
+0300
+++ b/libstdc++-v3/crossconfig.m4       2018-02-12 19:53:33.826632457
+0300
@@ -133,6 +133,7 @@
       AC_DEFINE(HAVE_ISNANL)
     fi
     AC_CHECK_FUNCS(__cxa_thread_atexit)
+    AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign
_aligned_malloc)
     ;;
 
   *-fuchsia*)
--- a/libstdc++-v3/configure    2017-06-21 11:55:52.630537000 +0300
+++ b/libstdc++-v3/configure    2018-02-12 21:18:38.153731777 +0300
@@ -53327,6 +53327,19 @@
 fi
 done
 
+    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
+
     ;;
 
   *-fuchsia*)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux