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

Comments

@benbrittain
Copy link

@benbrittain benbrittain commented Jul 23, 2019

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

@benbrittain benbrittain commented Jul 23, 2019

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

cc/ @cramertj @eddyb @nikomatsakis @Zoxc

Loading

@cramertj cramertj changed the title Remove TLS dependency from Futures Remove TLS dependency from async/await Jul 23, 2019
@xurtis
Copy link

@xurtis xurtis commented Jul 24, 2019

Duplicate of rustasync/team#42

Loading

@xurtis
Copy link

@xurtis xurtis commented Jul 24, 2019

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

Loading

@cramertj
Copy link
Member

@cramertj cramertj commented Jul 24, 2019

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.

Loading

@xurtis
Copy link

@xurtis 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.

Loading

@TomCrypto
Copy link

@TomCrypto TomCrypto commented Jul 25, 2019

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)

Loading

@phil-opp
Copy link
Contributor

@phil-opp phil-opp commented Sep 15, 2019

@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?

Loading

@benbrittain
Copy link
Author

@benbrittain benbrittain commented Sep 15, 2019

Loading

@phil-opp
Copy link
Contributor

@phil-opp phil-opp commented Sep 16, 2019

@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.

Loading

@jonas-schievink
Copy link
Member

@jonas-schievink jonas-schievink commented Jan 23, 2020

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants