[03/12] s390: purgatory: pass --target option to clang

Message ID 20190408212648.2407234-3-arnd@arndb.de
State New
Headers show
Series
  • [01/12] s390: remove -fno-strength-reduce flag
Related show

Commit Message

Arnd Bergmann April 8, 2019, 9:26 p.m.
The purgatory Makefile does not inherit the original cflags,
so clang falls back to the default target architecture when
building it, typically this would be x86 when cross-compiling.

Pass --target=s390x-linux to all compilers that understand
this option.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 arch/s390/purgatory/Makefile | 1 +
 1 file changed, 1 insertion(+)

-- 
2.20.0

Comments

Nathan Chancellor April 8, 2019, 10:03 p.m. | #1
On Mon, Apr 08, 2019 at 11:26:16PM +0200, Arnd Bergmann wrote:
> The purgatory Makefile does not inherit the original cflags,

> so clang falls back to the default target architecture when

> building it, typically this would be x86 when cross-compiling.

> 

> Pass --target=s390x-linux to all compilers that understand

> this option.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  arch/s390/purgatory/Makefile | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile

> index ce6a3f75065b..3a14b968cec3 100644

> --- a/arch/s390/purgatory/Makefile

> +++ b/arch/s390/purgatory/Makefile

> @@ -22,6 +22,7 @@ KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes

>  KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare

>  KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding

>  KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common

> +KBUILD_CFLAGS += $(call cc-option,--target=s390x-linux)

>  KBUILD_CFLAGS += $(call cc-option,-fno-PIE)

>  KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))

>  

> -- 

> 2.20.0

> 


Would

ifdef CONFIG_CC_IS_CLANG
KBUILD_CFLAGS += --target=s390x-linux
endif

be a little clearer (and save a cc-option call)?

Otherwise, makes sense.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Arnd Bergmann April 9, 2019, 6:43 a.m. | #2
On Tue, Apr 9, 2019 at 12:03 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>

> On Mon, Apr 08, 2019 at 11:26:16PM +0200, Arnd Bergmann wrote:

> > The purgatory Makefile does not inherit the original cflags,

> > so clang falls back to the default target architecture when

> > building it, typically this would be x86 when cross-compiling.

> >

> > Pass --target=s390x-linux to all compilers that understand

> > this option.

> >

> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> > ---

> >  arch/s390/purgatory/Makefile | 1 +

> >  1 file changed, 1 insertion(+)

> >

> > diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile

> > index ce6a3f75065b..3a14b968cec3 100644

> > --- a/arch/s390/purgatory/Makefile

> > +++ b/arch/s390/purgatory/Makefile

> > @@ -22,6 +22,7 @@ KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes

> >  KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare

> >  KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding

> >  KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common

> > +KBUILD_CFLAGS += $(call cc-option,--target=s390x-linux)

> >  KBUILD_CFLAGS += $(call cc-option,-fno-PIE)

> >  KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))

> >

> Would

>

> ifdef CONFIG_CC_IS_CLANG

> KBUILD_CFLAGS += --target=s390x-linux

> endif

>

> be a little clearer (and save a cc-option call)?


Fine with me as well. Actually I noticed later that we need the same
thing for arch/s390/boot/Makefile and arch/s390/boot/compressed/Makefile
in some form, so maybe we should drop this one for now and find
a solution that works for all three of them. The boot stuff is the one
patch I did not send, since I did not think I had a good solution there,
just one that happened to make it build.

> Otherwise, makes sense.

>

> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>


 Thanks,

       Arnd
Nathan Chancellor April 9, 2019, 4:30 p.m. | #3
On Tue, Apr 09, 2019 at 08:43:09AM +0200, Arnd Bergmann wrote:
> On Tue, Apr 9, 2019 at 12:03 AM Nathan Chancellor

> <natechancellor@gmail.com> wrote:

> >

> > On Mon, Apr 08, 2019 at 11:26:16PM +0200, Arnd Bergmann wrote:

> > > The purgatory Makefile does not inherit the original cflags,

> > > so clang falls back to the default target architecture when

> > > building it, typically this would be x86 when cross-compiling.

> > >

> > > Pass --target=s390x-linux to all compilers that understand

> > > this option.

> > >

> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> > > ---

> > >  arch/s390/purgatory/Makefile | 1 +

> > >  1 file changed, 1 insertion(+)

> > >

> > > diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile

> > > index ce6a3f75065b..3a14b968cec3 100644

> > > --- a/arch/s390/purgatory/Makefile

> > > +++ b/arch/s390/purgatory/Makefile

> > > @@ -22,6 +22,7 @@ KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes

> > >  KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare

> > >  KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding

> > >  KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common

> > > +KBUILD_CFLAGS += $(call cc-option,--target=s390x-linux)

> > >  KBUILD_CFLAGS += $(call cc-option,-fno-PIE)

> > >  KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))

> > >

> > Would

> >

> > ifdef CONFIG_CC_IS_CLANG

> > KBUILD_CFLAGS += --target=s390x-linux

> > endif

> >

> > be a little clearer (and save a cc-option call)?

> 

> Fine with me as well. Actually I noticed later that we need the same

> thing for arch/s390/boot/Makefile and arch/s390/boot/compressed/Makefile

> in some form, so maybe we should drop this one for now and find

> a solution that works for all three of them. The boot stuff is the one

> patch I did not send, since I did not think I had a good solution there,

> just one that happened to make it build.

> 


It did just occur to me that we added the --target and --gcc-toolchain
flags to a clang specific variable, CLANG_FLAGS, that has already been
used by powerpc in commit 813af51f5d30 ("powerpc/boot: Set target when
cross-compiling for clang"). I assume that could be used here?

Nathan

> > Otherwise, makes sense.

> >

> > Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> 

>  Thanks,

> 

>        Arnd
Nick Desaulniers April 9, 2019, 6:11 p.m. | #4
On Tue, Apr 9, 2019 at 9:30 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> It did just occur to me that we added the --target and --gcc-toolchain

> flags to a clang specific variable, CLANG_FLAGS, that has already been

> used by powerpc in commit 813af51f5d30 ("powerpc/boot: Set target when

> cross-compiling for clang"). I assume that could be used here?


I think reusing CLANG_FLAGS is a better approach.

-- 
Thanks,
~Nick Desaulniers

Patch

diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index ce6a3f75065b..3a14b968cec3 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -22,6 +22,7 @@  KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
 KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
 KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common
+KBUILD_CFLAGS += $(call cc-option,--target=s390x-linux)
 KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))