diff mbox

[v2,1/5] powerpc/kbuild: set default generic machine type for 32-bit compile

Message ID 20180510051659.15356-2-npiggin@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nicholas Piggin May 10, 2018, 5:16 a.m. UTC
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
powerpc machine type and scheduling model. 32-bit platforms and CPUs
can override this with -mcpu= options that come later on the command
line.

This fixes a lot of build failures due to incompatible assembly when
compiling 32-bit kernel with 64-bit toolchain.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Segher Boessenkool May 10, 2018, 1:10 p.m. UTC | #1
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> powerpc machine type and scheduling model. 32-bit platforms and CPUs
> can override this with -mcpu= options that come later on the command
> line.
> 
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with 64-bit toolchain.

So what ISA is set for gas without this patch?  With what GCC version?
And, why is that wrong?


Segher


> +ifdef CONFIG_PPC32
> +# These options will be overridden by any -mcpu option that comes
> +# later on the command line, but they are needed to set a sane
> +# 32-bit cpu target for the 64-bit cross compiler.
> +KBUILD_CFLAGS		+= -mcpu=powerpc
> +KBUILD_AFLAGS		+= -mcpu=powerpc
> +endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas Piggin May 10, 2018, 1:24 p.m. UTC | #2
On Thu, 10 May 2018 08:10:03 -0500
Segher Boessenkool <segher@kernel.crashing.org> wrote:

> On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> > The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> > kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> > powerpc machine type and scheduling model. 32-bit platforms and CPUs
> > can override this with -mcpu= options that come later on the command
> > line.
> > 
> > This fixes a lot of build failures due to incompatible assembly when
> > compiling 32-bit kernel with 64-bit toolchain.  
> 
> So what ISA is set for gas without this patch?  With what GCC version?

I'm not sure, how do I find that out?

> And, why is that wrong?

Some 32-bit platforms and CPU types do not provide -mcpu, so I assume
for 32-bit toolchains that must result in the "powerpc" machine. With
64-bit toolchains 

arch/powerpc/mm/hash_low_32.S:353: Error: missing operand

Which is,

        tlbie   r4

Is that v2.06?

Thanks,
Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Segher Boessenkool May 10, 2018, 2:29 p.m. UTC | #3
On Thu, May 10, 2018 at 11:24:40PM +1000, Nicholas Piggin wrote:
> On Thu, 10 May 2018 08:10:03 -0500
> Segher Boessenkool <segher@kernel.crashing.org> wrote:
> > On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> > > The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> > > kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> > > powerpc machine type and scheduling model. 32-bit platforms and CPUs
> > > can override this with -mcpu= options that come later on the command
> > > line.
> > > 
> > > This fixes a lot of build failures due to incompatible assembly when
> > > compiling 32-bit kernel with 64-bit toolchain.  
> > 
> > So what ISA is set for gas without this patch?  With what GCC version?
> 
> I'm not sure, how do I find that out?

gcc --version
gcc -v <rest of command>, look at the command line options passed to as
make something.s, look at what .machine is set (if any).


> > And, why is that wrong?
> 
> Some 32-bit platforms and CPU types do not provide -mcpu, so I assume
> for 32-bit toolchains that must result in the "powerpc" machine. With

It results in whatever is the default for that toolchain.  Depends on
many things.

> 64-bit toolchains 
> 
> arch/powerpc/mm/hash_low_32.S:353: Error: missing operand
> 
> Which is,
> 
>         tlbie   r4
> 
> Is that v2.06?

The original ISA did not have the L field, 2.xx does, for any xx even I think.


Segher
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Segher Boessenkool May 10, 2018, 2:52 p.m. UTC | #4
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> powerpc machine type and scheduling model. 32-bit platforms and CPUs
> can override this with -mcpu= options that come later on the command
> line.

So it turns out your compiler was configured with --with-cpu=power8;
it's not that GCC defaults are bad, but who built your compiler
overrode the defaults.

If the problem only happens in .S files, it might be better to put
.machine directives in those.  But your patch should work too, yes.


Segher
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 95813df90801..7034b1ad50e0 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -27,6 +27,14 @@  KBUILD_ARFLAGS	+= --target=elf32-powerpc
 endif
 endif
 
+ifdef CONFIG_PPC32
+# These options will be overridden by any -mcpu option that comes
+# later on the command line, but they are needed to set a sane
+# 32-bit cpu target for the 64-bit cross compiler.
+KBUILD_CFLAGS		+= -mcpu=powerpc
+KBUILD_AFLAGS		+= -mcpu=powerpc
+endif
+
 export CROSS32CC CROSS32AR
 
 ifeq ($(CROSS_COMPILE),)