This could be better achieved by rewriting the libstdc++-v3/configure file
to fail the test for _FILE_OFFSET_BITS = 64 when fpos is not defined.
But this is kind of an odd spot to be, as this is an oddity from those
specific conditions on Bionic and I don't know if it's worth devising a
universal test for that.

I don't know if android/bionic patches are still relevant for the
community, but I still build recent versions of GCC with NDK r17c for some
old embedded devices, so I felt like sharing.

Em ter., 13 de jul. de 2021 às 00:16, Abraão de Santana <
abraaocsant...@gmail.com> escreveu:

> If C++ is enabled with Bionic on API Level < 24 ( and with NDK >= r15 as
> lower versions just ignore the issue ) you get errors of ::fgetpos and
> ::fsetpos error: 'fsetpos' has not been declared in '::' .
>
> The issue is that API Level < 24 doesn't implement large files (64 bit),
> so when _FILE_OFFSET_BITS is 64 and API Level < 24, the functions fgetpos,
> fsetpos, fseeko, and ftello are not defined.
>
> The behavior described above can be observed by going to
> 'android-ndk-rxxx/sysroot/usr/include/stdio.h' and watching the condition
> when those symbols are defined ( note: the control define
> __USE_FILE_OFFSET64 is defined if _FILE_OFFSET_BITS if 64)
>
> It's a known issue and bionic's docs ask you to stop defining
> _FILE_OFFSET_BITS to 64 to solve it:
> https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
>
> Clang builds seem to get around this using libandroid_support on those
> cases ( android/ndk#480 ), which is not available when building the gnu std
> c++.
>
>
> libstdc++-v3/ChangeLog
>         * config/os/bionic/os_defines.h: Undefines _FILE_OFFSET_BITS when
> it's 64-bit and Api Level < 24
>
> ---
>  libstdc++-v3/config/os/bionic/os_defines.h | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/config/os/bionic/os_defines.h
> b/libstdc++-v3/config/os/bionic/os_defines.h
> index c534838aea3..27605fa8baa 100644
> --- a/libstdc++-v3/config/os/bionic/os_defines.h
> +++ b/libstdc++-v3/config/os/bionic/os_defines.h
> @@ -33,4 +33,16 @@
>  // System-specific #define, typedefs, corrections, etc, go here.  This
>  // file will come before all others.
>
> +// If _FILE_OFFSET_BITS is 64 and __ANDROID_API__ < 24, there will be
> +// errors of undefined fgetpos, fsetpos, fseeko, and ftello because their
> +//64-bit versions are only available from API Level 24 onwards.
> +//
> +// See https://github.com/android/ndk/issues/480
> +//
> +// See also
> +//
> https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
> +#if (_FILE_OFFSET_BITS == 64) && (__ANDROID_API__ < 24)
> +#undef _FILE_OFFSET_BITS
> +#endif
> +
>  #endif
>


-- 


*Abraão C. de Santana*

*Skype: * abraao.c.santana
*Mobile :* +55 (21) 9307-9868

Reply via email to