All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] powerpc: Clang build fixes
@ 2018-09-10  8:57 Joel Stanley
  2018-09-10  8:57 ` [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang Joel Stanley
  2018-09-10  8:57 ` [PATCH 2/2] powerpc/boot: Ensure _zimage_start is a weak symbol Joel Stanley
  0 siblings, 2 replies; 5+ messages in thread
From: Joel Stanley @ 2018-09-10  8:57 UTC (permalink / raw)
  To: linuxppc-dev, Anton Blanchard

Two fixes to get us closer to building with clang. With a one patch[1]
on top of clang master I can build and boot a powernv kernel:

$ make ARCH=powerpc powernv_defconfig
$ ./scripts/config -e PPC_DISABLE_WERROR -d FTRACE -d BTRFS_FS -d MD_RAID456
$ make CC=/scratch/joel/llvm-build/bin/clang-8 CLANG_TRIPLE=powerpc64le-linux-gnu -j128

$ qemu-system-ppc64 -M powernv -m 3G -nographic -kernel zImage.epapr \
 -L ~/skiboot/ -initrd ~/rootfs.cpio.xz

Linux version 4.19.0-rc3-00003-g728b25f26bce (joel@ozrom3) (clang version 8.0.0 (trunk 341773)) #12 SMP Mon Sep 10 17:32:05 ACST 2018

The DISABLE_WERROR is due to clang's -Wduplicate-decl-specifier. Some
macros we have in arch/powerpc/include/asm/uaccess.h warn on 'const
typeof(var)', where as the GCC version doesn't. Anton did fix this a
while ago, but the fix was 'reverted' to resolve some sparse warnings.
I think we should re-apply Anton's patch[2].

[1] https://reviews.llvm.org/D50965
[2] http://git.kernel.org/torvalds/c/b91c1e3e7a6f22a6b898e345b745b6a43273c973

Joel Stanley (2):
  powerpc/boot: Fix crt0.S syntax for clang
  powerpc/boot: Ensure _zimage_start is a weak symbol

 arch/powerpc/boot/crt0.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1

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

* [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang
  2018-09-10  8:57 [PATCH 0/2] powerpc: Clang build fixes Joel Stanley
@ 2018-09-10  8:57 ` Joel Stanley
  2018-09-11 11:32   ` Segher Boessenkool
  2018-09-10  8:57 ` [PATCH 2/2] powerpc/boot: Ensure _zimage_start is a weak symbol Joel Stanley
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Stanley @ 2018-09-10  8:57 UTC (permalink / raw)
  To: linuxppc-dev, Anton Blanchard

Clang's assembler does not like the syntax of the cmpdi:

 arch/powerpc/boot/crt0.S:168:22: error: unexpected modifier on variable reference
         cmpdi   12,RELACOUNT@l
                              ^
 arch/powerpc/boot/crt0.S:168:11: error: unknown operand
         cmpdi   12,RELACOUNT@l
                   ^
Enclosing RELACOUNT in () makes it is happy. Tested with GCC 8 and Clang
8 (trunk).

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/boot/crt0.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index dcf2f15e6797..ace3f3c64620 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -165,7 +165,7 @@ p_base:	mflr	r10		/* r10 now points to runtime addr of p_base */
 	ld	r13,8(r11)       /* get RELA pointer in r13 */
 	b	11f
 10:	addis	r12,r12,(-RELACOUNT)@ha
-	cmpdi	r12,RELACOUNT@l
+	cmpdi	r12,(RELACOUNT)@l
 	bne	11f
 	ld	r8,8(r11)       /* get RELACOUNT value in r8 */
 11:	addi	r11,r11,16
-- 
2.17.1

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

* [PATCH 2/2] powerpc/boot: Ensure _zimage_start is a weak symbol
  2018-09-10  8:57 [PATCH 0/2] powerpc: Clang build fixes Joel Stanley
  2018-09-10  8:57 ` [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang Joel Stanley
@ 2018-09-10  8:57 ` Joel Stanley
  1 sibling, 0 replies; 5+ messages in thread
From: Joel Stanley @ 2018-09-10  8:57 UTC (permalink / raw)
  To: linuxppc-dev, Anton Blanchard

When building with clang crt0's _zimage_start is not marked weak, which
breaks the build when linking the kernel image:

 $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$
 0000000000000058 g       .text  0000000000000000 _zimage_start

 ld: arch/powerpc/boot/wrapper.a(crt0.o): in function '_zimage_start':
 (.text+0x58): multiple definition of '_zimage_start';
 arch/powerpc/boot/pseries-head.o:(.text+0x0): first defined here

Clang requires the .weak directive to appear after the symbol is
declared. The binutils manual says:

 This directive sets the weak attribute on the comma separated list of
 symbol names. If the symbols do not already exist, they will be
 created.

So it appears this is different with clang. The only reference I could
see for this was an OpenBSD mailing list post[1].

Changing it to be after the declaration fixes building with Clang, and
still works with GCC.

 $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$
 0000000000000058  w      .text	0000000000000000 _zimage_start

[1] https://groups.google.com/forum/#!topic/fa.openbsd.tech/PAgKKen2YCY

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/boot/crt0.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index ace3f3c64620..41c6d03d6e2d 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -47,8 +47,8 @@ p_end:		.long	_end
 p_pstack:	.long	_platform_stack_top
 #endif
 
-	.weak	_zimage_start
 	.globl	_zimage_start
+	.weak	_zimage_start
 _zimage_start:
 	.globl	_zimage_start_lib
 _zimage_start_lib:
-- 
2.17.1

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

* Re: [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang
  2018-09-10  8:57 ` [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang Joel Stanley
@ 2018-09-11 11:32   ` Segher Boessenkool
  2018-09-14  2:55     ` Joel Stanley
  0 siblings, 1 reply; 5+ messages in thread
From: Segher Boessenkool @ 2018-09-11 11:32 UTC (permalink / raw)
  To: Joel Stanley; +Cc: linuxppc-dev, Anton Blanchard

On Mon, Sep 10, 2018 at 06:57:13PM +1000, Joel Stanley wrote:
> Clang's assembler does not like the syntax of the cmpdi:
> 
>  arch/powerpc/boot/crt0.S:168:22: error: unexpected modifier on variable reference
>          cmpdi   12,RELACOUNT@l
>                               ^
>  arch/powerpc/boot/crt0.S:168:11: error: unknown operand
>          cmpdi   12,RELACOUNT@l
>                    ^
> Enclosing RELACOUNT in () makes it is happy. Tested with GCC 8 and Clang
> 8 (trunk).

Is clang going to fix this?  You also might want to add a comment that
this is a workaround for that broken assembler.


Segher

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

* Re: [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang
  2018-09-11 11:32   ` Segher Boessenkool
@ 2018-09-14  2:55     ` Joel Stanley
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Stanley @ 2018-09-14  2:55 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Anton Blanchard

On Tue, 11 Sep 2018 at 21:02, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Mon, Sep 10, 2018 at 06:57:13PM +1000, Joel Stanley wrote:
> > Clang's assembler does not like the syntax of the cmpdi:
> >
> >  arch/powerpc/boot/crt0.S:168:22: error: unexpected modifier on variable reference
> >          cmpdi   12,RELACOUNT@l
> >                               ^
> >  arch/powerpc/boot/crt0.S:168:11: error: unknown operand
> >          cmpdi   12,RELACOUNT@l
> >                    ^
> > Enclosing RELACOUNT in () makes it is happy. Tested with GCC 8 and Clang
> > 8 (trunk).
>
> Is clang going to fix this?  You also might want to add a comment that
> this is a workaround for that broken assembler.

I am not sure that we need a comment, it doesn't look too out of place
compared to the other uses of wrapping symbols in ().

I did open a bug against clang though in the hope that they can fix
the behaviour:

 https://bugs.llvm.org/show_bug.cgi?id=38945

Cheers,

Joel

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

end of thread, other threads:[~2018-09-14  2:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10  8:57 [PATCH 0/2] powerpc: Clang build fixes Joel Stanley
2018-09-10  8:57 ` [PATCH 1/2] powerpc/boot: Fix crt0.S syntax for clang Joel Stanley
2018-09-11 11:32   ` Segher Boessenkool
2018-09-14  2:55     ` Joel Stanley
2018-09-10  8:57 ` [PATCH 2/2] powerpc/boot: Ensure _zimage_start is a weak symbol Joel Stanley

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.