Messages in this thread | | | From | Nick Desaulniers <> | Date | Thu, 23 Apr 2020 11:02:09 -0700 | Subject | Re: [PATCH] x86: Fix early boot crash on gcc-10, next try |
| |
On Thu, Apr 23, 2020 at 10:31 AM Borislav Petkov <bp@alien8.de> wrote: > > On Thu, Apr 23, 2020 at 06:12:24PM +0200, Borislav Petkov wrote: > > Ok, > > > > I have tried to summarize our odyssey so far and here's what I came up > > with. Just built latest gcc from the git repo and it seems to work. > > > > Next I need to come up with a slick way of testing the compiler... > > Maybe something like this. Seems to work with both. > > --- > From: Borislav Petkov <bp@suse.de> > Date: Thu, 23 Apr 2020 19:28:28 +0200 > Subject: [PATCH] Check compiler > > Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
It's too bad that $(CC) isn't exported yet; IIUC we include the arch specific Makefiles then later export $(CC). If that was the case, we could just use $(CC) in the shell script, rather than passing it along as an argument. Oh well.
> --- > arch/x86/Makefile | 4 ++++ > scripts/x86-check-compiler.sh | 9 +++++++++ > 2 files changed, 13 insertions(+) > create mode 100755 scripts/x86-check-compiler.sh > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 00e378de8bc0..38d3eec5062e 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -1,6 +1,10 @@ > # SPDX-License-Identifier: GPL-2.0 > # Unified Makefile for i386 and x86_64 > > +# Check the compiler > +sane_compiler := $(shell $(srctree)/scripts/x86-check-compiler.sh $(CC)) > +$(if $(sane_compiler),$(error $(CC) check failed. Aborting),)
If I add `echo "hello world"` to the end of scripts/x86-check-compiler.sh to verify this stops a build, this is the error message I would observe: arch/x86/Makefile:6: *** clang check failed. Aborting. Stop.
> + > # select defconfig based on actual architecture > ifeq ($(ARCH),x86) > ifeq ($(shell uname -m),x86_64) > diff --git a/scripts/x86-check-compiler.sh b/scripts/x86-check-compiler.sh > new file mode 100755 > index 000000000000..b2b5b54b6939 > --- /dev/null > +++ b/scripts/x86-check-compiler.sh > @@ -0,0 +1,9 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +# Check whether the compiler tail-call optimizes across an asm() statement. > +# Fail the build if it does. > + > +echo "int foo(int a); int bar(int a) { int r = foo(a); asm(\"\"); return r; }" |\ > + $* -O2 -x c -c -S - -o - 2>/dev/null |\ > + grep -E "^[[:blank:]]+jmp[[:blank:]]+.*" > -- > 2.21.0 > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette
-- Thanks, ~Nick Desaulniers
| |