Skip to contentSkip to conversation

arm64: Fix building failure for Xen target

PATCH In review Leo Yan 2 participants 6 messages May 4, 2023 – Jun 1, 2023 Arm (32-bit)

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

cover arm64: Fix building failure for Xen target

This patch series is for building Xen target with Clang.

The first patch is to fix building failure for Xen target, the second patch is to add info for a linkage known issue when use Clang as compiler.

Leo Yan (2):
arm64: Remove duplicated symbols
doc: Add info for building Xen target with Clang

 .../include/asm/boot0-linux-kernel-header.h   |  2 --
 doc/build/clang.rst                           | 36 +++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 1/2 arm64: Remove duplicated symbols

When build U-boot with clang with using commands:

  $ make HOSTCC=clang xenguest_arm64_defconfig
  $ make HOSTCC=clang CROSS_COMPILE=aarch64-linux-gnu- \
		CC="clang -target aarch64-linux-gnueabi" -j8

The compiler reports error:

/tmp/start-acdf31.s:330:1: error: symbol '_start' is already defined _start:
^

Because the symbol '_start' has been defined twice, one is defined in arch/arm/cpu/armv8/start.S, another is defined in the header boot0-linux-kernel-header.h.

To fix building failure, this patch removes the symbol '_start' from boot0-linux-kernel-header.h.

---
 arch/arm/include/asm/boot0-linux-kernel-header.h | 2 --
 1 file changed, 2 deletions(-)
arch/arm/include/asm/boot0-linux-kernel-header.h +0 -2
index c6cd76f32a..c930fea5fd 100644
@@ -31,8 +31,6 @@
 	.long	\sym\()_hi32
 	.endm
 
-.globl _start
-_start:
 	/*
 	 * DO NOT MODIFY. Image header expected by Linux boot-loaders.
 	 */
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH v1 1/2] arm64: Remove duplicated symbols

Quoted 12 lines · Leo Yan

When build U-boot with clang with using commands:

  $ make HOSTCC=clang xenguest_arm64_defconfig
  $ make HOSTCC=clang CROSS_COMPILE=aarch64-linux-gnu- \
		CC="clang -target aarch64-linux-gnueabi" -j8

The compiler reports error:

/tmp/start-acdf31.s:330:1: error: symbol '_start' is already defined _start:
^

Quoted 8 lines

Because the symbol '_start' has been defined twice, one is defined in arch/arm/cpu/armv8/start.S, another is defined in the header boot0-linux-kernel-header.h.

To fix building failure, this patch removes the symbol '_start' from boot0-linux-kernel-header.h.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
author
#3 lore raw

PATCH 2/2 doc: Add info for building Xen target with Clang

In reply to Leo Yan

When build Xen target with Clang, the linker reports failure.

This patch adds the related info in the documentation as a known issue and gives details for how to dismiss the building failure with Clang.

---
 doc/build/clang.rst | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
doc/build/clang.rst +36 -0
index 1d35616eb5..cc265506c2 100644
@@ -74,3 +74,39 @@ simplified with a simple wrapper script - saved as
 
     #!/bin/sh
     exec clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd "$@"
+
+
+Known Issues
+------------
+
+When build U-boot for `xenguest_arm64_defconfig` target, it reports linkage
+error:
+
+.. code-block:: bash
+
+    aarch64-linux-gnu-ld.bfd: drivers/xen/hypervisor.o: in function `do_hypervisor_callback':
+    /home/leoy/Dev2/u-boot/drivers/xen/hypervisor.c:188: undefined reference to `__aarch64_swp8_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/hypervisor.o: in function `synch_test_and_set_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:40: undefined reference to `__aarch64_ldset1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/hypervisor.o: in function `synch_test_and_clear_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:28: undefined reference to `__aarch64_ldclr1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/hypervisor.o: in function `synch_test_and_set_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:40: undefined reference to `__aarch64_ldset1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/hypervisor.o: in function `synch_test_and_clear_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:28: undefined reference to `__aarch64_ldclr1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/events.o: in function `synch_test_and_clear_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:28: undefined reference to `__aarch64_ldclr1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/events.o: in function `synch_test_and_set_bit':
+    /home/leoy/Dev2/u-boot/./arch/arm/include/asm/xen/system.h:40: undefined reference to `__aarch64_ldset1_acq_rel'
+    aarch64-linux-gnu-ld.bfd: drivers/xen/gnttab.o: in function `gnttab_end_access':
+    /home/leoy/Dev2/u-boot/drivers/xen/gnttab.c:109: undefined reference to `__aarch64_cas2_acq_rel'
+    Segmentation fault
+
+To fix the failure, we need to append option `-mno-outline-atomics` in Clang
+command to not generate local calls to out-of-line atomic operations:
+
+.. code-block:: bash
+
+    make HOSTCC=clang xenguest_arm64_defconfig
+    make HOSTCC=clang CROSS_COMPILE=aarch64-linux-gnu- \
+         CC="clang -target aarch64-linux-gnueabi -mno-outline-atomics" -j8
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH v1 2/2] doc: Add info for building Xen target with Clang

Quoted 6 lines · Leo Yan

When build Xen target with Clang, the linker reports failure.

This patch adds the related info in the documentation as a known issue and gives details for how to dismiss the building failure with Clang.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
author
#5 lore raw
In reply to Leo Yan
Quoted 5 lines · Leo Yan

This patch series is for building Xen target with Clang.

The first patch is to fix building failure for Xen target, the second patch is to add info for a linkage known issue when use Clang as compiler.

Gentle ping ...

I saw my patches were rejected by EPAM, so I am afraid EPAM engineers cannot see these two patches, I will try to reach them offline.

At meantine, it would be great if anyone could review on this list.

Thanks!

Quoted 11 lines

Leo Yan (2):
arm64: Remove duplicated symbols
doc: Add info for building Xen target with Clang

 .../include/asm/boot0-linux-kernel-header.h   |  2 --
 doc/build/clang.rst                           | 36 +++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2