bytecodealliance / bytecodealliance/wasmtime
Cranelift: support different code models (i.e., relocation strategies and displacement limits)
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 135
Description
Right now, we do not have a notion of "code model", i.e., a set of definitions for ways in which external symbols are referenced. The code model affects which types of relocations we emit, and which address-generation strategies we use: for example, going through a global offset table (GOT) vs. embedding addresses directly, or using PC-relative addressing modes vs. not, or using instructions with differently-sized displacement limits. The closest concept that we have seems to be the `colocated` flag on external function references.
Ideally, we would like to add support for this as a global compiler flag so that it can influence codegen.
This came up in #1570; non-x86 architectures (such as AArch64) will need it more urgently as the displacement limits are often lower (e.g., on AArch64, +/- 128MB for calls without going through some sort of indirection or veneer).
Contributor guide
Research direction
Start by reviewing Cranelift's existing `colocated` flag for external function references and the discussion in issue #1570. Define how a global code-model setting should control relocation strategies, address-generation choices, and displacement limits across supported architectures. Done means the compiler has a coherent code-model notion that influences code generation as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100