question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: clang default dwarf version being over-ridden?

See original GitHub issue

Describe the bug

Consider: https://godbolt.org/z/3Wd8q8fax

I’m trying to find which version of clang defaulted to dwarf-v5 implicitly when -g is used. I know clang switched to dwarf-v5 recently, but godbolt shows clang trunk emitting dwarf-v4 (there’s an assembler directive denoting the dwarf version in the output).

.short  4                               # DWARF version number

Steps to reproduce

enable -g for clang trunk (should be clang-16 today)

Expected behavior

.short  5                               # DWARF version number

is what I get locally for clang trunk.

Is godbolt overriding this somehow?

Reproduction link

https://godbolt.org/z/3Wd8q8fax

Screenshots

Not applicable

Operating System

No response

Browser version

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
nickdesaulnierscommented, Aug 26, 2022

Seems like GNU objdump can’t figure this out.

$ cat x.cpp
int square(int num) {
    return num * num;
}

int main () {
    return square(3);
}
$ g++ -g -gdwarf-5 x.cpp
$ objdump -dl a.out | grep main\>: -A 13
0000000000001138 <main>:
main():
/tmp/x.cpp:5
    1138:	55                   	push   %rbp
    1139:	48 89 e5             	mov    %rsp,%rbp
/tmp/x.cpp:6
    113c:	bf 03 00 00 00       	mov    $0x3,%edi
    1141:	e8 e3 ff ff ff       	call   1129 <_Z6squarei>
    1146:	90                   	nop
/tmp/x.cpp:7
    1147:	5d                   	pop    %rbp
    1148:	c3                   	ret
    1149:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
$ llvm-objdump -dl a.out| grep main\>: -A 13
0000000000001138 <main>:
; main():
; /tmp/x.cpp:5
    1138: 55                           	pushq	%rbp
    1139: 48 89 e5                     	movq	%rsp, %rbp
; /tmp/x.cpp:6
    113c: bf 03 00 00 00               	movl	$3, %edi
    1141: e8 e3 ff ff ff               	callq	0x1129 <_Z6squarei>
    1146: 90                           	nop
; /tmp/x.cpp:7
    1147: 5d                           	popq	%rbp
    1148: c3                           	retq
    1149: 0f 1f 80 00 00 00 00         	nopl	(%rax)
$ clang++ -g -gdwarf-5 x.cpp
$ llvm-objdump -dl a.out| grep main\>: -A 13
0000000000001140 <main>:
; main():
; /tmp/x.cpp:5
    1140: 55                           	pushq	%rbp
    1141: 48 89 e5                     	movq	%rsp, %rbp
    1144: 48 83 ec 10                  	subq	$16, %rsp
    1148: c7 45 fc 00 00 00 00         	movl	$0, -4(%rbp)
; /tmp/x.cpp:6
    114f: bf 03 00 00 00               	movl	$3, %edi
    1154: e8 d7 ff ff ff               	callq	0x1130 <_Z6squarei>
    1159: 48 83 c4 10                  	addq	$16, %rsp
    115d: 5d                           	popq	%rbp
    115e: c3                           	retq
    115f: 90                           	nop
$ objdump -dl a.out | grep main\>: -A 13    
0000000000001140 <main>:
main():
<unknown>:5
    1140:	55                   	push   %rbp
    1141:	48 89 e5             	mov    %rsp,%rbp
    1144:	48 83 ec 10          	sub    $0x10,%rsp
    1148:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%rbp)
<unknown>:6
    114f:	bf 03 00 00 00       	mov    $0x3,%edi
    1154:	e8 d7 ff ff ff       	call   1130 <_Z6squarei>
    1159:	48 83 c4 10          	add    $0x10,%rsp
    115d:	5d                   	pop    %rbp
    115e:	c3                   	ret
    115f:	90                   	nop

so testing [g++, clang++] x [objdump, llvm-objdump], it seems that it is GNU objdump that doesn’t understand the output from clang++; llvm-objdump supports both compilers.

I’ve filed https://sourceware.org/bugzilla/show_bug.cgi?id=29529 against GNU objdump.

1reaction
nickdesaulnierscommented, Aug 30, 2022

This has been fixed up ToT GNU objdump. It just missed the 2.39 release, so probably whatever is after that should have the fix. Leaving this open until that release exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

⚙ D69822 [clang] Add new -fdebug-default-version flag.
This adds a new flag '-fdebug-default-version=N' that sets the version of DWARF to be generated, but does not turn on/off debug info generation....
Read more >
Clang Compiler User's Manual
Introduction¶. The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation...
Read more >
Clang command line argument reference
Default is 'hash'. This option will be overridden by option '-cuid=[ID]' if it is specified. Don't error out if the detected version of...
Read more >
Diagnostic flags in Clang — Clang 16.0.0git documentation
warning: checker plugin 'A' is not compatible with this version of the analyzer ... This diagnostic is an error by default, but the...
Read more >
Clang 16.0.0git (In-Progress) Release Notes
Due to the extended period of time this bug was present in major C++ implementations (including Clang), this error has the ability to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found