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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdnU5qBqOroEkjf=n-R_rpXxAVx2NhA2wKfasmOPTf6K6Q@mail.gmail.com>
Date:   Tue, 6 Sep 2022 20:12:42 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     Nathan Chancellor <nathan@...nel.org>,
        Michal Marek <michal.lkml@...kovi.net>,
        Tom Rix <trix@...hat.com>,
        Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        clang-built-linux <llvm@...ts.linux.dev>,
        X86 ML <x86@...nel.org>,
        Dmitrii Bundin <dmitrii.bundin.a@...il.com>,
        Fangrui Song <maskray@...gle.com>,
        Alexey Alexandrov <aalexand@...gle.com>,
        Bill Wendling <morbo@...gle.com>,
        Greg Thelen <gthelen@...gle.com>
Subject: Re: [PATCH v2 2/5] Makefile.compiler: Use KBUILD_AFLAGS for as-option

On Mon, Sep 5, 2022 at 2:11 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> On Thu, Sep 1, 2022 at 4:53 AM Nathan Chancellor <nathan@...nel.org> wrote:
> >
> > On Wed, Aug 31, 2022 at 11:44:05AM -0700, Nick Desaulniers wrote:
> > > as-instr uses KBUILD_AFLAGS, but as-option uses KBUILD_CFLAGS.  This can
> > > cause as-option to fail unexpectedly because clang will emit
> > > -Werror,-Wunused-command-line-argument for various -m and -f flags for
> > > assembler sources.
> >
> > Now that I am looking closer at it, where does that '-Werror' come from?
>
>
>
>
> The related commit is
> c3f0d0bc5b01ad90c45276952802455750444b4f
>
> The previous discussion with Arnd is
> https://lore.kernel.org/linux-kbuild/20170314213724.3836900-1-arnd@arndb.de/
>
>
>
>
>
> > For cc-option, we add it to elevate clang's warnings about unused '-f',
> > '-m', and '-W' flags to errors so that we do not add those flags.
> > However, I do not see '-Werror' in as-option. I am going to assume it
> > came from CONFIG_WERROR, as I believe Android has that turned on by
> > default.
>
>
> CONFIG_WERROR is added to CFLAGS.
> But, I guess it is more correct to do likewise for others.
> (https://patchwork.kernel.org/project/linux-kbuild/patch/20220905083619.672091-1-masahiroy@kernel.org/)
>
>
>
> > I think that is the real problem: without '-Werror', the only
> > error that should come from as-option is when an option isn't supported
> > by the assembler, as clang will still warn but those will not be fatal
> > but with '-Werror', those warnings turn fatal, causing all subsequent
> > as-option calls to fail.
>
>
>
> Presumably, it is correct to add -Werror to as-option as well.
> We have no reason to add it to cc-option, but not to as-option.
>
>
>
>
> I also believe '-x assembler' should be changed to
> '-x assembler-with-cpp'.
>
>
> As I mentioned somewhere before, our assembly code (*.S) is always
> preprocessed. There is no *.s file in the kernel source tree.
>
>
> So, '-x assembler-with-cpp' matches the real situation.

Should I do this for as-instr then as well? In the same patch?

>
>
> One interesting thing is, clang does not warn
> [-Wunused-command-line-argument] for *.S files.
>
>
>
>
> $ clang -fomit-frame-pointer -c -x assembler /dev/null -o /dev/null
> clang: warning: argument unused during compilation:
> '-fomit-frame-pointer' [-Wunused-command-line-argument]
>
> $ clang -fomit-frame-pointer -c -x assembler-with-cpp /dev/null -o /dev/null
>
>
>
> The root cause is we are using '-x assembler', which
> never happens in the kernel tree.
>
>
>
>
> To sum up, the code I think correct is:
>
>
> as-option = $(call try-run,\
>    $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp
> /dev/null -o "$$TMP",$(1),$(2))

Does your recent patch affect this?
https://lore.kernel.org/linux-kbuild/20220905083619.672091-1-masahiroy@kernel.org/
If so, then I should not add -Werror as you suggest above?

-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ