Re: Introduce CONFIG_DEBUG_INFO_AS_DWARF2 and CONFIG_DEBUG_INFO_AS_DWARF4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 26, 2020 at 2:11 PM Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>
> On Sun, Aug 16, 2020 at 2:14 PM Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
> >
> > Hi Masahiro,
> >
> > I wondered why my generated linux-image-db Debian packages were so big
> > when I use GCC toolchain instead of LLVM toolchain.
> >
> > It turned out I mixed both...
> >
> >    KBUILD_AFLAGS += -Wa,-gdwarf-2
> >
> > ...together with...
> >
> >    DEBUG_CFLAGS += -gdwarf-4
> >
> > ...when CONFIG_DEBUG_INFO_DWARF4=y is set.
> >
> > So I hacked up something like the following to prevent this:
> >
> > diff --git a/Makefile b/Makefile
> > index 24a4c1b97bb0..e7a8e47b0e34 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -815,7 +815,11 @@ DEBUG_CFLAGS       += -gsplit-dwarf
> >  else
> >  DEBUG_CFLAGS   += -g
> >  endif
> > +ifdef CONFIG_DEBUG_INFO_AS_DWARF2
> >  KBUILD_AFLAGS  += -Wa,-gdwarf-2
> > +else ifdef CONFIG_DEBUG_INFO_AS_DWARF4
> > +KBUILD_AFLAGS  += -Wa,-gdwarf-4
> > +endif
> >  endif
> >  ifdef CONFIG_DEBUG_INFO_DWARF4
> >  DEBUG_CFLAGS   += -gdwarf-4
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index 9ad9210d70a1..9f11fc71462c 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -257,10 +257,23 @@ config DEBUG_INFO_SPLIT
> >           to know about the .dwo files and include them.
> >           Incompatible with older versions of ccache.
> >
> > +config DEBUG_INFO_AS_DWARF2
> > +       bool "Use DWARF-2 assembler option with debuginfo"
> > +       depends on $(cc-option,-Wa$(comma)-gdwarf-2)
> > +       help
> > +         Set DWARF-2 assembler option with debuginfo
> > +
> > +config DEBUG_INFO_AS_DWARF4
> > +       bool "Use DWARF-4 assembler option with debuginfo"
> > +       depends on $(cc-option,-Wa$(comma)-gdwarf-4)
> > +       help
> > +         Set DWARF-4 assembler option with debuginfo
> > +
> >  config DEBUG_INFO_DWARF4
> >         bool "Generate dwarf4 debuginfo"
> >         depends on DEBUG_INFO
> >         depends on $(cc-option,-gdwarf-4)
> > +       select DEBUG_INFO_AS_DWARF4
> >         help
> >           Generate dwarf4 debug info. This requires recent versions
> >           of gcc and gdb. It makes the debug information larger.
> >
> > NOTE: This is on top of Linux v5.8 vanilla.
> >
> > NOTE-2: When building with LLVM toolchain v11.0.0-rc1+ and especially
> > with LLVM_IAS=1 (and LLVM=1) DWARF version 4 is a good choice.
> >
> > For details see below links.
> >
> > Thoughts?
> >
> > Regards,
> > - Sedat -
> >
> > [1] https://github.com/ClangBuiltLinux/linux/issues/1086
> > [2] https://github.com/ClangBuiltLinux/linux/issues/1086#issuecomment-674503335
> > [3] https://github.com/ClangBuiltLinux/linux/issues/1086#issuecomment-674517876
>
> [ CC Sami ]
>
> Hi,
>
> while playing with Clang-CFI I needed this patch to fix these warnings:
>
> $ grep DWARF BROKEN_DWARF2-only-supports-one-section-per-compilation-unit.txt
> arch/x86/crypto/twofish-avx-x86_64-asm_64.S:17:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/twofish-avx-x86_64-asm_64.S:22:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/serpent-avx-x86_64-asm_64.S:17:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/serpent-avx-x86_64-asm_64.S:21:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/serpent-avx2-asm_64.S:18:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/serpent-avx2-asm_64.S:23:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/serpent-avx2-asm_64.S:28:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/des3_ede-asm_64.S:534:1: warning: DWARF2 only supports
> one section per compilation unit
> arch/x86/crypto/camellia-aesni-avx-asm_64.S:577:1: warning: DWARF2
> only supports one section per compilation unit
> arch/x86/crypto/camellia-aesni-avx-asm_64.S:717:1: warning: DWARF2
> only supports one section per compilation unit
> <instantiation>:2:2: warning: DWARF2 only supports one section per
> compilation unit
> <instantiation>:8:2: warning: DWARF2 only supports one section per
> compilation unit
> <instantiation>:13:2: warning: DWARF2 only supports one section per
> compilation unit
> arch/x86/crypto/camellia-aesni-avx2-asm_64.S:610:1: warning: DWARF2
> only supports one section per compilation unit
> arch/x86/crypto/camellia-aesni-avx2-asm_64.S:618:1: warning: DWARF2
> only supports one section per compilation unit
> arch/x86/crypto/camellia-aesni-avx2-asm_64.S:625:1: warning: DWARF2
> only supports one section per compilation unit
> arch/x86/crypto/camellia-aesni-avx2-asm_64.S:754:1: warning: DWARF2
> only supports one section per compilation unit
> <instantiation>:2:2: warning: DWARF2 only supports one section per
> compilation unit
> <instantiation>:8:2: warning: DWARF2 only supports one section per
> compilation unit
> <instantiation>:13:2: warning: DWARF2 only supports one section per
> compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:183:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:187:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:191:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:196:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:200:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast5-avx-x86_64-asm_64.S:204:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast6-avx-x86_64-asm_64.S:213:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast6-avx-x86_64-asm_64.S:232:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast6-avx-x86_64-asm_64.S:237:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/cast6-avx-x86_64-asm_64.S:242:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/aegis128-aesni-asm.S:27:1: warning: DWARF2 only
> supports one section per compilation unit
> arch/x86/crypto/aegis128-aesni-asm.S:36:1: warning: DWARF2 only
> supports one section per compilation unit
>
> Can you please review?
>
> Thanks.
>
> Regards,
> - Sedat -
>
> P.S.: With the help of Sami I can now build and boot into Linux-kernel
> with Clang-CFI support enabled.
>
> [1] https://github.com/samitolvanen/linux/commits/clang-cfi

Some more informations to clarify this is really needed.

I switched over to DWARF version 4 when dealing with Clang-IAS
(integrated assembler).
And saw similar problems.

This was always with...

CONFIG_DEBUG_INFO_DWARF4=y

There are 156 places here on x86 64bit...

[ Clang-CFI ]

$ grep '\-Wa,-gdwarf-4' build-log_5.9.0-rc2-5-amd64-llvm11-cfi.txt | wc -l
156

[ Clang-LTO ]

$ grep '\-Wa,-gdwarf-4' build-log_5.9.0-rc2-6-amd64-clang-lto.txt | wc -l
156

- Sedat -



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux