diff mbox series

[v2] xen/arm: un-break build with clang

Message ID 20230525191531.120224-1-stewart.hildebrand@amd.com (mailing list archive)
State New, archived
Headers show
Series [v2] xen/arm: un-break build with clang | expand

Commit Message

Stewart Hildebrand May 25, 2023, 7:15 p.m. UTC
clang doesn't like extern with __attribute__((__used__)):

  ./arch/arm/include/asm/setup.h:171:8: error: 'used' attribute ignored [-Werror,-Wignored-attributes]
  extern DEFINE_BOOT_PAGE_TABLE(boot_pgtable);
         ^
  ./arch/arm/include/asm/lpae.h:273:29: note: expanded from macro 'DEFINE_BOOT_PAGE_TABLE'
  lpae_t __aligned(PAGE_SIZE) __section(".data.page_aligned")                   \
                              ^
  ./include/xen/compiler.h:71:27: note: expanded from macro '__section'
  #define __section(s)      __used __attribute__((__section__(s)))
                            ^
  ./include/xen/compiler.h:104:39: note: expanded from macro '__used'
  #define __used         __attribute__((__used__))
                                        ^

Simplify the declarations by getting rid of the macro (and thus the
__aligned/__section/__used attributes) in the header. No functional change
intended as the macro/attributes are present in the respective definitions in
xen/arch/arm/mm.c.

Fixes: 1c78d76b67e1 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable the identity mapping")
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
v1->v2:
* simplify by getting rid of the macro per Andrew's suggestion

---
I tested with clang 12 and clang 16

Here is my make command line:
make -j $(nproc) \
    clang=y \
    CC="clang --target=aarch64-none-linux-gnu -march=armv8a+nocrypto" \
    CXX="clang++ --target=aarch64-none-linux-gnu -march=armv8a+nocrypto" \
    HOSTCC=clang \
    HOSTCXX=clang++ \
    XEN_TARGET_ARCH=arm64 \
    CROSS_COMPILE=aarch64-none-linux-gnu- \
    dist-xen
---
 xen/arch/arm/include/asm/setup.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andrew Cooper May 25, 2023, 7:30 p.m. UTC | #1
On 25/05/2023 8:15 pm, Stewart Hildebrand wrote:
> I tested with clang 12 and clang 16
>
> Here is my make command line:
> make -j $(nproc) \
>     clang=y \
>     CC="clang --target=aarch64-none-linux-gnu -march=armv8a+nocrypto" \
>     CXX="clang++ --target=aarch64-none-linux-gnu -march=armv8a+nocrypto" \
>     HOSTCC=clang \
>     HOSTCXX=clang++ \
>     XEN_TARGET_ARCH=arm64 \
>     CROSS_COMPILE=aarch64-none-linux-gnu- \
>     dist-xen

Looking much better now.  But the fact that Gitlab doesn't spot this
suggests that there ought to be some non-GCC ARM build tests.

~Andrew
Julien Grall May 26, 2023, 12:09 p.m. UTC | #2
Hi,

On 25/05/2023 20:15, Stewart Hildebrand wrote:
> clang doesn't like extern with __attribute__((__used__)):
> 
>    ./arch/arm/include/asm/setup.h:171:8: error: 'used' attribute ignored [-Werror,-Wignored-attributes]
>    extern DEFINE_BOOT_PAGE_TABLE(boot_pgtable);
>           ^
>    ./arch/arm/include/asm/lpae.h:273:29: note: expanded from macro 'DEFINE_BOOT_PAGE_TABLE'
>    lpae_t __aligned(PAGE_SIZE) __section(".data.page_aligned")                   \
>                                ^
>    ./include/xen/compiler.h:71:27: note: expanded from macro '__section'
>    #define __section(s)      __used __attribute__((__section__(s)))
>                              ^
>    ./include/xen/compiler.h:104:39: note: expanded from macro '__used'
>    #define __used         __attribute__((__used__))
>                                          ^
> 
> Simplify the declarations by getting rid of the macro (and thus the
> __aligned/__section/__used attributes) in the header. No functional change
> intended as the macro/attributes are present in the respective definitions in
> xen/arch/arm/mm.c.
> 
> Fixes: 1c78d76b67e1 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable the identity mapping")
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
index 38e2ce255fcf..1dbf3ced8079 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -168,13 +168,13 @@  u32 device_tree_get_u32(const void *fdt, int node,
 int map_range_to_domain(const struct dt_device_node *dev,
                         u64 addr, u64 len, void *data);
 
-extern DEFINE_BOOT_PAGE_TABLE(boot_pgtable);
+extern lpae_t boot_pgtable[XEN_PT_LPAE_ENTRIES];
 
 #ifdef CONFIG_ARM_64
-extern DEFINE_BOOT_PAGE_TABLE(boot_first_id);
+extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
 #endif
-extern DEFINE_BOOT_PAGE_TABLE(boot_second_id);
-extern DEFINE_BOOT_PAGE_TABLE(boot_third_id);
+extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
+extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
 
 /* Find where Xen will be residing at runtime and return a PT entry */
 lpae_t pte_of_xenaddr(vaddr_t);