Function alignment does not work on wasm
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
For #[align], see the error here and the discussion here. I assume this also affects -Zmin-function-align.
In wasm, functions don't have an "address", it's not a von-Neumann architecture. Instead, there is a dedicated table and one can pick an integer index into the table when doing a dynamic call. So the actual address of a function cannot be observed and "aligning" it has no meaning. However, the fn ptr value can be observed by being cast to an integer, and then one will see the index into that table. One could attempt to align that but it seems not very useful...
Apart from the usefulness, I guess the question is what can we do?
- Error when the attribute is used on wasm, since relying on fn ptr being divisible by N will just not work
- Try to convince LLVM to implement this (is there an LLVM issue?)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the error in the linked rust-lang/rust#143313 discussion and the related discussion in rust-lang/rust#143206. Investigate how #[align] and -Zmin-function-align are handled for wasm; done means establishing and implementing a clear wasm-specific behavior, whether rejection or supported alignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100