diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2017-11-20 12:32:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 12:32:23 -0800 |
commit | c567ceb01af2ccfc4bd631c0c1247767732c67a1 (patch) | |
tree | d8a262f1f8587f78fdfa882cc101bc287fcf5d51 /include | |
parent | ad671ff561d34b30e6a857842add23b27e7ae7de (diff) | |
parent | 8abe26237e0060d2601b789ffcbf52437bd67a7d (diff) |
Merge pull request #13173 from kwasimensah/patch-1
Add logic to work around buggy Android NDKs
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc/impl/codegen/port_platform.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index fb4bfc3162..1906886d5e 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -297,6 +297,27 @@ #endif #endif /* GPR_NO_AUTODETECT_PLATFORM */ +/* + * There are platforms for which TLS should not be used even though the + * compiler makes it seem like it's supported (Android NDK < r12b for example). + * This is primarily because of linker problems and toolchain misconfiguration: + * TLS isn't supported until NDK r12b per + * https://developer.android.com/ndk/downloads/revision_history.html + * Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in + * <android/ndk-version.h>. For NDK < r16, users should define these macros, + * e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. */ +#if defined(__ANDROID__) && defined(__clang__) && defined(GPR_GCC_TLS) +#if __has_include(<android/ndk-version.h>) +#include <android/ndk-version.h> +#endif /* __has_include(<android/ndk-version.h>) */ +#if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ + defined(__NDK_MINOR__) && \ + ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) +#undef GPR_GCC_TLS +#define GPR_PTHREAD_TLS 1 +#endif +#endif /*defined(__ANDROID__) && defined(__clang__) && defined(GPR_GCC_TLS) */ + #if defined(__has_include) #if __has_include(<atomic>) #define GRPC_HAS_CXX11_ATOMIC |