Opened 5 years ago
Last modified 5 years ago
#13230 new Bugs
_FILE_OFFSET_BITS=64 breaks compilation with Android NDK r15 and API<24
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.65.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Behavior of _FILE_OFFSET_BITS
in Android NDK is described at android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
Android support for
_FILE_OFFSET_BITS=64
(which turns off_t intooff64_t
and replaces eachoff_t
function with itsoff64_t
counterpart, such aslseek
in the source becominglseek64
at runtime) was added late. Even when it became available for the platform, it wasn‘t available from the NDK until r15. Before NDK r15,_FILE_OFFSET_BITS=64
silently did nothing: all code compiled with that was actually using a 32-bitoff_t
. With a new enough NDK, the situation becomes complicated. If you’re targeting an API before 21, almost all functions that take anoff_t
become unavailable. You‘ve asked for their 64-bit equivalents, and none of them (exceptlseek
/lseek64
) exist. As you increase your target API level, you’ll have more and more of the functions available. API 12 adds some of the<unistd.h>
functions, API 21 adds mmap, and by API 24 you have everything including<stdio.h>
.
In filesystem/src/operations.cpp
_FILE_OFFSET_BITS
is unconditionally defined to 64
in hope that
at worst, these defines may have no effect
It actually breaks compilation with Android NDK r15 if __ANDROID_API__
is less than 24.
Change History (6)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Also affected by this issue and can verify that the patch on GitHub resolved it
comment:3 by , 5 years ago
Where is the patch that fixes this? I'm running into this same issue using LLVM STL with Clang on NDK r16b while building boost 1.64. This is blocking my transition away from GNU STL. Note that GNU STL is deprecated and NDK team will be removing it soon. I feel a sense of urgency because of that.
comment:4 by , 5 years ago
This android-boost-1_65_1-patches.patch in my github report https://github.com/boostorg/filesystem/issues/65. For the information, this patch only fix the build issue and not the problem! It builds and it also "runs" but it could be a problem on "large filesystem/files" ... I'm not sure. I'm not a filesystem expert. I still waiting for any boost filesystem contributor.
comment:5 by , 5 years ago
it could be a problem on "large filesystem/files" ... I'm not sure
to be clear: if your code worked on an older NDK, your patch is correct: it restores the old "use a 32-bit off_t" behavior. it's a neutral "(in)correctness preserving" change :-)
comment:6 by , 5 years ago
The issue is still not fixed. The issue is quite serious: Boost.Filesystem does not compile on Android. It is not the same issue as #13274.
There is a pull request, addressing the issue: https://github.com/boostorg/filesystem/pull/69
It is also breaks compilation with Android NDK 16.0.4442984 and API level lower then 21. With API Level 21 it compiles without any error. See also my github report https://github.com/boostorg/filesystem/issues/65