Skip to content
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

llvm: always include debug information for global variables #19865

Merged
merged 1 commit into from May 9, 2024

Conversation

pkova
Copy link
Contributor

@pkova pkova commented May 5, 2024

Fixes #15095

Somebody who knows these compiler internals should verify my logic here, but the conditional here does not make sense to me. Consider the following piece of code example.zig:

var globl: i32 = 0;

pub fn main() void {
    var hello: i32 = 1;
    hello += 1;
    globl += 124;
}

globl is the variable that debuggers cannot find. On master this is the relevant LLVM IR:

@example.globl = internal unnamed_addr global i32 0, align 4

With my fix this becomes:

@example.globl = internal unnamed_addr global i32 0, align 4, !dbg !13

Note the !dbg that was speculated to be the cause in the issue as well. I've verified that this fix allows debuggers to see non-exported global variables, but I'm still confused as to why this check ever existed.

@andrewrk
Copy link
Member

andrewrk commented May 9, 2024

Thanks!

@andrewrk andrewrk merged commit 4163126 into ziglang:master May 9, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zig doesn't produce global variable debug information
2 participants