lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKwvOdn1Shqc3nW6z0Ji_=4uMrOimhUbX3TRG7fQuysja64zog@mail.gmail.com>
Date:   Mon, 5 Nov 2018 09:59:09 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:     Stefan Agner <stefan@...er.ch>,
        Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Kees Cook <keescook@...omium.org>,
        Matthias Kaehlcke <mka@...omium.org>,
        Chris Fries <cfries@...gle.com>, joel@....id.au,
        dja@...ens.net, Michal Marek <michal.lkml@...kovi.net>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kbuild: consolidate Clang compiler flags

On Mon, Nov 5, 2018 at 1:19 AM Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
>
> On Mon, Nov 5, 2018 at 6:10 PM Stefan Agner <stefan@...er.ch> wrote:
> >
> > On 05.11.2018 03:48, Masahiro Yamada wrote:
> > > Add basic options for Clang such as --target, --prefix, --gcc-toolchain,
> > > -no-integrated-as to a single variable CLANG_FLAGS.
> > >
> > > Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
> > > ---
> > >
> > >  Makefile | 13 ++++++-------
> > >  1 file changed, 6 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 93315eb..58c838a 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -487,18 +487,17 @@ endif
> > >
> > >  ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
> > >  ifneq ($(CROSS_COMPILE),)
> > > -CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
> > > +CLANG_FLAGS  = --target=$(notdir $(CROSS_COMPILE:%-=%))
> > >  GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
> > > -CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)
> > > +CLANG_FLAGS  += --prefix=$(GCC_TOOLCHAIN_DIR)
> >
> > So this will expand later now, is this ok?
> >
> > --
> > Stefan
> >
> > >  GCC_TOOLCHAIN        := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
> > >  endif
> > >  ifneq ($(GCC_TOOLCHAIN),)
> > > -CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
> > > +CLANG_FLAGS  += --gcc-toolchain=$(GCC_TOOLCHAIN)
> > >  endif
> > > -KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> > > -KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> > > -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
> > > -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
> > > +CLANG_FLAGS  += $(call cc-option, -no-integrated-as)
> > > +KBUILD_CFLAGS        += $(CLANG_FLAGS)
> > > +KBUILD_AFLAGS        += $(CLANG_FLAGS)
>
>
> CLANG_FLAGS is expanded here because KBUILD_CFLAGS and KBUILD_AFLAGS
> are defined by using :=
>
> So, it should be OK, but turning CLANG_FLAGS into a simple variable
> will be a little more efficient since $(call cc-option, -no-integrated-as)
> is evaluated just once.
>
> (Or, this cc-option may not be necessary any longer.)
>
> Will send v2.

If the ultimate goal is not evaluate cc-option more than once,
removing cc-option from both KBUILD_CFLAGS and KBUILD_AFLAGS for clang
is the better approach; we always want those for clang
unconditionally. And if you by chance have an ancient version of clang
that doesn't support those flags, you wont be able to compile a kernel
anyways.  Eventually we want to get Clang's integrated assembler in
shape to be used to assemble the kernel, but I think we're a ways off
there still.


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ