public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [android] Disable large files when unsupported
@ 2021-07-13  3:16 Abraão de Santana
  2021-07-13  3:33 ` Abraão de Santana
  0 siblings, 1 reply; 6+ messages in thread
From: Abraão de Santana @ 2021-07-13  3:16 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [android] Disable large files when unsupported
  2021-07-13  3:16 [PATCH] [android] Disable large files when unsupported Abraão de Santana
@ 2021-07-13  3:33 ` Abraão de Santana
  0 siblings, 0 replies; 6+ messages in thread
From: Abraão de Santana @ 2021-07-13  3:33 UTC (permalink / raw)
  To: gcc-patches

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 <
abraaocsantana@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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [android] Disable large files when unsupported
  2021-07-15 18:43 ` Abraão de Santana
@ 2021-07-16  2:20   ` João Gabriel Jardim
  0 siblings, 0 replies; 6+ messages in thread
From: João Gabriel Jardim @ 2021-07-16  2:20 UTC (permalink / raw)
  To: Abraão de Santana; +Cc: gcc-patches

Hi Mr. Santana,

Some strange stuff happened with my previous comment. I've been struggling
with this lately, so this patch would be really useful.

Em qui., 15 de jul. de 2021 às 15:44, Abraão de Santana <
abraaocsantana@gmail.com> escreveu:

> Hey João , I think there's a problem with your email, it's empty!
>
> --
> *Abraão C. de Santana*
>


-- 
João Gabriel Jardim

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [android] Disable large files when unsupported
  2021-07-15 18:18 João Gabriel Jardim
@ 2021-07-15 18:43 ` Abraão de Santana
  2021-07-16  2:20   ` João Gabriel Jardim
  0 siblings, 1 reply; 6+ messages in thread
From: Abraão de Santana @ 2021-07-15 18:43 UTC (permalink / raw)
  To: João Gabriel Jardim; +Cc: gcc-patches

Hey João , I think there's a problem with your email, it's empty!

--
*Abraão C. de Santana*

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [android] Disable large files when unsupported
@ 2021-07-15 18:18 João Gabriel Jardim
  2021-07-15 18:43 ` Abraão de Santana
  0 siblings, 1 reply; 6+ messages in thread
From: João Gabriel Jardim @ 2021-07-15 18:18 UTC (permalink / raw)
  To: abraaocsantana; +Cc: gcc-patches

-- 
João Gabriel Jardim

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [android] Disable large files when unsupported
@ 2021-07-15 18:17 João Gabriel Jardim
  0 siblings, 0 replies; 6+ messages in thread
From: João Gabriel Jardim @ 2021-07-15 18:17 UTC (permalink / raw)
  To: abraaocsantana, gcc-patches

-- 
João Gabriel Jardim

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-16  2:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13  3:16 [PATCH] [android] Disable large files when unsupported Abraão de Santana
2021-07-13  3:33 ` Abraão de Santana
2021-07-15 18:17 João Gabriel Jardim
2021-07-15 18:18 João Gabriel Jardim
2021-07-15 18:43 ` Abraão de Santana
2021-07-16  2:20   ` João Gabriel Jardim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).