diff mbox series

powerpc/boot: Fix compilation of uImage for e500 platforms

Message ID 20220820105200.30425-1-pali@kernel.org (mailing list archive)
State Superseded
Headers show
Series powerpc/boot: Fix compilation of uImage for e500 platforms | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.

Commit Message

Pali Rohár Aug. 20, 2022, 10:52 a.m. UTC
Commit 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
broke compilation of uImage target for mpc85xx platforms by powerpc e500
SPE capable cross compilers. After that commit build process throws error:

    BOOTAS  arch/powerpc/boot/crt0.o
  powerpc-linux-gnuspe-gcc: error: unrecognized argument in option ‘-mcpu=powerpc’
  powerpc-linux-gnuspe-gcc: note: valid arguments to ‘-mcpu=’ are: 8540 8548 native
  make[1]: *** [arch/powerpc/boot/Makefile:231: arch/powerpc/boot/crt0.o] Error 1

Fix this issue by checking for CONFIG_PPC_E500MC / CONFIG_E500 options and
applying appropriate -mcpu options for building uImage boot code.

Fixes: 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
Cc: stable@vger.kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/powerpc/boot/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Christophe Leroy Aug. 23, 2022, 4:57 p.m. UTC | #1
Le 20/08/2022 à 12:52, Pali Rohár a écrit :
> Commit 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
> broke compilation of uImage target for mpc85xx platforms by powerpc e500
> SPE capable cross compilers. After that commit build process throws error:
> 
>      BOOTAS  arch/powerpc/boot/crt0.o
>    powerpc-linux-gnuspe-gcc: error: unrecognized argument in option ‘-mcpu=powerpc’
>    powerpc-linux-gnuspe-gcc: note: valid arguments to ‘-mcpu=’ are: 8540 8548 native
>    make[1]: *** [arch/powerpc/boot/Makefile:231: arch/powerpc/boot/crt0.o] Error 1
> 
> Fix this issue by checking for CONFIG_PPC_E500MC / CONFIG_E500 options and
> applying appropriate -mcpu options for building uImage boot code.

This is very specific to e500, could you instead do something using 
CONFIG_TARGET_CPU, just like commit 446cda1b21d9 ("powerpc/32: Don't 
always pass -mcpu=powerpc to the compiler")

Thanks
Christophe


> 
> Fixes: 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
> Cc: stable@vger.kernel.org
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>   arch/powerpc/boot/Makefile | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index a9cd2ea4a861..d7cf5d87e4bc 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -44,8 +44,14 @@ else
>   BOOTCFLAGS	+= -m64 -mcpu=powerpc64
>   endif
>   else
> +ifdef CONFIG_PPC_E500MC
> +BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
> +else ifdef CONFIG_E500
> +BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
> +else
>   BOOTCFLAGS	+= -m32 -mcpu=powerpc
>   endif
> +endif
>   
>   BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
>
Pali Rohár Aug. 24, 2022, 12:02 p.m. UTC | #2
On Tuesday 23 August 2022 16:57:34 Christophe Leroy wrote:
> Le 20/08/2022 à 12:52, Pali Rohár a écrit :
> > Commit 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
> > broke compilation of uImage target for mpc85xx platforms by powerpc e500
> > SPE capable cross compilers. After that commit build process throws error:
> > 
> >      BOOTAS  arch/powerpc/boot/crt0.o
> >    powerpc-linux-gnuspe-gcc: error: unrecognized argument in option ‘-mcpu=powerpc’
> >    powerpc-linux-gnuspe-gcc: note: valid arguments to ‘-mcpu=’ are: 8540 8548 native
> >    make[1]: *** [arch/powerpc/boot/Makefile:231: arch/powerpc/boot/crt0.o] Error 1
> > 
> > Fix this issue by checking for CONFIG_PPC_E500MC / CONFIG_E500 options and
> > applying appropriate -mcpu options for building uImage boot code.
> 
> This is very specific to e500, could you instead do something using 
> CONFIG_TARGET_CPU, just like commit 446cda1b21d9 ("powerpc/32: Don't 
> always pass -mcpu=powerpc to the compiler")

Ok, What about this change?

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index a9cd2ea4a861..2247374c4e70 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -34,6 +34,7 @@ endif
 
 BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
+		 $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
 		 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
 		 $(LINUXINCLUDE)
 
@@ -44,8 +45,16 @@ else
 BOOTCFLAGS	+= -m64 -mcpu=powerpc64
 endif
 else
+ifdef CONFIG_PPC32
+ifdef CONFIG_TARGET_CPU_BOOL
+BOOTCFLAGS	+= -m32 -mcpu=$(CONFIG_TARGET_CPU)
+else
+BOOTCFLAGS	+= -m32 -mcpu=powerpc
+endif
+else
 BOOTCFLAGS	+= -m32 -mcpu=powerpc
 endif
+endif
 
 BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 


> Thanks
> Christophe
> 
> 
> > 
> > Fixes: 40a75584e526 ("powerpc/boot: Build wrapper for an appropriate CPU")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >   arch/powerpc/boot/Makefile | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> > index a9cd2ea4a861..d7cf5d87e4bc 100644
> > --- a/arch/powerpc/boot/Makefile
> > +++ b/arch/powerpc/boot/Makefile
> > @@ -44,8 +44,14 @@ else
> >   BOOTCFLAGS	+= -m64 -mcpu=powerpc64
> >   endif
> >   else
> > +ifdef CONFIG_PPC_E500MC
> > +BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
> > +else ifdef CONFIG_E500
> > +BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
> > +else
> >   BOOTCFLAGS	+= -m32 -mcpu=powerpc
> >   endif
> > +endif
> >   
> >   BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
> >
diff mbox series

Patch

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index a9cd2ea4a861..d7cf5d87e4bc 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -44,8 +44,14 @@  else
 BOOTCFLAGS	+= -m64 -mcpu=powerpc64
 endif
 else
+ifdef CONFIG_PPC_E500MC
+BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
+else ifdef CONFIG_E500
+BOOTCFLAGS	+= -m32 $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
+else
 BOOTCFLAGS	+= -m32 -mcpu=powerpc
 endif
+endif
 
 BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)