Message ID | AM4PR0701MB2162A9E9F378D3BF2D9BE6E6E48C0@AM4PR0701MB2162.eurprd07.prod.outlook.com |
---|---|
State | New |
Headers | show |
On 30/11/16 19:00 +0000, Bernd Edlinger wrote: >Hi, > >I noticed that a cross-compiler produces an unusable libstdc++.so >that contains an unresolved reference to aligned_alloc instead of >posix_memalign, or whatever is actually available. > >Therefore it is impossible to link any C++ programs against the >libstdc++.so that comes with the cross-compiler. > >That happens for instance in the following configuration: >--target=arm-linux-gnueabihf. > >The attached patch adds a link test for the memalign function >and fixes the cross-build for me. > >Is it OK for trunk? OK. Presumably we should have this for other cross targets too.
On 30 November 2016 at 20:00, Bernd Edlinger <bernd.edlinger@hotmail.de> wrote: > Hi, > > I noticed that a cross-compiler produces an unusable libstdc++.so > that contains an unresolved reference to aligned_alloc instead of > posix_memalign, or whatever is actually available. > > Therefore it is impossible to link any C++ programs against the > libstdc++.so that comes with the cross-compiler. > > That happens for instance in the following configuration: > --target=arm-linux-gnueabihf. > How could this be unnoticed so far? > The attached patch adds a link test for the memalign function > and fixes the cross-build for me. > > Is it OK for trunk? > > > Thanks > Bernd.
On 30/11/16 22:32 +0100, Christophe Lyon wrote: >On 30 November 2016 at 20:00, Bernd Edlinger <bernd.edlinger@hotmail.de> wrote: >> Hi, >> >> I noticed that a cross-compiler produces an unusable libstdc++.so >> that contains an unresolved reference to aligned_alloc instead of >> posix_memalign, or whatever is actually available. >> >> Therefore it is impossible to link any C++ programs against the >> libstdc++.so that comes with the cross-compiler. >> >> That happens for instance in the following configuration: >> --target=arm-linux-gnueabihf. >> > >How could this be unnoticed so far? I did wonder that. The newlib config is hardcoded, which probably covers a lot of the cross builds in regular use. >> The attached patch adds a link test for the memalign function >> and fixes the cross-build for me. >> >> Is it OK for trunk? >> >> >> Thanks >> Bernd.
On 30 November 2016 at 22:51, Jonathan Wakely <jwakely@redhat.com> wrote: > On 30/11/16 22:32 +0100, Christophe Lyon wrote: >> >> On 30 November 2016 at 20:00, Bernd Edlinger <bernd.edlinger@hotmail.de> >> wrote: >>> >>> Hi, >>> >>> I noticed that a cross-compiler produces an unusable libstdc++.so >>> that contains an unresolved reference to aligned_alloc instead of >>> posix_memalign, or whatever is actually available. >>> >>> Therefore it is impossible to link any C++ programs against the >>> libstdc++.so that comes with the cross-compiler. >>> >>> That happens for instance in the following configuration: >>> --target=arm-linux-gnueabihf. >>> >> >> How could this be unnoticed so far? > > > I did wonder that. > > The newlib config is hardcoded, which probably covers a lot of the > cross builds in regular use. > The config mentioned by Bernd (arm-linux-gnueabihf) does not use newlib. I checked my libstdc++.log files, there's no -static option in use, I don't use --disable-shared, so I'm not sure why there's a problem? > >>> The attached patch adds a link test for the memalign function >>> and fixes the cross-build for me. >>> >>> Is it OK for trunk? >>> >>> >>> Thanks >>> Bernd.
On 30/11/16 23:06 +0100, Christophe Lyon wrote: >On 30 November 2016 at 22:51, Jonathan Wakely <jwakely@redhat.com> wrote: >> On 30/11/16 22:32 +0100, Christophe Lyon wrote: >>> >>> On 30 November 2016 at 20:00, Bernd Edlinger <bernd.edlinger@hotmail.de> >>> wrote: >>>> >>>> Hi, >>>> >>>> I noticed that a cross-compiler produces an unusable libstdc++.so >>>> that contains an unresolved reference to aligned_alloc instead of >>>> posix_memalign, or whatever is actually available. >>>> >>>> Therefore it is impossible to link any C++ programs against the >>>> libstdc++.so that comes with the cross-compiler. >>>> >>>> That happens for instance in the following configuration: >>>> --target=arm-linux-gnueabihf. >>>> >>> >>> How could this be unnoticed so far? >> >> >> I did wonder that. >> >> The newlib config is hardcoded, which probably covers a lot of the >> cross builds in regular use. >> >The config mentioned by Bernd (arm-linux-gnueabihf) does not use newlib. >I checked my libstdc++.log files, there's no -static option in use, I don't >use --disable-shared, so I'm not sure why there's a problem? Then you probably have a newer glibc that defines aligned_alloc, and Bernd is using an older one that doesn't define it. Bernd?
On 12/01/16 00:10, Jonathan Wakely wrote: > On 30/11/16 23:06 +0100, Christophe Lyon wrote: >> On 30 November 2016 at 22:51, Jonathan Wakely <jwakely@redhat.com> wrote: >>> On 30/11/16 22:32 +0100, Christophe Lyon wrote: >>>> >>>> On 30 November 2016 at 20:00, Bernd Edlinger >>>> <bernd.edlinger@hotmail.de> >>>> wrote: >>>>> >>>>> Hi, >>>>> >>>>> I noticed that a cross-compiler produces an unusable libstdc++.so >>>>> that contains an unresolved reference to aligned_alloc instead of >>>>> posix_memalign, or whatever is actually available. >>>>> >>>>> Therefore it is impossible to link any C++ programs against the >>>>> libstdc++.so that comes with the cross-compiler. >>>>> >>>>> That happens for instance in the following configuration: >>>>> --target=arm-linux-gnueabihf. >>>>> >>>> >>>> How could this be unnoticed so far? >>> >>> >>> I did wonder that. >>> >>> The newlib config is hardcoded, which probably covers a lot of the >>> cross builds in regular use. >>> >> The config mentioned by Bernd (arm-linux-gnueabihf) does not use newlib. >> I checked my libstdc++.log files, there's no -static option in use, I >> don't >> use --disable-shared, so I'm not sure why there's a problem? > > Then you probably have a newer glibc that defines aligned_alloc, and > Bernd is using an older one that doesn't define it. Bernd? > Yes. It is from 2011, glibc-2.15 as it looks like. I never had any issues with that, because it is supposed to be upward compatible with newer glibc, I did update the glibc on the target system recently to glibc-2.23, though, and had not noticed any issues, before. Thanks Bernd.
On 1 December 2016 at 01:18, Bernd Edlinger <bernd.edlinger@hotmail.de> wrote: > On 12/01/16 00:10, Jonathan Wakely wrote: >> On 30/11/16 23:06 +0100, Christophe Lyon wrote: >>> On 30 November 2016 at 22:51, Jonathan Wakely <jwakely@redhat.com> wrote: >>>> On 30/11/16 22:32 +0100, Christophe Lyon wrote: >>>>> >>>>> On 30 November 2016 at 20:00, Bernd Edlinger >>>>> <bernd.edlinger@hotmail.de> >>>>> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> I noticed that a cross-compiler produces an unusable libstdc++.so >>>>>> that contains an unresolved reference to aligned_alloc instead of >>>>>> posix_memalign, or whatever is actually available. >>>>>> >>>>>> Therefore it is impossible to link any C++ programs against the >>>>>> libstdc++.so that comes with the cross-compiler. >>>>>> >>>>>> That happens for instance in the following configuration: >>>>>> --target=arm-linux-gnueabihf. >>>>>> >>>>> >>>>> How could this be unnoticed so far? >>>> >>>> >>>> I did wonder that. >>>> >>>> The newlib config is hardcoded, which probably covers a lot of the >>>> cross builds in regular use. >>>> >>> The config mentioned by Bernd (arm-linux-gnueabihf) does not use newlib. >>> I checked my libstdc++.log files, there's no -static option in use, I >>> don't >>> use --disable-shared, so I'm not sure why there's a problem? >> >> Then you probably have a newer glibc that defines aligned_alloc, and >> Bernd is using an older one that doesn't define it. Bernd? >> > > Yes. > > It is from 2011, glibc-2.15 as it looks like. > > I never had any issues with that, because it is supposed to be upward > compatible with newer glibc, I did update the glibc on the target > system recently to glibc-2.23, though, and had not noticed any issues, > before. > OK, it makes sense: I'm using glibc-2.20. > > Thanks > Bernd.
2016-11-30 Bernd Edlinger <bernd.edlinger@hotmail.de> * crossconfig.m4 (*-linux*): Add link-check for memalign. * configure: Regenerated. Index: libstdc++-v3/configure =================================================================== --- libstdc++-v3/configure (revision 242960) +++ libstdc++-v3/configure (working copy) @@ -59826,11 +59826,24 @@ _ACEOF 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 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : Index: libstdc++-v3/crossconfig.m4 =================================================================== --- libstdc++-v3/crossconfig.m4 (revision 242960) +++ libstdc++-v3/crossconfig.m4 (working copy) @@ -157,6 +157,7 @@ case "${host}" in AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1) GCC_CHECK_TLS AC_CHECK_FUNCS(__cxa_thread_atexit_impl) + AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) AM_ICONV ;; *-mingw32*)