-
Notifications
You must be signed in to change notification settings - Fork 260
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
Unified Headers: pthread_barrier_t defined when __ANDROID_API__ < 24 #336
Comments
The problem is that a common use case for the NDK is to target a lower API level (since your target NDK API level is the minimum supported version for your app) and conditionally access newer APIs with dlopen/dlsym. In this case, you need those types and constants to be defined even on the lower API level. Because of that, we can't alter this behavior without causing a much larger set of problems.
libuv needs to check for the availability of the function, not the availability of the constant. Some configure step needs to be checking this. Alternatively libuv could be patched to expose its own implementation based on |
Discussed this with the rest of the bionic folks today and they all suspect I've overestimating the number of people that rely on this kind of behavior. Reopening for discussion and summoning some other unified headers early adopters and folks that have been involved in earlier discussions: @alexcohn @DoDoENT @hrydgard We don't have much insight into how important the use case of using We have some options here:
Thoughts? |
FWIW, I haven't seen the
A platform in such broad use cannot easily exclude authors/users who want improved/divergent behavior on later Android releases. Perhaps 2 could be implemented first, with the eye toward a streamlined migration to Unified Headers, with 3 in a subsequent NDK release for additional flexibility. |
I don't really have a strong opinion regarding option 1 vs option 2, I tend to only use what exists on api=9. I don't like option 3 because it's adding yet another setting that needs to be tested both ways which will take time that the NDK team could use for more important things. I've mostly had issues with STL incompatibilities between gnustl_static and clang, which will be solved by switching to libc++ in a couple of NDK versions. Apart from that one strerror_r thing which will be fixed in NDK 14r2, my app builds fine with unified headers as they are. I don't use dlsym except for conditionally loading Vulkan. |
In our SDK, we generally use only what is offered by API 9, except for OpenGL ES 3.1, from which we only use headers (which are available from API 21). Since those headers offer pointers to functions which we can inspect at runtime, there is no need to manually use We also plan to use Vulkan for some of our use cases, however we still do not have any experience with it. Using it will require We also made some experiments with using OpenCL for accelerating some of our core algorithms and since it is not part of android API, we heavily used So, my opinion would be to stick with option 1 or give a choice as with option 3 - those people that require usage of both |
TL;NR: I vote for the second option: hide the defines and constants together with APIs. I haven't yet seen a situation where dlsym for newer platform was necessary. Similar condition is quite popular on the Java side of Android, but the way it works there is by using minSdkVersion lower than compileSdkVersion, and keeping the newer-platform-dependent code isolated by On the Native side, I have never came across extended libc API that provides important additional functionality as compared to lower platforms. Having atof() defined as inline in stdlib.h prior to SDK 21 does not break anything; the only burden it creates is that mixing components built with different APP_PLATFORM is hard. |
PS OpenCL is a very different beast. AFAIK, presence of OpenCL is not determined by the platform level, but depends on the chipset; the library may have different names, and expose different capabilities. Will there be some wrapper for it in the shiny post-Nougat future? |
If Vulkan is available, spinning that up and using it to dispatch compute shaders seems like a better (and better-supported) option than going OpenCL. (But that's a bit off topic here). |
other than since the case of "the header exists, but is effectively empty" is also weird, i'm leaning towards leaving those alone until/unless we get an actual motivating use case. https://android-review.googlesource.com/355466 hides the definitions of the types until API level 24 (to match the functions), but unfortunately that breaks the versioner tool. it spews messages like
and then dumps core:
|
Yeah, you'll need to add guards to the functions as well. |
Thanks a lot for the feedback! Sounds like mostly votes for 2. @DoDoENT, if I'm understanding you correctly, you're only interested in being able to |
Yes.
No.
👍 In short terms, I am more interested in having fixes for issues #318, #313 and #21. #318 is really a blocker for us at the moment and #313 is quite critical (some of our developers need to run android studio under linux virtual machine on their windows system just to get LTO working). |
Bug: android/ndk#336 Test: builds Change-Id: I938d9d7ea879d1dbc355f14e100f1ea31a51a1f0
Just a heads up: this is going to be in r15 but won't be in beta 1. We've got a bunch of new code in the headers (better |
Signed-off-by: Victor Chong <victor.chong@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Bug: android/ndk#336 Test: builds Change-Id: I938d9d7ea879d1dbc355f14e100f1ea31a51a1f0
Description
When compiling
libuv
with-D__ANDROID_API__=16
, I found that these macros and types were defined:PTHREAD_BARRIER_SERIAL_THREAD
pthread_barrier_t
pthread_barrierattr_t
I would expect that since
pthread_barrier_init
and friends are excluded when__ANDROID_API__ < 24
, that these types would be excluded as well. They were not available onlibuv
checks for a definition ofPTHREAD_BARRIER_SERIAL_THREAD
and forOS=android
when deciding whether or not to include its ownpthread_barrier*
implementation. I can patchlibuv
to always use its own implementation, but I can't easily patch the NDK to exclude its conflicting definition ofpthread_barrier_t
.Environment Details
Not all of these will be relevant to every bug, but please provide as much
information as you can.
ExternalProject_Add
invoking configure/make with environment variables set for Unified HeadersThe text was updated successfully, but these errors were encountered: