Page MenuHomeFreeBSD

clang: default to DWARF 4 as of FreeBSD 12
AcceptedPublic

Authored by emaste on Nov 9 2018, 7:23 PM.

Details

Reviewers
dim
jhb
markj
Summary

I had this change sitting in my working tree for some time; posted for discussion. We should make the change upstream.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

emaste updated this revision to Diff 50226.Nov 9 2018, 7:23 PM
emaste created this revision.

Upload correct diff

Any objections to this change? Are folks happy with `< 12` as here or shall I make it `< 13`?
kib added a comment.Fri, Jan 11, 1:50 AM

Are -g kernels compiled with dwarf2 or dwarf4 after this change ? If 4, then /usr/libexec/kgdb becomes unusable, and what about crashinfo ?

Via sys/conf/kern.mk:

#
# Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
# and gcc 4.8 is to generate DWARF version 4. However, our tools don't
# cope well with DWARF 4, so force it to genereate DWARF2, which they
# understand. Do this unconditionally as it is harmless when not needed,
# but critical for these newer versions.
#
.if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
CFLAGS+=        -gdwarf-2
.endif

Further to the comment The default starting in clang v3.4 ... is to generate DWARF version 4, I'm not sure if Clang defaulted to version 4 and someone later added the FreeBSD special case to go back to 2, or the comment is based on a misunderstanding. I may just change the comment to something like Newer compilers generate version 4 by default, but our old /usr/libexec/gdb .... (Other tools have been updated to handle DWARF4.)

markj accepted this revision.Fri, Jan 11, 8:43 PM

ISTR a comment somewhere mentioning that DWARF2 was required on FreeBSD, but maybe it's gone in newer versions.

This revision is now accepted and ready to land.Fri, Jan 11, 8:43 PM

Since 12 is already out and using 2, shouldn't that be <= 12?

dim added a comment.Fri, Jan 11, 9:21 PM

Further to the comment The default starting in clang v3.4 ... is to generate DWARF version 4, I'm not sure if Clang defaulted to version 4 and someone later added the FreeBSD special case to go back to 2, or the comment is based on a misunderstanding. I may just change the comment to something like Newer compilers generate version 4 by default, but our old /usr/libexec/gdb .... (Other tools have been updated to handle DWARF4.)

I remember that we set the DWARF version to 2 first, and when in a later version of clang I tried to bump it to 4, it got very quickly shot down. :) Hopefully it'll be more accepted now.

exp-run requested in PR234887

Since 12 is already out and using 2, shouldn't that be <= 12?

I think it's fine to switch the default when targeting 12 actually. The only tool left which does not handle DWARF>2 is /usr/libexec/gdb, which should be used only for kernel core dumps when the gdb port is not installed, and the kernel build explicitly adds -gdwarf2.

dim added a comment.Sat, Jan 12, 6:56 PM

Note, this should be upstreamed as well. @emaste if you didn't do the new LLVM license stuff already, I'll commit it there, when we've reached concensus.

pi added a subscriber: pi.Sat, Jan 12, 7:02 PM

What of using libexec/gdb ? WITH_GDB is still the default except on aarch64 and riscv64* . There are architectures for which modern gdb from ports fails ( by running into bugs in C++ thrown-exception support in the system libgc_s ): powerpc families. (I experiment with using more modern compilers. clang has issues of its own but devel/powerpc64-gcc for powerpc64 targeting is useful for buildworld buildkernel and more. I have a patched libgcc_s that I reported on the lists but most folks do not have.)