Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] fseeko and ftello not supported on arm32 & x86 below API level 24 without disabling _FILE_OFFSET_BITS=64 #111665

Open
steveisok opened this issue Jan 21, 2025 · 9 comments
Milestone

Comments

@steveisok
Copy link
Member

From https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md

Android does not require the _LARGEFILE_SOURCE macro to be used to make fseeko and ftello available. Instead they're always available from API level 24 where they were introduced, and never available before then.

An easy solution would be to bump the min API level to 24, but that is not solely a technical decision.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 21, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 21, 2025
@steveisok steveisok added area-Infrastructure-coreclr and removed untriaged New issue has not been triaged by the area owner needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 21, 2025
@steveisok steveisok added os-android runtime-coreclr specific to the CoreCLR runtime labels Jan 21, 2025
@steveisok steveisok added this to the 10.0.0 milestone Jan 21, 2025
Copy link
Contributor

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

@akoeplinger
Copy link
Member

Where are these functions used? I can't seem to find any in the runtime.

@steveisok
Copy link
Member Author

It starts here

I haven't looked deeply into if we'll be able to sidestep it somehow.

@akoeplinger
Copy link
Member

you mean just including fstream causes these functions to be used somehow?

@steveisok
Copy link
Member Author

Yeah, apparently. But we can't get rid of it because fstream types are used later on in the host PAL.

Here's an example of the build error you'll get:

In file included from /Users/steve/dev/customer-runtime/src/native/corehost/hostmisc/trace.cpp:4:
  In file included from /Users/steve/dev/customer-runtime/src/native/corehost/hostmisc/trace.h:7:
  In file included from /Users/steve/dev/customer-runtime/src/native/corehost/hostmisc/pal.h:9:
  /Users/steve/android-ndk-r27c/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/fstream:869:9: error: no member named 'fseeko' in the global namespace; did you mean 'fseek'?
    869 |   if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
        |       ~~^
  /Users/steve/android-ndk-r27c/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/stdio.h:207:5: note: 'fseek' declared here
    207 | int fseek(FILE* _Nonnull __fp, long __offset, int __whence);
        |     ^

@jkoritzinsky
Copy link
Member

These failures cause a lot of complications in our infrastructure today (see all checks around '$(TargetsLinuxBionic)' == 'true' and '$(TargetArchitecture)' == 'arm'.

We can likely skip defining _FILE_OFFSET_BITS=64 for android arm32, at least for the hosts layer. It's highly unlikely that someone would have a 4GB+ runtimeconfig.json or deps.json file for an Android arm32 app.

@vitek-karas
Copy link
Member

We might be able to rewrite the host pal to not use fstream - the pal is pretty simple, so if we can find other ways to do it... the only limitation is that we don't want to make the host larger, so ideally use something which already exists in it.

@steveisok steveisok changed the title [Android] fseeko and ftello not supported on arm32 below API level 24 without disabling _FILE_OFFSET_BITS=64 [Android] fseeko and ftello not supported on arm32 & x86 below API level 24 without disabling _FILE_OFFSET_BITS=64 Jan 23, 2025
steveisok added a commit that referenced this issue Jan 24, 2025
This change adds build support for the arm64 and x64 CoreCLR runtimes for Android. Initial infrastructure to run a simple sample was also added (src/mono/sample/Android) and we plan to do more in a follow up.

The arm32 and x86 builds are blocked by #111665 since our min API level target is 21. Both will be fixed at a later time.

Contributes to #111491

---------

Co-authored-by: Steve Pfister <[email protected]>
Co-authored-by: Jan Vorlicek <[email protected]>
Co-authored-by: Ivan Povazan <[email protected]>
Co-authored-by: Milos Kotlar <[email protected]>
@filipnavara
Copy link
Member

filipnavara commented Jan 24, 2025

We might be able to rewrite the host pal to not use fstream

That seems pretty doable: main...filipnavara:runtime:host-remove-fstream

I didn't update the test code but that only reads whole file into memory, essentially the same thing as done in json_parser.cpp, so I don't expect to be hard. I also didn't actually try to run it, so take it with a grain of salt, but it looks like a reasonable approach to take.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

5 participants