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

Meeting proposal: Unsafe extern blocks #223

Closed
tmandry opened this issue Oct 4, 2023 · 3 comments
Closed

Meeting proposal: Unsafe extern blocks #223

tmandry opened this issue Oct 4, 2023 · 3 comments
Labels
meeting-proposal Proposal for a lang team design meeting T-lang

Comments

@tmandry
Copy link
Member

tmandry commented Oct 4, 2023

Summary

Simply declaring extern items, even without ever using them, can cause Undefined Behavior. When performing cross-language compilation, attributes on one function declaration can flow to the foreign declaration elsewhere within LLVM and cause a miscompilation. In Rust we consider all sources of Undefined Behavior to be unsafe, and so we must make declaring extern blocks be unsafe. The up-side to this change is that in the new style it will be possible to declare an extern fn that's safe to call after the initial unsafe declaration.

In Edition 2024 it is unsafe to declare an extern function or static, but external functions and statics can be safe to use after the initial declaration.

Background reading

rust-lang/rfcs#3484

About this issue

This issue corresponds to a lang-team design meeting proposal. It corresponds to a possible topic of discussion that may be scheduled for deeper discussion during one of our design meetings.

@tmandry
Copy link
Member Author

tmandry commented Oct 4, 2023

cc @Lokathor

@traviscross traviscross moved this from Needs triage to Scheduled in T-lang design meeting schedule Oct 4, 2023
@Lokathor
Copy link

Lokathor commented Oct 4, 2023

Thanks but I never have Wednesday free, so just hold it without me.

@RalfJung
Copy link
Member

RalfJung commented Oct 4, 2023

Simply declaring extern items, even without ever using them, can cause Undefined Behavior.

FWIW this is not a fact of nature, it's an LLVM thing inherited from C. We could also try to work towards fixing that.

@traviscross traviscross moved this from Scheduled to Needs minutes in T-lang design meeting schedule Oct 24, 2023
@traviscross traviscross moved this from Needs minutes to Done in T-lang design meeting schedule Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meeting-proposal Proposal for a lang team design meeting T-lang
Projects
Development

No branches or pull requests

4 participants