rust-lang / rust-lang/rustc_codegen_cranelift
Access to global variable metadata?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 157
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 3
Description
Hello, I am writing an extension for Cranelift, for which at one point I need to determine the size of static global data.
When compiling an example codebase, with the following buffer declaration and --emit=llvm-ir enabled, I get the expected IR output:
static BUFFER: [i32; 5] = [1, 2, 3, 4, 0];
gv0 = symbol userextname0 ; DefId(0:4 ~ extension_test_example[f5b4]::BUFFER)
I discovered that the above comment is generated in the codegen_fn_body function, but failed to further narrow it down. Is it possible to determine the exact spot where DefId is converted into a GlobalValueData object?
Contributor guide
No contributing guide indexed for this repository
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 in the codegen_fn_body function and trace how the DefId shown in the emitted LLVM IR becomes a GlobalValueData object. The issue names no file or test; done would be identifying the conversion point and establishing how the static global's size metadata could be obtained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100