Fix #9476: Support native TLS on Mac OS X#5346
Conversation
986813e to
27c111c
Compare
|
Why are the FreeBSD and Windows tests looking for |
|
Out of date make rules |
|
Ah, but they don't cause the build to fail. |
27c111c to
c5be41b
Compare
|
Added back emulated TLS for 32bit. |
|
ping @WalterBright @yebblies @klickverbot @smolt |
|
Seems like the AA test case still fails on the auto tester – wasn't that the one you asked me about on the LDC mailing list? |
|
Also be aware of ldc-developers/ldc#1252, just in case. |
Yes. I'll have a look.
Ok, thanks. |
c5be41b to
f1d5d3f
Compare
|
@klickverbot I'm pretty sure it's because the druntime PR is not merged. All tests pass for me locally when including the necessary changes for druntime. If I use druntime master I get the same error as the auto tester gets. |
|
@jacob-carlborg I'll take a look this weekend, my week got full already. |
|
@smolt thanks, no rush 😃 |
|
@yebblies: How can we run two PRs together on the auto-tester again? Was this something special Brad set up for you? |
|
I fetched both dmd and druntime native_tls branches and all is fine here for 64-bit with OS X 10.10.5 and Xcode 7.2. Passes druntime, phobos, and dmd test suite. The assembly looks correct for OS X thread local access, although I suppose since tests passed, all I did was verify that it is truly using OS X thread local support. As @klickverbot brought up issue ldc-developers/ldc#1252, I checked into it with this program. // file tls_faild.d
import core.stdc.stdio;
byte tb = 42; // __thread_data
real zb16 = void; // __thread_bss 16-byte aligned
void main()
{
printf("zb16 %p\n", &zb16);
// zb16 addr is only 8-byte aligned, should be 16-byte
}See how real |
src/backend/machobj.c
Outdated
There was a problem hiding this comment.
I think comment was for 64-bit and can be removed.
@smolt not sure I understand. Should I change the alignment of I looks like Clang is using the alignment of the largest variable in the section, for both |
|
Without the OS X linker bug, doing what clang is doing is best (align section to maximum member alignment). I was being general, saying a workaround for the linker alignment bug is to make sure For LDC, it was easiest to declare a thread-local variable with 16-byte alignment: https://github.com/ldc-developers/druntime/blob/ldc/src/rt/sections_ldc.d#L410 although when I tried align like that in dmd, it didn't seem to have an effect. Whatever the workaround, I have a radar bug filed with Apple, and will update ldc-developers/ldc#1252 when I get feedback so the workaround can be lifted someday. |
Now I'm confused. Should |
|
Sorry for confusion. Section |
f1d5d3f to
8547efc
Compare
@smolt fixed. Also rebased. |
|
@WalterBright ping. @andralex this is a prerequisite for dynamic libraries on OS X which, IIRC, you've been asking for. |
|
@jacob-carlborg looks good. BTW, I located half of the alignment bug in dyld source code. The following allocation of thread local block ( https://www.opensource.apple.com/source/dyld/dyld-360.18/src/threadLocalVariables.c I haven't heard back from Apple yet on bug I filed. I assume they will fix it in ld64 |
|
ping @WalterBright @9rnsr @yebblies |
|
can we get an ETA for review/merge on this? |
|
@MartinNowak ping |
|
@WalterBright @yebblies @9rnsr ping |
|
@andralex ping. I would like to add that this is a perquisite for dynamic libraries that you've been asking for. |
|
Where you have an Apart from that it looks good (from my limited understanding of this part of the compiler), but I think it really needs @WalterBright's review before merging. Let's say if Walter hasn't had a chance to review in the next week I'll merge and see what happens. |
I'll update the code.
Ok, fair enough. @yebblies have you looked at the runtime part as well? dlang/druntime#1461 |
8547efc to
2e19e8d
Compare
|
Updated. |
|
@yebblies one week later, I see no indication of any form of new review. |
|
Ok then. We can always revert if anything goes wrong. |
|
And there we go, reverted. |
|
Do you have any reference to what failed? Is it this: https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=102572&dataid=709075 ? |
|
@yebblies (see previous post, explicitly pinging to be sure) |
|
Yeah |
This currently only works on 64bit. I created this PR anyway to get some code review for the changes.
For 32bit, there are three options, see discussions as well [1] [2]:
Drop it completelyImplement a working native TLS. I'm suspecting there just some issue with how the instructions are generate for accessing a TLS variable that causes a segmentation fault. Otherwise both 32 and 64bit uses the same implementationRuntime part: dlang/druntime#1461.
[1] http://forum.dlang.org/thread/n6u3e8$1u0b$1@digitalmars.com
[2] http://forum.dlang.org/thread/8125593F-344A-4A46-BB84-57E251EB9CB6@me.com