Re: [PATCH 1/2] kbuild: Hoist '--orphan-handling' into Kconfig

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

 



On Tue, Nov 17, 2020 at 10:03:29PM +1100, Michael Ellerman wrote:
> Nathan Chancellor <natechancellor@xxxxxxxxx> writes:
> > Currently, '--orphan-handling=warn' is spread out across four different
> > architectures in their respective Makefiles, which makes it a little
> > unruly to deal with in case it needs to be disabled for a specific
> > linker version (in this case, ld.lld 10.0.1).
> >
> > To make it easier to control this, hoist this warning into Kconfig and
> > the main Makefile so that disabling it is simpler, as the warning will
> > only be enabled in a couple places (main Makefile and a couple of
> > compressed boot folders that blow away LDFLAGS_vmlinx) and making it
> > conditional is easier due to Kconfig syntax. One small additional
> > benefit of this is saving a call to ld-option on incremental builds
> > because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.
> >
> > To keep the list of supported architectures the same, introduce
> > CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
> > gain this automatically after all of the sections are specified and size
> > asserted. A special thanks to Kees Cook for the help text on this
> > config.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1187
> > Signed-off-by: Nathan Chancellor <natechancellor@xxxxxxxxx>
> > ---
> >  Makefile                          | 6 ++++++
> >  arch/Kconfig                      | 9 +++++++++
> >  arch/arm/Kconfig                  | 1 +
> >  arch/arm/Makefile                 | 4 ----
> >  arch/arm/boot/compressed/Makefile | 4 +++-
> >  arch/arm64/Kconfig                | 1 +
> >  arch/arm64/Makefile               | 4 ----
> >  arch/powerpc/Kconfig              | 1 +
> >  arch/powerpc/Makefile             | 1 -
> 
> Acked-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx> (powerpc)
> 
> 
> >  arch/x86/Kconfig                  | 1 +
> >  arch/x86/Makefile                 | 3 ---
> >  arch/x86/boot/compressed/Makefile | 4 +++-
> >  init/Kconfig                      | 3 +++
> >  13 files changed, 28 insertions(+), 14 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 008aba5f1a20..c443afd61886 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -984,6 +984,12 @@ ifeq ($(CONFIG_RELR),y)
> >  LDFLAGS_vmlinux	+= --pack-dyn-relocs=relr
> >  endif
> >  
> > +# We never want expected sections to be placed heuristically by the
> > +# linker. All sections should be explicitly named in the linker script.
> > +ifeq ($(CONFIG_LD_ORPHAN_WARN),y)
> > +LDFLAGS_vmlinux += --orphan-handling=warn
> > +endif
> 
> This is a nit, but you can use ifdef with bool CONFIG symbols in
> Makefiles, which reads a bit nicer, eg:
> 
> ifdef CONFIG_LD_ORPHAN_WARN
> LDFLAGS_vmlinux += --orphan-handling=warn
> endif

That is indeed cleaner, I did not realize I could do that as long as the
config was a boolean. I will use that in v2, which I will send along
within the next few days to give Masahiro some time to comment.

Cheers,
Nathan



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

  Powered by Linux