Skip to content
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

clang __thread caused linker error #8

Closed
arseny30 opened this issue Mar 11, 2016 · 6 comments
Closed

clang __thread caused linker error #8

arseny30 opened this issue Mar 11, 2016 · 6 comments
Assignees
Milestone

Comments

@arseny30
Copy link

ndk r11
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION := clang

Trying to build shared library from single line file:
x.cpp:
__thread const char *x = "";
Got:

/Users/arseny30/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: warning: shared library text segment is not shareable
/Users/arseny30/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: treating warnings as errors
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Everything is OK, when I replace the line with:
__thread const char *x = nullptr;

@DanAlbert
Copy link
Member

@chih-hung, at first glance I would guess this is something in clang? Any known issues that were fixed very recently? r11 has clang version 3.8.243773

@DanAlbert DanAlbert added this to the r12 milestone Mar 11, 2016
@stephenhines
Copy link
Collaborator

Yes, the final patches for emutls are only in a clang that I updated yesterday for AOSP (still labeled 3.8.256229, but from build ID 2658975 instead).

@DanAlbert
Copy link
Member

Ahh damn. I shouldn't have called out __threadin the changelog then :( I thought we had all the fixes.

still labeled 3.8.256229, but from build ID 2658975 instead

Is it actually still the same revision, or did we miss updating the config for the build? I'm wondering about impact of pulling in the new build. If it's small I'll do it for r11b, if not I'll just fix the changelog and we'll do this for r12.

@DanAlbert DanAlbert assigned DanAlbert and unassigned chih-hung Mar 11, 2016
@stephenhines
Copy link
Collaborator

It's a merge + a handful of cherry-picks for emutls, long double, and "krait". We don't update the "merge" CL ID when we do these cherry-picks, as it would be pretty misleading. I need a better strategy though for labeling these as 256229A, etc., instead. That said, r11 only has r243773, so you are missing quite a lot of changes because of the actual merge.

@DanAlbert
Copy link
Member

Talked to @stephenhines, there was another patch that was needed to get this fully enabled that we didn't get in the NDK (wasn't available to us until a week or two ago, at which point I didn't want to rev the compiler again).

I'll fix the changelog, and get the feature out in r12.

@DanAlbert
Copy link
Member

(closing because this is fixed in master)

kwasimensah added a commit to kwasimensah/grpc that referenced this issue Oct 27, 2017
Old version of the Android NDK have linker issues with thread local support android/ndk#8 and isn't actually fixed until r12b https://developer.android.com/ndk/downloads/revision_history.html. ABSL's config.h is being updated to catch this case and having gRPC rely on that will make sure it also gets the fix (rather than repeating a somewhat lengthy macro). 

Since gRPC already has a dependency on ABSL, I figured this wouldn't be an issue.
kwasimensah added a commit to kwasimensah/bullet3 that referenced this issue Nov 2, 2017
Expand logic for when __thread is supported to work around android/ndk#8
kwasimensah added a commit to kwasimensah/gemmlowp that referenced this issue Nov 22, 2017
Some buggy versions of Android NDK don't support thread_local properly (see android/ndk#8). So use pthreads here.
@PvR33 PvR33 mentioned this issue Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants