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

Use the right TLS model for CloudABI. #47110

Merged
merged 2 commits into from
Jan 5, 2018
Merged

Conversation

EdSchouten
Copy link
Contributor

CloudABI doesn't do dynamic linking. For this reason, there is no need
to handle any other TLS model than local-exec. CloudABI's C library
doesn't provide a __tls_get_addr() function to do Dynamic TLS.

By forcing local-exec to be used here, we ensure that we don't generate
function calls to __tls_get_addr().

CloudABI doesn't do dynamic linking. For this reason, there is no need
to handle any other TLS model than local-exec. CloudABI's C library
doesn't provide a __tls_get_addr() function to do Dynamic TLS.

By forcing local-exec to be used here, we ensure that we don't generate
function calls to __tls_get_addr().
@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2018
@kennytm
Copy link
Member

kennytm commented Jan 3, 2018

I'm not familiar with TLS, but from what I searched, the initial-exec model also doesn't generate __tls_get_addr(). Could you explain why local-exec is chosen, besides "it doesn't do dynamic linking"? Thanks.

@EdSchouten
Copy link
Contributor Author

Thanks for the review! It looks like initial-exec would work for CloudABI as well. That also doesn't emit any calls to __tls_get_addr().

The main difference between local-exec and initial-exec is that the latter emits code that has one more level of indirection: it accesses the GOT (Global Offset Table) to obtain the effective address of a thread-local variable. Using a GOT is advantageous when doing dynamic linking, because it means that multiple accesses of the same variable within one library are folded into just one startup-time relocation.

With local-exec, the offset is expanded into every instruction that attempts to access it directly. This is optimal and for CloudABI, it is also sufficient.

@kennytm
Copy link
Member

kennytm commented Jan 3, 2018

Thanks for explanation! Could you summarize those (#47110 (comment) + #47110 (comment)) as a code-comment? r=me after that.

@EdSchouten
Copy link
Contributor Author

EdSchouten commented Jan 3, 2018

Sure thing!

r= @kennytm

@kennytm
Copy link
Member

kennytm commented Jan 3, 2018

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 3, 2018

📌 Commit 05949b0 has been approved by kennytm

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2018
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jan 4, 2018
Use the right TLS model for CloudABI.

CloudABI doesn't do dynamic linking. For this reason, there is no need
to handle any other TLS model than local-exec. CloudABI's C library
doesn't provide a __tls_get_addr() function to do Dynamic TLS.

By forcing local-exec to be used here, we ensure that we don't generate
function calls to __tls_get_addr().
kennytm added a commit to kennytm/rust that referenced this pull request Jan 4, 2018
Use the right TLS model for CloudABI.

CloudABI doesn't do dynamic linking. For this reason, there is no need
to handle any other TLS model than local-exec. CloudABI's C library
doesn't provide a __tls_get_addr() function to do Dynamic TLS.

By forcing local-exec to be used here, we ensure that we don't generate
function calls to __tls_get_addr().
kennytm added a commit to kennytm/rust that referenced this pull request Jan 5, 2018
Use the right TLS model for CloudABI.

CloudABI doesn't do dynamic linking. For this reason, there is no need
to handle any other TLS model than local-exec. CloudABI's C library
doesn't provide a __tls_get_addr() function to do Dynamic TLS.

By forcing local-exec to be used here, we ensure that we don't generate
function calls to __tls_get_addr().
bors added a commit that referenced this pull request Jan 5, 2018
Rollup of 10 pull requests

- Successful merges: #47030, #47033, #47110, #47149, #47150, #47160, #47162, #47182, #47198, #47199
- Failed merges:
@bors
Copy link
Contributor

bors commented Jan 5, 2018

☔ The latest upstream changes (presumably #47214) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors merged commit 05949b0 into rust-lang:master Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants