Fixes the build failure when using ECM Android toolchain
AbandonedPublic

Authored by sh-zam on Mar 12 2019, 1:28 AM.

Diff Detail

Repository
R244 KCoreAddons
Branch
android-bug-fix (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9490
Build 9508: arc lint + arc unit
sh-zam created this revision.Mar 12 2019, 1:28 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMar 12 2019, 1:28 AM
sh-zam requested review of this revision.Mar 12 2019, 1:28 AM
apol added a subscriber: apol.Mar 12 2019, 2:21 AM

Maybe it would make more sense to remove them instead?

Are we sure this doesn't need to be conditional on the API level? Ie. only have those dummy declarations available on API levels before they were introduced on Android?

Removing them doesn't help either.

We could use conditionals, but then I was using API 21 and it failed with that.

Yes, that is confusing. I tried recreating the CI system, but it still doesn't compile.

I can reproduce with -DCMAKE_ANDROID_API=26 here, while anything below builds fine. This seems to fix it:

diff --git a/src/lib/util/kuser_unix.cpp b/src/lib/util/kuser_unix.cpp
index c42ea99..216dfb7 100644
--- a/src/lib/util/kuser_unix.cpp
+++ b/src/lib/util/kuser_unix.cpp
@@ -36,7 +36,7 @@
 #include <algorithm>  // std::find
 #include <functional> // std::function
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && __ANDROID_API__ < 26
 static inline struct passwd * getpwent() { return nullptr; }
 inline void setpwent() { }
 static inline void setgrent() { }

When using API >= 26, it doesn't find the enclosed functions, so we will have to make them non-static in that case.

PS: Making them non-static doesn't break tests.

Are you sure? pwd.h of the NDK contains the following here:

#if __ANDROID_API__ >= 26
struct passwd* getpwent(void) __INTRODUCED_IN(26);

void setpwent(void) __INTRODUCED_IN(26);
void endpwent(void) __INTRODUCED_IN(26);
#endif /* __ANDROID_API__ >= 26 */

So we should not need any declarations in our code for API >= 26 I think, which matches exactly the behavior I observe here when trying to compile kcoreaddons with different API levels.

I tested it against Android NDK's toolchain and it built fine. So, probably an issue with ECM/toolchain/Android.cmake

sh-zam abandoned this revision.Mar 12 2019, 8:53 PM