linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang
@ 2018-11-04 23:11 Joel Stanley
  2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Joel Stanley @ 2018-11-04 23:11 UTC (permalink / raw)
  To: Michael Ellerman, Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, linux-kernel, linuxppc-dev

Hello,

These patches allow clang to cross-compile the powerpc boot wrapper.
The boot wrapper constructs it's own compiler flags as it may not be
built for the same arch as the kernel.

The powerpc64le kernel builds natively with clang and with this patch it
can cross compile too.

Joel Stanley (2):
  Makefile: Export clang toolchain variables
  powerpc/boot: Set target when cross-compiling for clang

 Makefile                   | 3 +++
 arch/powerpc/boot/Makefile | 7 +++++++
 2 files changed, 10 insertions(+)

-- 
2.19.1


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

* [PATCH 1/2] Makefile: Export clang toolchain variables
  2018-11-04 23:11 [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Joel Stanley
@ 2018-11-04 23:11 ` Joel Stanley
  2018-11-05  0:10   ` Daniel Axtens
  2018-11-05  2:52   ` Masahiro Yamada
  2018-11-04 23:11 ` [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang Joel Stanley
  2018-11-05 22:37 ` [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Nick Desaulniers
  2 siblings, 2 replies; 8+ messages in thread
From: Joel Stanley @ 2018-11-04 23:11 UTC (permalink / raw)
  To: Michael Ellerman, Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, linux-kernel, linuxppc-dev

The powerpc makefile will use these in it's boot wrapper.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 9aa352b38815..a2db3c885b38 100644
--- a/Makefile
+++ b/Makefile
@@ -495,6 +495,9 @@ endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
+export CLANG_TARGET
+export CLANG_GCC_TC
+export CLANG_PREFIX
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-- 
2.19.1


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

* [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang
  2018-11-04 23:11 [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Joel Stanley
  2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
@ 2018-11-04 23:11 ` Joel Stanley
  2018-11-05  0:11   ` Daniel Axtens
  2018-11-05 22:37 ` [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Nick Desaulniers
  2 siblings, 1 reply; 8+ messages in thread
From: Joel Stanley @ 2018-11-04 23:11 UTC (permalink / raw)
  To: Michael Ellerman, Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, linux-kernel, linuxppc-dev

Clang needs to be told which target it is building for when cross
compiling.

Link: https://github.com/ClangBuiltLinux/linux/issues/259
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/boot/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 39354365f54a..8fdb1890f09a 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -55,6 +55,13 @@ BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
 
 BOOTARFLAGS	:= -cr$(KBUILD_ARFLAGS)
 
+ifdef CONFIG_CC_IS_CLANG
+BOOTCFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+BOOTAFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+BOOTCFLAGS += $(call cc-option, -no-integrated-as)
+BOOTAFLAGS += $(call cc-option, -no-integrated-as)
+endif
+
 ifdef CONFIG_DEBUG_INFO
 BOOTCFLAGS	+= -g
 endif
-- 
2.19.1


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

* Re: [PATCH 1/2] Makefile: Export clang toolchain variables
  2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
@ 2018-11-05  0:10   ` Daniel Axtens
  2018-11-05  2:52   ` Masahiro Yamada
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Axtens @ 2018-11-05  0:10 UTC (permalink / raw)
  To: Joel Stanley, Michael Ellerman, Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, linux-kernel, linuxppc-dev

Hi Joel,

Thanks!

Tested-by: Daniel Axtens <dja@axtens.net> # powerpc 64-bit BE

Regards,
Daniel

> The powerpc makefile will use these in it's boot wrapper.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 9aa352b38815..a2db3c885b38 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -495,6 +495,9 @@ endif
>  ifneq ($(GCC_TOOLCHAIN),)
>  CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
>  endif
> +export CLANG_TARGET
> +export CLANG_GCC_TC
> +export CLANG_PREFIX
>  KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
>  KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
>  KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
> -- 
> 2.19.1

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

* Re: [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang
  2018-11-04 23:11 ` [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang Joel Stanley
@ 2018-11-05  0:11   ` Daniel Axtens
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Axtens @ 2018-11-05  0:11 UTC (permalink / raw)
  To: Joel Stanley, Michael Ellerman, Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, linux-kernel, linuxppc-dev

Joel Stanley <joel@jms.id.au> writes:

Hi Joel,

Thanks!

Tested-by: Daniel Axtens <dja@axtens.net> # powerpc 64-bit BE

This solves one of the 2 issues I have in building for 64-bit BE with
clang. The other is the VDSO32 stuff, and I hope to send a patch for
that soon.

Regards,
Daniel

> Clang needs to be told which target it is building for when cross
> compiling.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/259
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  arch/powerpc/boot/Makefile | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 39354365f54a..8fdb1890f09a 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -55,6 +55,13 @@ BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
>  
>  BOOTARFLAGS	:= -cr$(KBUILD_ARFLAGS)
>  
> +ifdef CONFIG_CC_IS_CLANG
> +BOOTCFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> +BOOTAFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> +BOOTCFLAGS += $(call cc-option, -no-integrated-as)
> +BOOTAFLAGS += $(call cc-option, -no-integrated-as)
> +endif
> +
>  ifdef CONFIG_DEBUG_INFO
>  BOOTCFLAGS	+= -g
>  endif
> -- 
> 2.19.1

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

* Re: [PATCH 1/2] Makefile: Export clang toolchain variables
  2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
  2018-11-05  0:10   ` Daniel Axtens
@ 2018-11-05  2:52   ` Masahiro Yamada
  1 sibling, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-11-05  2:52 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Michael Ellerman, Nick Desaulniers, Michal Marek,
	Linux Kbuild mailing list, Linux Kernel Mailing List,
	linuxppc-dev

Hi Joel,


On Mon, Nov 5, 2018 at 9:53 AM Joel Stanley <joel@jms.id.au> wrote:
>
> The powerpc makefile will use these in it's boot wrapper.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 9aa352b38815..a2db3c885b38 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -495,6 +495,9 @@ endif
>  ifneq ($(GCC_TOOLCHAIN),)
>  CLANG_GCC_TC   := --gcc-toolchain=$(GCC_TOOLCHAIN)
>  endif
> +export CLANG_TARGET
> +export CLANG_GCC_TC
> +export CLANG_PREFIX
>  KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
>  KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
>  KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
> --
> 2.19.1
>


Before exporting these compiler flags,
I'd like to do a cleanup work.


Could you take a look at my patch, please?

https://patchwork.kernel.org/patch/10667369/


By using it as a prerequisite,
your patch set will be more simplified.


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang
  2018-11-04 23:11 [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Joel Stanley
  2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
  2018-11-04 23:11 ` [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang Joel Stanley
@ 2018-11-05 22:37 ` Nick Desaulniers
  2018-11-06  0:36   ` Joel Stanley
  2 siblings, 1 reply; 8+ messages in thread
From: Nick Desaulniers @ 2018-11-05 22:37 UTC (permalink / raw)
  To: joel
  Cc: mpe, Masahiro Yamada, Michal Marek, Linux Kbuild mailing list,
	LKML, linuxppc-dev

On Sun, Nov 4, 2018 at 3:11 PM Joel Stanley <joel@jms.id.au> wrote:
>
> Hello,
>
> These patches allow clang to cross-compile the powerpc boot wrapper.
> The boot wrapper constructs it's own compiler flags as it may not be
> built for the same arch as the kernel.

Hi Joel, thanks for the series!  I'm just curious, how does the boot
wrapper run on a different arch than the kernel?

>
> The powerpc64le kernel builds natively with clang and with this patch it
> can cross compile too.
>
> Joel Stanley (2):
>   Makefile: Export clang toolchain variables
>   powerpc/boot: Set target when cross-compiling for clang
>
>  Makefile                   | 3 +++
>  arch/powerpc/boot/Makefile | 7 +++++++
>  2 files changed, 10 insertions(+)
>
> --
> 2.19.1
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang
  2018-11-05 22:37 ` [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Nick Desaulniers
@ 2018-11-06  0:36   ` Joel Stanley
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Stanley @ 2018-11-06  0:36 UTC (permalink / raw)
  To: Nick Desaulniers, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild,
	Linux Kernel Mailing List, linuxppc-dev

On Tue, 6 Nov 2018 at 09:07, Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Sun, Nov 4, 2018 at 3:11 PM Joel Stanley <joel@jms.id.au> wrote:
> >
> > Hello,
> >
> > These patches allow clang to cross-compile the powerpc boot wrapper.
> > The boot wrapper constructs it's own compiler flags as it may not be
> > built for the same arch as the kernel.
>
> Hi Joel, thanks for the series!  I'm just curious, how does the boot
> wrapper run on a different arch than the kernel?

The kernel can have a ppc32 boot wrapper for a ppc64 kernel. There's
some rationale in the boot wrapper's Makefile:

 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/boot/Makefile#n10

Cheers,

Joel

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

end of thread, other threads:[~2018-11-06  0:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-04 23:11 [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Joel Stanley
2018-11-04 23:11 ` [PATCH 1/2] Makefile: Export clang toolchain variables Joel Stanley
2018-11-05  0:10   ` Daniel Axtens
2018-11-05  2:52   ` Masahiro Yamada
2018-11-04 23:11 ` [PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang Joel Stanley
2018-11-05  0:11   ` Daniel Axtens
2018-11-05 22:37 ` [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang Nick Desaulniers
2018-11-06  0:36   ` Joel Stanley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).