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

Use options debug format if it is provided #21995

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

bentheklutz
Copy link
Contributor

Closes #19478

As in the linked issue:

hello.zig

const std = @import("std");
pub fn main() void {
     std.debug.print("Hello, ziguana\n", .{});
}

Compilation and debug info

/home/bhetz -> zig build-obj -gdwarf64 -ODebug -target x86_64-linux hello.zig 
/home/bhetz -> objdump --dwarf=info hello.o | head -n 10

hello.o:     file format elf64-x86-64

Contents of the .debug_info section:

  Compilation Unit @ offset 0:
   Length:        0x3c779 (64-bit)
   Version:       4
   Abbrev Offset: 0
   Pointer Size:  8
/home/bhetz -> zig build-obj -gdwarf32 -ODebug -target x86-linux hello.zig 
/home/bhetz -> objdump --dwarf=info hello.o | head -n 10

hello.o:     file format elf32-i386

Contents of the .debug_info section:

  Compilation Unit @ offset 0:
   Length:        0x2c404 (32-bit)
   Version:       4
   Abbrev Offset: 0
   Pointer Size:  4

@bentheklutz
Copy link
Contributor Author

Just to confirm the existing default behavior of 32bit dwarf for linux x64 remains.

/home/bhetz -> zig build-obj -ODebug -target x86_64-linux hello.zig 
/home/bhetz -> objdump --dwarf=info hello.o | head -n 10

hello.o:     file format elf64-x86-64

Contents of the .debug_info section:

  Compilation Unit @ offset 0:
   Length:        0x2e571 (32-bit)
   Version:       4
   Abbrev Offset: 0
   Pointer Size:  8

Copy link
Member

@alexrp alexrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to return an error if the target object format doesn't support the specified debug format. But that would probably require some refactoring (e.g. moving DebugFormat to std.Target alongside ObjectFormat), so that's a problem for another day.

src/Compilation/Config.zig Outdated Show resolved Hide resolved
@alexrp alexrp enabled auto-merge (squash) November 16, 2024 15:06
@bentheklutz
Copy link
Contributor Author

Thanks for the feedback. I had the same concern about mismatching object and debug formats. I'd be happy to take a crack at that refactor here soon, but I should probably get through a few more contributor friendly issues first I think.

@alexrp alexrp merged commit 7cc7ae1 into ziglang:master Nov 16, 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.

-gdwarf64 does not produce object with 64bit DWARF debug info
2 participants