diff mbox series

efi/x86: Fix build with gcc 4

Message ID 20200605150638.1011637-1-nivedita@alum.mit.edu
State Not Applicable
Delegated to: David Miller
Headers show
Series efi/x86: Fix build with gcc 4 | expand

Commit Message

Arvind Sankar June 5, 2020, 3:06 p.m. UTC
Commit
  bbf8e8b0fe04 ("efi/libstub: Optimize for size instead of speed")

changed the optimization level for the EFI stub to -Os from -O2.

Andrey Ignatov reports that this breaks the build with gcc 4.8.5.

Testing on godbolt.org, the combination of -Os,
-fno-asynchronous-unwind-tables, and ms_abi functions doesn't work,
failing with the error:
  sorry, unimplemented: ms_abi attribute requires
  -maccumulate-outgoing-args or subtarget optimization implying it

This does appear to work with gcc 4.9 onwards.

Add -maccumulate-outgoing-args explicitly to unbreak the build with
pre-4.9 versions of gcc.

Reported-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 drivers/firmware/efi/libstub/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrey Ignatov June 5, 2020, 4:09 p.m. UTC | #1
Arvind Sankar <nivedita@alum.mit.edu> [Fri, 2020-06-05 08:06 -0700]:
> Commit
>   bbf8e8b0fe04 ("efi/libstub: Optimize for size instead of speed")
> 
> changed the optimization level for the EFI stub to -Os from -O2.
> 
> Andrey Ignatov reports that this breaks the build with gcc 4.8.5.
> 
> Testing on godbolt.org, the combination of -Os,
> -fno-asynchronous-unwind-tables, and ms_abi functions doesn't work,
> failing with the error:
>   sorry, unimplemented: ms_abi attribute requires
>   -maccumulate-outgoing-args or subtarget optimization implying it
> 
> This does appear to work with gcc 4.9 onwards.
> 
> Add -maccumulate-outgoing-args explicitly to unbreak the build with
> pre-4.9 versions of gcc.
> 
> Reported-by: Andrey Ignatov <rdna@fb.com>
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Thanks. I confirmed it fixes the problem on my setup with gcc 4.8.5 and
also works as before with clang 9.0.20190721.

> ---
>  drivers/firmware/efi/libstub/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index cce4a7436052..d67418de768c 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -6,7 +6,8 @@
>  # enabled, even if doing so doesn't break the build.
>  #
>  cflags-$(CONFIG_X86_32)		:= -march=i386
> -cflags-$(CONFIG_X86_64)		:= -mcmodel=small
> +cflags-$(CONFIG_X86_64)		:= -mcmodel=small \
> +				   $(call cc-option,-maccumulate-outgoing-args)
>  cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ \
>  				   -fPIC -fno-strict-aliasing -mno-red-zone \
>  				   -mno-mmx -mno-sse -fshort-wchar \
> -- 
> 2.26.2
>
Ard Biesheuvel June 15, 2020, 9:43 a.m. UTC | #2
On Fri, 5 Jun 2020 at 18:09, Andrey Ignatov <rdna@fb.com> wrote:
>
> Arvind Sankar <nivedita@alum.mit.edu> [Fri, 2020-06-05 08:06 -0700]:
> > Commit
> >   bbf8e8b0fe04 ("efi/libstub: Optimize for size instead of speed")
> >
> > changed the optimization level for the EFI stub to -Os from -O2.
> >
> > Andrey Ignatov reports that this breaks the build with gcc 4.8.5.
> >
> > Testing on godbolt.org, the combination of -Os,
> > -fno-asynchronous-unwind-tables, and ms_abi functions doesn't work,
> > failing with the error:
> >   sorry, unimplemented: ms_abi attribute requires
> >   -maccumulate-outgoing-args or subtarget optimization implying it
> >
> > This does appear to work with gcc 4.9 onwards.
> >
> > Add -maccumulate-outgoing-args explicitly to unbreak the build with
> > pre-4.9 versions of gcc.
> >
> > Reported-by: Andrey Ignatov <rdna@fb.com>
> > Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
>
> Thanks. I confirmed it fixes the problem on my setup with gcc 4.8.5 and
> also works as before with clang 9.0.20190721.
>

Queued in efi/urgent, thanks.

> > ---
> >  drivers/firmware/efi/libstub/Makefile | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> > index cce4a7436052..d67418de768c 100644
> > --- a/drivers/firmware/efi/libstub/Makefile
> > +++ b/drivers/firmware/efi/libstub/Makefile
> > @@ -6,7 +6,8 @@
> >  # enabled, even if doing so doesn't break the build.
> >  #
> >  cflags-$(CONFIG_X86_32)              := -march=i386
> > -cflags-$(CONFIG_X86_64)              := -mcmodel=small
> > +cflags-$(CONFIG_X86_64)              := -mcmodel=small \
> > +                                $(call cc-option,-maccumulate-outgoing-args)
> >  cflags-$(CONFIG_X86)         += -m$(BITS) -D__KERNEL__ \
> >                                  -fPIC -fno-strict-aliasing -mno-red-zone \
> >                                  -mno-mmx -mno-sse -fshort-wchar \
> > --
> > 2.26.2
> >
>
> --
> Andrey Ignatov
diff mbox series

Patch

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index cce4a7436052..d67418de768c 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -6,7 +6,8 @@ 
 # enabled, even if doing so doesn't break the build.
 #
 cflags-$(CONFIG_X86_32)		:= -march=i386
-cflags-$(CONFIG_X86_64)		:= -mcmodel=small
+cflags-$(CONFIG_X86_64)		:= -mcmodel=small \
+				   $(call cc-option,-maccumulate-outgoing-args)
 cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ \
 				   -fPIC -fno-strict-aliasing -mno-red-zone \
 				   -mno-mmx -mno-sse -fshort-wchar \