Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2015 15:44:13 -0400
From:      Ed Maste <emaste@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Andriy Gapon <avg@freebsd.org>,  "freebsd-toolchain@freebsd.org" <freebsd-toolchain@freebsd.org>
Subject:   Re: clang confuses kgdb on static symbols
Message-ID:  <CAPyFy2AyhV2HO1CRAp0EVty%2BD0VJGLb-wXGC_H8rnrdeB0V=iQ@mail.gmail.com>
In-Reply-To: <2309223.qpHU2DNGVF@ralph.baldwin.cx>
References:  <562627C8.5060108@FreeBSD.org> <2309223.qpHU2DNGVF@ralph.baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
On 20 October 2015 at 13:27, John Baldwin <jhb@freebsd.org> wrote:
>
> If '-gdwarf-4' works then you can just set that in the DEBUG makeoptions as a
> test, otherwise try hacking kern.mk to disable this bit:
>
> #
> # 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

Note that Clang defaults to DWARF 2 on FreeBSD, so removing the
override in kern.mk isn't sufficient.

>From contrib/llvm/tools/clang/lib/Driver/Tools.cpp:
    else if (!A->getOption().matches(options::OPT_g0) &&
             !A->getOption().matches(options::OPT_ggdb0)) {
      // Default is dwarf-2 for Darwin, OpenBSD, FreeBSD and Solaris.
      const llvm::Triple &Triple = getToolChain().getTriple();
      if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD ||
          Triple.getOS() == llvm::Triple::FreeBSD ||
          Triple.getOS() == llvm::Triple::Solaris)
        CmdArgs.push_back("-gdwarf-2");
      else
        CmdArgs.push_back("-g");
    }

It may be time for us to remove this default from Clang.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2AyhV2HO1CRAp0EVty%2BD0VJGLb-wXGC_H8rnrdeB0V=iQ>