Make Wasm target features atomics and exception-handling target modifiers by daxpedda · Pull Request #148417 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Adds the ability to make any target feature a target modifier.
Specifically makes Wasm target features atomics and exception-handling target modifiers
Tracking issue: #136966.
Draft
Would like to get some initial feedback on the implementation and the green light from @alexcrichton if this makes sense in the first place.
Still missing tests as well.
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Area: port run-make Makefiles to rmake.rs
Area: Rustdoc JSON backend
Status: This is awaiting some action (such as code changes or more information) from the author.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the rustdoc team, which will review and decide on the PR/issue.
labels
| // If feature is a target modifier. |
|---|
| type TargetModifier = bool; |
| static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures, TargetModifier)] = &[ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be time to turn this into a struct type?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might work well as a builder-style structure such as:
unstable("aclass, sym::...),
stable("aes"),
stable("other").deps(["a", "b", "c"]),where .target_modifier(true) could be one of those.
Comment on lines 98 to 99
| if session.target.rust_target_features().iter().any( |
|---|
| |(name, _, _, target_modifier) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't handle implied features. Its not required right now, but let me know if we should handle it as well.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also doesn't handle base features, which is more of a concern.
I'm not entirely sure how this could be handled here.
Could I assume that Session::target_features contains the base features and add any codegen options on top of that?
EDIT: done.
This comment has been minimized.
Area: The tidy tool
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
labels
This comment has been minimized.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on lines +96 to +126
| for feature in session |
|---|
| .target_features |
| .iter() |
| .map(|symbol |
| .chain(val.value_name.split(',')) |
| { |
| if let Some(feature) = feature.strip_prefix('+') { |
| if session |
| .target |
| .rust_target_features() |
| .iter() |
| .any(|(name, _, _, target_modifier) |
| { |
| target_features.push(feature); |
| } |
| } else if let Some(feature) = feature.strip_prefix('-') { |
| if session |
| .target |
| .rust_target_features() |
| .iter() |
| .any(|(name, _, _, target_modifier) |
| { |
| for (index, target_feature) in target_features.iter().enumerate() { |
| if *target_feature == feature { |
| target_features.remove(index); |
| break; |
| } |
| } |
| } |
| } |
| } |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this parsing already exists elsewhere in the codebase -- would it be possible to deduplicate the parsing routine?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-Ctarget-features is parsed by parse_rust_feature_flag in cg_ssa. sess.target.features is split on , by cg_llvm and then parsed by LLVM given that it is a set of backend features rather than rust features:
| // Features implied by an implicit or explicit `--target`. |
|---|
| features.extend(sess.target.features.split(',').filter(|v |
| // If feature is a target modifier. |
|---|
| type TargetModifier = bool; |
| static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures, TargetModifier)] = &[ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might work well as a builder-style structure such as:
unstable("aclass, sym::...),
stable("aes"),
stable("other").deps(["a", "b", "c"]),where .target_modifier(true) could be one of those.
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Area: port run-make Makefiles to rmake.rs
Area: Rustdoc JSON backend
Area: The tidy tool
Status: This is awaiting some action (such as code changes or more information) from the author.
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the rustdoc team, which will review and decide on the PR/issue.