* question about all*config and COMPILE_TEST
@ 2021-12-09 5:07 Kees Cook
2021-12-09 7:45 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2021-12-09 5:07 UTC (permalink / raw)
To: Masahiro Yamada, Arnd Bergmann; +Cc: linux-kbuild, linux-kernel
Hi,
tl;dr: is there a way to force a config default to "off" under
all*config builds, but still leave it configurable? (i.e. not "depends
on !COMPILE_TEST")
I'm trying to understand a Kconfig behavior with regard to
COMPILE_TEST. I'm able to use an "all*config" target, followed by specific
additional config changes (e.g. turning off KCOV), but I can't enable
things like DEBUG_INFO because of their "depends on !COMPILE_TEST".
Whenever I want to examine debug info from all*config build I need to
patch lib/Kconfig.debug to remove the depends. I was hoping I could,
instead do:
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 0e2de4b375f3..e8533ffc92c3 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -212,7 +212,8 @@ menu "Compile-time checks and compiler options"
config DEBUG_INFO
bool "Compile the kernel with debug info"
- depends on DEBUG_KERNEL && !COMPILE_TEST
+ depends on DEBUG_KERNEL
+ default n if COMPILE_TEST
help
If you say Y here the resulting kernel image will include
debugging info resulting in a larger kernel image.
Which would turn this off when COMPILE_TEST was enabled, but I assume it
doesn't work because an all*config target turns everything on first, and
therefore this "default" gets ignored since DEBUG_INFO already has a
value set.
I then thought I could use:
default !COMPILE_TEST
since this works:
config WERROR
bool "Compile the kernel with warnings as errors"
default COMPILE_TEST
but I think the above is a no-op: it's the same as not having
"default COMPILE_TEST" when doing an all*config build: it'll be enabled
not because of COMPILE_TEST but because of the all*config pass.
How can I make DEBUG_INFO configurable, but default off under
all*config?
Thanks!
--
Kees Cook
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: question about all*config and COMPILE_TEST
2021-12-09 5:07 question about all*config and COMPILE_TEST Kees Cook
@ 2021-12-09 7:45 ` Arnd Bergmann
2021-12-10 0:07 ` Kees Cook
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2021-12-09 7:45 UTC (permalink / raw)
To: Kees Cook
Cc: Masahiro Yamada, Arnd Bergmann, Linux Kbuild mailing list,
Linux Kernel Mailing List
On Thu, Dec 9, 2021 at 6:07 AM Kees Cook <keescook@chromium.org> wrote:
>
> tl;dr: is there a way to force a config default to "off" under
> all*config builds, but still leave it configurable? (i.e. not "depends
> on !COMPILE_TEST")
>
> I'm trying to understand a Kconfig behavior with regard to
> COMPILE_TEST. I'm able to use an "all*config" target, followed by specific
> additional config changes (e.g. turning off KCOV), but I can't enable
> things like DEBUG_INFO because of their "depends on !COMPILE_TEST".
> Whenever I want to examine debug info from all*config build I need to
> patch lib/Kconfig.debug to remove the depends. I was hoping I could,
> instead do:
This would be a minor hassle for my randconfig testing because I really
want to have DEBUG_INFO disabled when building randconfigs in order
to keep down compile times. I could however just force DEBUG_INFO=n
the same way as forcing COMPILE_TEST=y at the moment.
> I then thought I could use:
>
> default !COMPILE_TEST
>
> since this works:
>
> config WERROR
> bool "Compile the kernel with warnings as errors"
> default COMPILE_TEST
>
> but I think the above is a no-op: it's the same as not having
> "default COMPILE_TEST" when doing an all*config build: it'll be enabled
> not because of COMPILE_TEST but because of the all*config pass.
Correct. One trick that works here is to use a 'choice' statement, as those
still honor the 'default' value even for allmodconfig -- Kconfig has no
idea which one of them is the 'all' version.
> How can I make DEBUG_INFO configurable, but default off under
> all*config?
I'd try generalizing the "DWARF version" choice to offer 'none' as a
default, like
choice
prompt "Debug information"
default DEBUG_INFO_NONE if COMPILE_TEST
default DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT if DEBUG_KERNEL
config DEBUG_INFO_NONE
bool "Turn off all debug information"
config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
bool "Rely on the toolchain's implicit default DWARF version"
config DEBUG_INFO_DWARF4
bool "Generate DWARF Version 4 debuginfo"
config DEBUG_INFO_DWARF5
bool "Generate DWARF Version 5 debuginfo"
depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM ||
(AS_IS_GNU && AS_VERSION >= 23502)))
depends on !DEBUG_INFO_BTF
endchoice
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about all*config and COMPILE_TEST
2021-12-09 7:45 ` Arnd Bergmann
@ 2021-12-10 0:07 ` Kees Cook
0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2021-12-10 0:07 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Masahiro Yamada, Linux Kbuild mailing list, Linux Kernel Mailing List
On Thu, Dec 09, 2021 at 08:45:30AM +0100, Arnd Bergmann wrote:
> On Thu, Dec 9, 2021 at 6:07 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > tl;dr: is there a way to force a config default to "off" under
> > all*config builds, but still leave it configurable? (i.e. not "depends
> > on !COMPILE_TEST")
> >
> > I'm trying to understand a Kconfig behavior with regard to
> > COMPILE_TEST. I'm able to use an "all*config" target, followed by specific
> > additional config changes (e.g. turning off KCOV), but I can't enable
> > things like DEBUG_INFO because of their "depends on !COMPILE_TEST".
> > Whenever I want to examine debug info from all*config build I need to
> > patch lib/Kconfig.debug to remove the depends. I was hoping I could,
> > instead do:
>
> This would be a minor hassle for my randconfig testing because I really
> want to have DEBUG_INFO disabled when building randconfigs in order
> to keep down compile times. I could however just force DEBUG_INFO=n
> the same way as forcing COMPILE_TEST=y at the moment.
Right, yes, I want the default for DEBUG_INFO to be off for the
COMPILE_TEST=y case (for savings on speed, storage, etc), but I want to
be _able_ to turn it on when I'm doing whole-build binary comparisons or
pahole archaeology. :)
>
> > I then thought I could use:
> >
> > default !COMPILE_TEST
> >
> > since this works:
> >
> > config WERROR
> > bool "Compile the kernel with warnings as errors"
> > default COMPILE_TEST
> >
> > but I think the above is a no-op: it's the same as not having
> > "default COMPILE_TEST" when doing an all*config build: it'll be enabled
> > not because of COMPILE_TEST but because of the all*config pass.
>
> Correct. One trick that works here is to use a 'choice' statement, as those
> still honor the 'default' value even for allmodconfig -- Kconfig has no
> idea which one of them is the 'all' version.
>
> > How can I make DEBUG_INFO configurable, but default off under
> > all*config?
>
> I'd try generalizing the "DWARF version" choice to offer 'none' as a
> default, like
>
> choice
> prompt "Debug information"
> default DEBUG_INFO_NONE if COMPILE_TEST
> default DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT if DEBUG_KERNEL
>
> config DEBUG_INFO_NONE
> bool "Turn off all debug information"
>
> config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> bool "Rely on the toolchain's implicit default DWARF version"
>
> config DEBUG_INFO_DWARF4
> bool "Generate DWARF Version 4 debuginfo"
>
> config DEBUG_INFO_DWARF5
> bool "Generate DWARF Version 5 debuginfo"
> depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM ||
> (AS_IS_GNU && AS_VERSION >= 23502)))
> depends on !DEBUG_INFO_BTF
>
> endchoice
Ooooh! Yes, that's excellent. I will give that a try. Thanks!
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-10 0:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 5:07 question about all*config and COMPILE_TEST Kees Cook
2021-12-09 7:45 ` Arnd Bergmann
2021-12-10 0:07 ` Kees Cook
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.