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

Remove TLS dependency from async/await #62918

Closed
benbrittain opened this issue Jul 23, 2019 · 10 comments
Closed

Remove TLS dependency from async/await #62918

benbrittain opened this issue Jul 23, 2019 · 10 comments
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@benbrittain
Copy link

Futures currently have a dependency on TLS for storing a pointer to Context<'_>.
https://github.com/rust-lang/rust/blob/master/src/libstd/future.rs#L116

This makes usage in no_std environments quite difficult.

@benbrittain
Copy link
Author

I would like to tackle this since it's blocking a personal project.

cc/ @cramertj @eddyb @nikomatsakis @Zoxc

@cramertj cramertj added A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. labels Jul 23, 2019
@cramertj cramertj changed the title Remove TLS dependency from Futures Remove TLS dependency from async/await Jul 23, 2019
@xurtis
Copy link

xurtis commented Jul 24, 2019

Duplicate of rustasync/team#42

@xurtis
Copy link

xurtis commented Jul 24, 2019

There's also some additional background discussion on the rust-internals discourse.

@cramertj
Copy link
Member

Duplicate of rustasync/team#42

Not sure if you were suggesting this, but I don't think we should be using other repo's issues to track changes to rustc.

@xurtis
Copy link

xurtis commented Jul 24, 2019

I mean, nor do I but that is where most of the existing discussion is. It may be worth closing the other thread to try and avoid splitting the discussion over two issues on separate repos.

@TomCrypto
Copy link

I'm running into this as well. You can work around it and get things working using a hack akin to this https://github.com/SunriseOS/core-futures-tls but it requires overriding libcore for every crate that needs #![feature(async_await)] which makes it difficult to do in library crates. TLS-free async fns would be cool.

(I'm sure this workaround is well-known but just posting for future readers that might come across this issue)

@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 17, 2019
@phil-opp
Copy link
Contributor

@cavedweller

I would like to tackle this since it's blocking a personal project.

Are you still working on this? I don't have much experience with the Rust compiler, but maybe there is still a way I can help?

@benbrittain
Copy link
Author

benbrittain commented Sep 15, 2019 via email

@phil-opp
Copy link
Contributor

@cavedweller I took a detailed look at your work-in-progress implementation at benbrittain@11c9422 today. I think the next step would be to adjust the MIR transformation in librustc_mir/transform/generator.rs, which transforms generators into "normal" state machines. I assume that we would need to adjust the code generated for yield and resume to take the new arguments into account. Unfortunately, I have no experience with MIR transformations, so I fear that this is over my head. I'll try to read up about MIR and see if I can understand this transformation, but I can't promise anything.

@jonas-schievink
Copy link
Contributor

This is essentially a duplicate of #56974, so closing in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants