All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options
@ 2016-08-09 12:43 Michael Ellerman
  2016-08-09 14:36 ` Nicholas Piggin
  2016-08-11 11:16 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-08-09 12:43 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nick Piggin, Anton Blanchard, imunsie

When we introduced the little endian support, we added the endian flags
to CC directly using override. I don't know the history of why we did
that, I suspect no one does.

Although this mostly works, it has one bug, which is that CROSS32CC
doesn't get -mbig-endian. That means when the compiler is little endian
by default and the user is building big endian, vdso32 is incorrectly
compiled as little endian and the kernel fails to build.

Instead we can add the endian flags to cflags-y/aflags-y, and then
append those to KBUILD_CFLAGS/KBUILD_AFLAGS.

This has the advantage of being 1) less ugly, 2) the documented way of
adding flags in the arch Makefile and 3) it fixes building vdso32 with a
LE toolchain.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/Makefile | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ca254546cd05..1934707bf321 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -66,29 +66,28 @@ endif
 UTS_MACHINE := $(OLDARCH)
 
 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
-override CC	+= -mlittle-endian
-ifneq ($(cc-name),clang)
-override CC	+= -mno-strict-align
-endif
-override AS	+= -mlittle-endian
 override LD	+= -EL
-override CROSS32CC += -mlittle-endian
 override CROSS32AS += -mlittle-endian
 LDEMULATION	:= lppc
 GNUTARGET	:= powerpcle
 MULTIPLEWORD	:= -mno-multiple
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
 else
-ifeq ($(call cc-option-yn,-mbig-endian),y)
-override CC	+= -mbig-endian
-override AS	+= -mbig-endian
-endif
 override LD	+= -EB
 LDEMULATION	:= ppc
 GNUTARGET	:= powerpc
 MULTIPLEWORD	:= -mmultiple
 endif
 
+cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
+ifneq ($(cc-name),clang)
+  cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mno-strict-align
+endif
+
+aflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
+aflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
+
 ifeq ($(HAS_BIARCH),y)
 override AS	+= -a$(CONFIG_WORD_SIZE)
 override LD	+= -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION)
@@ -232,6 +231,9 @@ cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 KBUILD_AFLAGS += $(cpu-as-y)
 KBUILD_CFLAGS += $(cpu-as-y)
 
+KBUILD_AFLAGS += $(aflags-y)
+KBUILD_CFLAGS += $(cflags-y)
+
 head-y				:= arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o
 head-$(CONFIG_8xx)		:= arch/powerpc/kernel/head_8xx.o
 head-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options
  2016-08-09 12:43 [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options Michael Ellerman
@ 2016-08-09 14:36 ` Nicholas Piggin
  2016-08-10  5:20   ` Michael Ellerman
  2016-08-11 11:16 ` Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Nicholas Piggin @ 2016-08-09 14:36 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Anton Blanchard, imunsie

On Tue,  9 Aug 2016 22:43:46 +1000
Michael Ellerman <mpe@ellerman.id.au> wrote:

> When we introduced the little endian support, we added the endian flags
> to CC directly using override. I don't know the history of why we did
> that, I suspect no one does.
> 
> Although this mostly works, it has one bug, which is that CROSS32CC
> doesn't get -mbig-endian. That means when the compiler is little endian
> by default and the user is building big endian, vdso32 is incorrectly
> compiled as little endian and the kernel fails to build.
> 
> Instead we can add the endian flags to cflags-y/aflags-y, and then
> append those to KBUILD_CFLAGS/KBUILD_AFLAGS.
> 
> This has the advantage of being 1) less ugly, 2) the documented way of
> adding flags in the arch Makefile and 3) it fixes building vdso32 with a
> LE toolchain.

This seems okay to me.

> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/Makefile | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index ca254546cd05..1934707bf321 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -66,29 +66,28 @@ endif
>  UTS_MACHINE := $(OLDARCH)
>  
>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
> -override CC	+= -mlittle-endian
> -ifneq ($(cc-name),clang)
> -override CC	+= -mno-strict-align
> -endif
> -override AS	+= -mlittle-endian
>  override LD	+= -EL
> -override CROSS32CC += -mlittle-endian
>  override CROSS32AS += -mlittle-endian

Can't we get rid of CROSS32AS? If not, then should it get the
-mbig-endian override?

Thanks,
Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options
  2016-08-09 14:36 ` Nicholas Piggin
@ 2016-08-10  5:20   ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-08-10  5:20 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev, Anton Blanchard, imunsie

Nicholas Piggin <npiggin@gmail.com> writes:

> On Tue,  9 Aug 2016 22:43:46 +1000
> Michael Ellerman <mpe@ellerman.id.au> wrote:
>> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
>> index ca254546cd05..1934707bf321 100644
>> --- a/arch/powerpc/Makefile
>> +++ b/arch/powerpc/Makefile
>> @@ -66,29 +66,28 @@ endif
>>  UTS_MACHINE := $(OLDARCH)
>>  
>>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
>> -override CC	+= -mlittle-endian
>> -ifneq ($(cc-name),clang)
>> -override CC	+= -mno-strict-align
>> -endif
>> -override AS	+= -mlittle-endian
>>  override LD	+= -EL
>> -override CROSS32CC += -mlittle-endian
>>  override CROSS32AS += -mlittle-endian
>
> Can't we get rid of CROSS32AS? If not, then should it get the
> -mbig-endian override?

It's unused. I have a patch to remove it lying around, let me dig up
that series.

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: powerpc/Makefile: Use cflags-y/aflags-y for setting endian options
  2016-08-09 12:43 [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options Michael Ellerman
  2016-08-09 14:36 ` Nicholas Piggin
@ 2016-08-11 11:16 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-08-11 11:16 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: Anton Blanchard, Nick Piggin, imunsie

On Tue, 2016-09-08 at 12:43:46 UTC, Michael Ellerman wrote:
> When we introduced the little endian support, we added the endian flags
> to CC directly using override. I don't know the history of why we did
> that, I suspect no one does.
> 
> Although this mostly works, it has one bug, which is that CROSS32CC
> doesn't get -mbig-endian. That means when the compiler is little endian
> by default and the user is building big endian, vdso32 is incorrectly
> compiled as little endian and the kernel fails to build.
> 
> Instead we can add the endian flags to cflags-y/aflags-y, and then
> append those to KBUILD_CFLAGS/KBUILD_AFLAGS.
> 
> This has the advantage of being 1) less ugly, 2) the documented way of
> adding flags in the arch Makefile and 3) it fixes building vdso32 with a
> LE toolchain.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/164af597ce945751e2dcd53d0a

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-11 11:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09 12:43 [PATCH] powerpc/Makefile: Use cflags-y/aflags-y for setting endian options Michael Ellerman
2016-08-09 14:36 ` Nicholas Piggin
2016-08-10  5:20   ` Michael Ellerman
2016-08-11 11:16 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.