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

mmap causes compile errors on r15c (unknown identifier) #477

Closed
scared27 opened this issue Aug 2, 2017 · 12 comments
Closed

mmap causes compile errors on r15c (unknown identifier) #477

scared27 opened this issue Aug 2, 2017 · 12 comments

Comments

@scared27
Copy link

scared27 commented Aug 2, 2017

Description

Usage of mmap with NDK r15c are flagged as errors (use of undeclared identifier 'mmap'). This was not an issue with previous versions of the NDK (including r15 and r15b). This can easily be reproduced by adding usage of mmap to a native project (or include sqlite3).

This issue can be worked around by using the deprecated headers (adding APP_DEPRECATED_HEADERS := true to Application.mk)

Environment Details

  • NDK Version: 15.2.4203891
  • Build sytem: Both NDK-Build and CMAKE
  • Host OS: Windows 10 Enterprise 64bit
  • Compiler: Clang
  • ABI: armeabi-v7a
  • STL: c++_shared
  • NDK API level: 15 (Target/Compile = 26. Minimum = 15)
  • Device API level: 23 (6.0.1)
@DanAlbert
Copy link
Member

Are you setting _FILE_OFFSET_BITS=64?

@scared27
Copy link
Author

scared27 commented Aug 3, 2017

I believe not (I'm not exactly sure where it would be defined, but I checked all our .mk files and places that call through to ndk-build)

I created a bare bones c++ project via Android studio and added sqlite3 to the project with no additional modifications to confirm this issue before logging.

@DanAlbert
Copy link
Member

It could also be in one of your sources.

Add the following just above the failing call to mmap:

#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
#error "_FILE_OFFSET_BITS=64"
#elif defined(__USE_FILE_OFFSET64)
#error "__USE_FILE_OFFSET64"
#endif

If either of those errors happens, then something is setting it. It could be one of your build files, your build system (we don't do this in ndk-build though, so not in this case), one of your source files, or one of your dependencies' source files.

@scared27
Copy link
Author

scared27 commented Aug 3, 2017

We are not using the 64bit offset (The code compiles successfully).

@DanAlbert
Copy link
Member

Any chance you just forgot to include <sys/mman.h>? Maybe the old headers leaked that from some other header you were including.

If that's not the case either, I'm out of guesses and will need a test case to do any more (my trivial test case worked fine).

@scared27
Copy link
Author

scared27 commented Aug 3, 2017

Apologies for this, but we do actually define 64 bits file offset in code (I put the code inside the sqlite3.c file instead of a different file).

What are the implications for this? (I tried to blindly use mmap64 and that didn't work)

edit: Using mmap64 works in my basic test example, so I guess this is highly unlikely at this point to be an NDK issue and more an issue with us (although it's sad that sqlite3 no longer compiles out of the box with ndk r15c)

@enh
Copy link
Contributor

enh commented Aug 3, 2017

see https://android.googlesource.com/platform/bionic/+/master#32_bit-ABI-bugs-is-32_bit-1 for the full story. but basically, stop defining _FILE_OFFSET_BITS and r15 will behave the same as r14 did.

@scared27
Copy link
Author

scared27 commented Aug 3, 2017

Thank you for the assistance.

Sorry for wasting your time on a non-issue.

@DanAlbert
Copy link
Member

No worries, happy to help :)

@enh
Copy link
Contributor

enh commented Aug 3, 2017

and it's actually useful feedback that even in r15c where everything is strictly correct, users are confused by the diagnostics. we'll look into what we can do to improve these...

hideki pushed a commit to couchbaselabs/couchbase-lite-libsqlcipher that referenced this issue Sep 6, 2017
- Since NDK r15c, some methods are not defined if API version is lower than 21 and _FILE_OFFSET_BITS=64. See following link. android/ndk#477
hideki pushed a commit to couchbaselabs/couchbase-lite-libsqlcipher that referenced this issue Sep 7, 2017
- Since NDK r15c, some methods are not defined if API version is lower than 21 and _FILE_OFFSET_BITS=64. See following link. android/ndk#477
@4brunu
Copy link

4brunu commented Sep 27, 2017

I was having the same issue, and this is what fixed for me.
couchbaselabs/couchbase-lite-libsqlcipher#23

@GrahamAsher
Copy link

One simple way to fix the missing mmap problem, as long as you can live without large-file support, is to add the following option to your GCC command-line:

-DSQLITE_DISABLE_LFS

which prevents _FILE_OFFSET_BITS from being defined at (in my version) line 75 of the SQLite amalgamation source file sqlite3.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants