Remove extra indirection from statics with linkage?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I just learned from @bjorn3 that the way we represent statics with linkage, such as #[linkage = "extern_weak"], is kind of strange:
unsafe extern "C" {
#[linkage = "extern_weak"]
static test_symbol_that_does_not_exist: Option<unsafe extern "C" fn()>;
}
Here, test_symbol_that_does_not_exist will actually be a global variable local to this module that points to the weak symbol.
Now that we have the &raw address-of operator, we could avoid this extra indirection. Whether we should, I do not know.
Cc @bjorn3 @nikic @chorman0773
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 with the #[linkage = "extern_weak"] example and the &raw address-of operator mentioned in the issue. Determine whether statics with linkage can avoid the module-local pointer, then define the affected behavior and validation before proposing a change; no files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100