diff mbox series

[v4,bpf] kbuild: fix dependencies for DEBUG_INFO_BTF

Message ID 20200402153335.38447-1-slava@bacher09.org (mailing list archive)
State New, archived
Headers show
Series [v4,bpf] kbuild: fix dependencies for DEBUG_INFO_BTF | expand

Commit Message

Slava Bacherikov April 2, 2020, 3:33 p.m. UTC
Currently turning on DEBUG_INFO_SPLIT when DEBUG_INFO_BTF is also
enabled will produce invalid btf file, since gen_btf function in
link-vmlinux.sh script doesn't handle *.dwo files.

Enabling DEBUG_INFO_REDUCED will also produce invalid btf file, and
using GCC_PLUGIN_RANDSTRUCT with BTF makes no sense.

Signed-off-by: Slava Bacherikov <slava@bacher09.org>
Reported-by: Jann Horn <jannh@google.com>
Reported-by: Liu Yiding <liuyd.fnst@cn.fujitsu.com>
Acked-by: KP Singh <kpsingh@google.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Fixes: e83b9f55448a ("kbuild: add ability to generate BTF type info for vmlinux")
---
 lib/Kconfig.debug | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Slava Bacherikov April 2, 2020, 3:40 p.m. UTC | #1
02.04.2020 18:33, Slava Bacherikov wrote:
> +	depends on DEBUG_INFO || COMPILE_TEST

Andrii are you fine by this ?
Andrii Nakryiko April 2, 2020, 7:31 p.m. UTC | #2
On Thu, Apr 2, 2020 at 8:40 AM Slava Bacherikov <slava@bacher09.org> wrote:
>
>
>
> 02.04.2020 18:33, Slava Bacherikov wrote:
> > +     depends on DEBUG_INFO || COMPILE_TEST
>
> Andrii are you fine by this ?

I think it needs a good comment explaining this weirdness, at least.
As I said, if there is no DEBUG_INFO, there is not point in doing
DWARF-to-BTF conversion, even more -- it actually might fail, I
haven't checked what pahole does in that case. So I'd rather drop
GCC_PLUGIN_RANDSTRUCT is that's the issue here. DEBUG_INFO_SPLIT and
DEBUG_INFO_REDUCED look good.
Kees Cook April 2, 2020, 8:34 p.m. UTC | #3
On Thu, Apr 02, 2020 at 12:31:36PM -0700, Andrii Nakryiko wrote:
> On Thu, Apr 2, 2020 at 8:40 AM Slava Bacherikov <slava@bacher09.org> wrote:
> >
> >
> >
> > 02.04.2020 18:33, Slava Bacherikov wrote:
> > > +     depends on DEBUG_INFO || COMPILE_TEST
> >
> > Andrii are you fine by this ?
> 
> I think it needs a good comment explaining this weirdness, at least.
> As I said, if there is no DEBUG_INFO, there is not point in doing
> DWARF-to-BTF conversion, even more -- it actually might fail, I
> haven't checked what pahole does in that case. So I'd rather drop
> GCC_PLUGIN_RANDSTRUCT is that's the issue here. DEBUG_INFO_SPLIT and
> DEBUG_INFO_REDUCED look good.

The DEBUG_INFO is separate, AIUI -- it sounds like BTF may entirely
break on a compile with weird DWARF configs.

The GCC_PLUGIN_RANDSTRUCT issue is separate: it doesn't make sense to
run a kernel built with BTF and GCC_PLUGIN_RANDSTRUCT. But they should
have nothing to do with each other with regard to compilation. So, to
keep GCC_PLUGIN_RANDSTRUCT disable for "real" builds but leave it on for
all*config, randconfig, etc, I'd like to keep the || COMPILE_TEST,
otherwise GCC_PLUGIN_RANDSTRUCT won't be part of the many CIs doing
compilation testing.

And FWIW, I'm fine to let GCC_PLUGIN_RANDSTRUCT and BTF build together.
But if they want to be depends-conflicted, I wanted to keep the test
compile trap door.
Slava Bacherikov April 2, 2020, 8:38 p.m. UTC | #4
02.04.2020 23:34, Kees Cook wrote:
> On Thu, Apr 02, 2020 at 12:31:36PM -0700, Andrii Nakryiko wrote:
>> On Thu, Apr 2, 2020 at 8:40 AM Slava Bacherikov <slava@bacher09.org> wrote:
>>>
>>>
>>>
>>> 02.04.2020 18:33, Slava Bacherikov wrote:
>>>> +     depends on DEBUG_INFO || COMPILE_TEST
>>>
>>> Andrii are you fine by this ?
>>
>> I think it needs a good comment explaining this weirdness, at least.
>> As I said, if there is no DEBUG_INFO, there is not point in doing
>> DWARF-to-BTF conversion, even more -- it actually might fail, I
>> haven't checked what pahole does in that case. So I'd rather drop
>> GCC_PLUGIN_RANDSTRUCT is that's the issue here. DEBUG_INFO_SPLIT and
>> DEBUG_INFO_REDUCED look good.

Yesterday before sending it I tested it against latest bpf git with
allyesconfig and it compiled fine, even worked in vm ;)
> 
> The DEBUG_INFO is separate, AIUI -- it sounds like BTF may entirely
> break on a compile with weird DWARF configs.
> 
> The GCC_PLUGIN_RANDSTRUCT issue is separate: it doesn't make sense to
> run a kernel built with BTF and GCC_PLUGIN_RANDSTRUCT. But they should
> have nothing to do with each other with regard to compilation. So, to
> keep GCC_PLUGIN_RANDSTRUCT disable for "real" builds but leave it on for
> all*config, randconfig, etc, I'd like to keep the || COMPILE_TEST,
> otherwise GCC_PLUGIN_RANDSTRUCT won't be part of the many CIs doing
> compilation testing.
> 
> And FWIW, I'm fine to let GCC_PLUGIN_RANDSTRUCT and BTF build together.
> But if they want to be depends-conflicted, I wanted to keep the test
> compile trap door.
> 

Oh, seems I misunderstood you, if everyone agree I'll drop it.
diff mbox series

Patch

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f61d834e02fe..b94227be2d62 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -222,7 +222,9 @@  config DEBUG_INFO_DWARF4
 
 config DEBUG_INFO_BTF
 	bool "Generate BTF typeinfo"
-	depends on DEBUG_INFO
+	depends on DEBUG_INFO || COMPILE_TEST
+	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
+	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
 	help
 	  Generate deduplicated BTF type information from DWARF debug info.
 	  Turning this on expects presence of pahole tool, which will convert