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

[elf] -gsplit-dwarf leaves the resulting file in the cache dir #11858

Open
motiejus opened this issue Jun 13, 2022 · 1 comment
Open

[elf] -gsplit-dwarf leaves the resulting file in the cache dir #11858

motiejus opened this issue Jun 13, 2022 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@motiejus
Copy link
Contributor

motiejus commented Jun 13, 2022

Zig Version

0.10.0-dev.2473+e498fb155

Steps to Reproduce

A test file for everything:

#include <stdio.h>
#include <features.h>
int main() {
    #ifdef __GLIBC__
    printf("glibc_%d.%d\n", __GLIBC__, __GLIBC_MINOR__);
    #else
    printf("non-glibc\n");
    #endif
    return 0;
}

Expected Behavior

main.dwo appears in the working directory. Like with clang-13:

$ clang-13 main.c -ggdb3 -gsplit-dwarf -o main.clang-13
$ ls -lh main*
-rwxr-xr-x 1 motiejus engineering 17K Jun 13 13:51 main.clang-13
-rw-r--r-- 1 motiejus engineering 197 Jun 13 13:28 main.c
-rw-r--r-- 1 motiejus engineering 712 Jun 13 13:51 main.dwo

Actual Behavior

When compiled with zig cc, the dwo file is not placed to the current directory:

$ zig cc  main.c -ggdb3 -gsplit-dwarf -o main.zigcc
$ ls -lh main* 
-rwxr-xr-x 1 motiejus engineering 5.4K Jun 13 13:52 main.zigcc
-rw-r--r-- 1 motiejus engineering  197 Jun 13 13:28 main.c

The resulting binary points to main.dwo in zig's cache dir:

$ readelf -wi main.zig-cc |& head -1                                                                   
main: Found separate debug object file: /home/motiejus/.cache/zig/tmp/b676a2799c666cc3-main.dwo
$ strings main.zig-cc | grep dwo
/home/motiejus/.cache/zig/tmp/38be76f262cfa3bb-main.dwo

Sure enough, the file in /home/motiejus/.cache/zig/tmp/38be76f262cfa3bb-main.dwo is correct. Point being: copying the file is not enough; the dwo file path in the resulting object file needs to be updated accordingly.

For the record, the clang-13 version points to main.dwo in the same directory:

$ strings main.clang-13 | grep dwo
main.dwo
@motiejus motiejus added the bug Observed behavior contradicts documented or intended behavior label Jun 13, 2022
@motiejus
Copy link
Contributor Author

motiejus commented Jun 14, 2022

Also see #11194 (comment): zig cc -gsplit-dwarf does not actually move the debug info to the .dwo file; it merely copies it, defeating the purpose of -gsplit-dwarf.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature labels Jun 28, 2022
@andrewrk andrewrk added this to the 0.10.0 milestone Jun 28, 2022
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Sep 14, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

2 participants