-
Notifications
You must be signed in to change notification settings - Fork 162
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
Compile error for Android Level API lower then 21 with NDK r16 #65
Comments
I have seen there is a ticket in track https://svn.boost.org/trac10/ticket/13230 . It is most likely the same issue |
@Bjoe Any idea what patch they're talking about in the issue you linked? They didn't seem to include a link to a github commit or pull request that I can see. |
@rcdailey Hi. I think my patch .... see above: android-boost-1_65_1-patches.patch.txt .... I didn't create a pull request yet because my patch fixes the build issue (!) not the problem ! I'm still waiting for any contributors from the boost filesystem project to give me a answer, if I should create a pull request ... maybe in the next time I will created one... |
Btw ... #56 and boost.filesystem compile problem on Android is the same issue |
Update: I confirmed via response from an NDK developer that this issue is indeed a boost.filesystem problem, not an NDK bug. When will this issue get some attention? It's been months. |
Disclaimer: I'm not a Boost.Filesystem maintainer. From the preprocessed output, there is no declaration of Granted, we shouldn't define |
this is the mistake:
no, it wasn't. in older NDKs, if you want the old behavior back 100%, just don't define alternatively, at the cost of ABI issues on your side, you could check |
That NDK removes pieces of otherwise available APIs when I guess, we could consider |
…el 21. The newer Google NDK versions don't declare truncate() function when _FILE_OFFSET_BITS=64 is defined. Don't define that macro and fall back to 32-bit offsets. boostorg#65
you think so (and it's a not entirely invalid argument), but others argue the opposite: that if they ask for an argument in favor of the behavior we chose for the NDK is that it's trivial for dissenters to get what they want (just stop defining |
Could someone test if #67 fixes the problem? |
@enh I understand your reasoning but I disagree. When the user defines |
@Lastique I can confirm your changes fix the problem. I checked out your branch on your fork and compiled for the following platform using Android NDK:
I applied your patch to boost 1.66.0 for my test. Patch file I used is available at the bottom of this post. Can we get this hotfixed into 1.66? diff --git a/src/operations.cpp b/src/operations.cpp
index 035612c..df9aa42 100644
--- a/src/operations.cpp
+++ b/src/operations.cpp
@@ -10,7 +10,9 @@
//--------------------------------------------------------------------------------------//
-// define 64-bit offset macros BEFORE including boost/config.hpp (see ticket #5355)
+// define 64-bit offset macros BEFORE including boost/config.hpp (see ticket #5355)
+// Google Android NDK is broken though as it doesn't provide truncate() declaration when _FILE_OFFSET_BITS=64 is defined (https://github.com/boostorg/filesystem/issues/65)
+#if !defined(__ANDROID__) || (__ANDROID_API__+0) >= 21 || defined(__CRYSTAX__)
#if !(defined(__HP_aCC) && defined(_ILP32) && !defined(_STATVFS_ACPP_PROBLEMS_FIXED))
#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect,
#endif
@@ -28,6 +30,7 @@
#else
#define _FILE_OFFSET_BITS 64
#endif
+#endif // !defined(__ANDROID__) || (__ANDROID_API__+0) >= 21 || defined(__CRYSTAX__)
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
@@ -44,7 +47,8 @@
#include <boost/filesystem/operations.hpp>
#include <boost/scoped_array.hpp>
#include <boost/detail/workaround.hpp>
-#include <vector>
+#include <limits>
+#include <vector>
#include <cstdlib> // for malloc, free
#include <cstring>
#include <cstdio> // for remove, rename
@@ -1615,6 +1619,12 @@ namespace detail
BOOST_FILESYSTEM_DECL
void resize_file(const path& p, uintmax_t size, system::error_code* ec)
{
+# if defined(BOOST_POSIX_API)
+ if (BOOST_UNLIKELY(size > static_cast< uintmax_t >((std::numeric_limits< off_t >::max)()))) {
+ error(system::errc::file_too_large, p, ec, "boost::filesystem::resize_file");
+ return;
+ }
+# endif
error(!BOOST_RESIZE_FILE(p.c_str(), size) ? BOOST_ERRNO : 0, p, ec,
"boost::filesystem::resize_file");
} |
Patch from boostorg#69 multiple commits, but head at boostorg/filesystem@3d3d504 Author: Alexei Khlebnikov <alexei.khlebnikov@gmail.com> Also see boostorg#65 boostorg#67
Now when #67 has been merged, this issue can be closed, I think. |
Yep. I close this. Thanks @alexeikh |
In the process, we: - Pass OPENSSL_BUILD_TARGET & ANDROID_API_LEVEL & TARGET_TRIPLE as Docker build args. - Use API level 21. - Adjust Python's configure flags so that it never calls setlocale(). The Android (bionic) C library doesn't meaningfully support setlocale(). Relevant links: - android/ndk#516 - boostorg/filesystem#65 There might be more things to change beyond this.
Boost 1.65.1
Compiler: clang from android NDK
clang_version__ "5.0.300080 "
NDK version: 16.0.4442984
Build system: cmake (3.6.4111459)
Std librariy: libc++_static
Build machine: Ubuntu 16.04.3 LTS
Since Google introduced unified headers the following compile error occurs to build boost::filesystem for example Android Level 19:
Before they introduced the unified headers the header file unistd.h didn't care about the defines _FILE_OFFSET_BITS or __USE_FILE_OFFSET64. Here a snippit from unistd.h:
Since they introduced unified headers, unistd.h snippet:
Now they care about the define __USE_FILE_OFFSET64 and truncate for 64 Bit is not implemented before Android API level 21.
We compile and use boost::filesystem for Android API level 19 long time ago and we didn't have any problems. So I decided to "if def" the define of __USE_FILE_OFFSET64 around (see snippet):
to skip this so that we have the same behavior as before, I think.
I create a patch file but I will not create a pull request because I think this is not the right solution and you should decided if this is a proper fix or not. Then I can create a pull request, if needed.
I added the patch file and a preprocessor output of the compile error in operations.cpp
operations.ii.txt
android-boost-1_65_1-patches.patch.txt
You need some help or additional information, let me know.
The text was updated successfully, but these errors were encountered: