Re: BPF vs objtool again

From: Arvind Sankar
Date: Wed Apr 29 2020 - 18:01:58 EST


On Wed, Apr 29, 2020 at 04:51:59PM -0500, Josh Poimboeuf wrote:
> On Thu, Jul 18, 2019 at 12:14:08PM -0700, tip-bot for Josh Poimboeuf wrote:
> > Commit-ID: 3193c0836f203a91bef96d88c64cccf0be090d9c
> > Gitweb: https://git.kernel.org/tip/3193c0836f203a91bef96d88c64cccf0be090d9c
> > Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > AuthorDate: Wed, 17 Jul 2019 20:36:45 -0500
> > Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > CommitDate: Thu, 18 Jul 2019 21:01:06 +0200
> >
> > bpf: Disable GCC -fgcse optimization for ___bpf_prog_run()
>
> For some reason, this
>
> __attribute__((optimize("-fno-gcse")))
>
> is disabling frame pointers in ___bpf_prog_run(). If you compile with
> CONFIG_FRAME_POINTER it'll show something like:
>
> kernel/bpf/core.o: warning: objtool: ___bpf_prog_run.cold()+0x7: call without frame pointer save/setup
>
> Also, since GCC 9.1, the GCC docs say "The optimize attribute should be
> used for debugging purposes only. It is not suitable in production
> code." That doesn't sound too promising.
>

It turns out that the optimize attribute doesn't append options to the
command-line arguments, it starts from the defaults and only adds
whatever you specify in the attribute. So it's not very useful for
production code.

See this for eg where the same thing came up in a different context.
https://lore.kernel.org/lkml/alpine.LSU.2.21.2004151445520.11688@xxxxxxxxxxxxx/