-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for the #[wasm_custom_section] attribute #51088
Comments
…lexcrichton Ensure every unstable language feature has a tracking issue. Filled in the missing numbers: * `abi_ptx` → #38788 * `generators` → #43122 * `global_allocator` → #27389 Reused existing tracking issues because they were decomposed from a larger feature * `*_target_feature` → #44839 (reusing the old `target_feature` number) * `proc_macros_*` → #38356 (reusing the to-be-stabilized `proc_macros` number) Filed new issues * `exhaustive_patterns` → #51085 * `pattern_parentheses` → #51087 * `wasm_custom_section` and `wasm_import_module` → #51088
I've commandeered this issue for just |
This comment has been minimized.
This comment has been minimized.
Similar to #52090 I think this feature is ready enough for stabilization now, could I perhaps persuade a member of @rust-lang/compiler to start the FCP for this issue? There's a description of how this issue works in the OP. Additionally, cc @rust-lang/wg-wasm, y'all are probably interested too! For me the motivation for this issue is to ensure that |
Questions:
|
If the same section name is used multiple times within a crate, rustc currently accepts this (http://play.rust-lang.org/?gist=d586d1b74b220b29579472bca8f4167d&version=nightly&mode=debug&edition=2015) but I'm fairly certain that this causes an undefined ordering. Especially with incremental involved. Even if it doesn't, reordering modules with sections inside will cause these sections to be reordered. I'm assuming we could just forbid using the same section name twice within a single crate? |
The general idea I had here was that
A good question! If we went with So originally I chose a different attribute because it could (a) be unstable vs Correct it is accepted multiple times within one crate! Also correct that there's a somewhat undefined ordering coming out the other end. I don't think the problem is exclusively within one crate though in that you can't really say much about orderings between crates either. In general I believe this just means that you either have to design custom sections to be unique or binary-concatenatable-yet-still-understandable. Another motivation for supporting multiple uses within a crate is that each |
@rfcbot fcp merge |
Team member @oli-obk has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I prefer |
Note that if |
@alexcrichton wait, why the byte restriction? You can get the byte contents of any |
@eddyb Ok cool! That may be possible yeah. In that sense this could also be an issue in that case to change to:
Denying relocations means denying this, right? #[link_section = "foo"]
static A: &u8 = &1; |
@alexcrichton Yeah. |
@eddyb hm but it still leaves a weird question I think in terms of: #[link_section = "foo"]
static A: u8 = 8;
fn main() {
println!("{}", A);
} This means that |
@alexcrichton IIRC at least in ELF sections can be marked as not being loaded to memory at all, I wonder what happens then! My guess is either the relocation in |
This commit transitions definitions of custom sections on the wasm target from the unstable `#[wasm_custom_section]` attribute to the already-stable-for-other-targets `#[link_section]` attribute. Mostly the same restrictions apply as before, except that this now applies only to statics. Closes rust-lang#51088
rustc: Use link_section, not wasm_custom_section This commit transitions definitions of custom sections on the wasm target from the unstable `#[wasm_custom_section]` attribute to the already-stable-for-other-targets `#[link_section]` attribute. Mostly the same restrictions apply as before, except that this now applies only to statics. Closes #51088
This issue tracks the
wasm_custom_section
attribute which is used to define the contents of a custom section in the wasm executable.cc rustwasm/team#82.
The attribute is used like so:
The attribute in its current form can only be applied to
const
values and must be of the form[u8; N]
. The attribute also must be of the form#[wasm_custom_section = "name"]
.Custom sections are a feature of the WebAssembly binary encoding. They are intended to allow wasm files to encode arbitrary information useful for tools like debuggers, profilers, or transformations like
wasm-bindgen
. Each custom section must have a UTF-8 name and a payload of bytes. There is no restricton on the name or payload otherwise.The linker, LLD, for the wasm target will concatenate custom sections of the same name in the order the objects appear on the comand line. For example if both crate
a
and crateb
define a custom section with the namefoo
the final output will contain only one custom section with the name offoo
where the contents ofa
andb
are concatenated (byte-wise).Helpful links:
The text was updated successfully, but these errors were encountered: