NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-evbarm/55778: evbarm64 GENERIC64 kernel fails to build with clang



>Number:         55778
>Category:       port-evbarm
>Synopsis:       evbarm64 GENERIC64 kernel fails to build with clang
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 02 13:40:00 +0000 2020
>Originator:     Piotr Tworek
>Release:        trunk
>Organization:
>Environment:
Linux hawk 5.9.2 #1 SMP Thu Oct 29 12:35:39 CET 2020 x86_64 AMD Ryzen 5 3600 6-Core Processor AuthenticAMD GNU/Linux
>Description:
Trying to build evbarm64 GENERIC64 kernel with clang I see the following error message:

/home/tworaz/devel/netbsd/sys/arch/aarch64/aarch64/aarch64_machdep.c:174:2: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
        isb();
        ^
./arm/cpufunc.h:72:55: note: expanded from macro 'isb'
        __asm __volatile("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory")
                                                             ^
/home/tworaz/devel/netbsd/sys/arch/aarch64/aarch64/aarch64_machdep.c:174:2: note: use constraint modifier "w"
./arm/cpufunc.h:72:32: note: expanded from macro 'isb'
        __asm __volatile("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory")
                                      ^
1 error generated.

This is a regression caused by: https://github.com/NetBSD/src/commit/b9c6da0c271a71cae0483685361bcd0edd8db6a3

The problem happens because wrong version of dsb/dmb/isb macros from sys/arch/arm/include/cpufunc.h are used. It happens because when using clang on aarch64 _ARM_ARCH_7 is not being defined. This should happen in sys/arch/arm/include/cdefs.h, due to following code:

#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A)
	/* __ARM_ARCH_8A__ is a typo */
#define _ARM_ARCH_8
#endif

#if defined (_ARM_ARCH_8) || defined (__ARM_ARCH_7__) || \
    defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) || \
    defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
	/* 7R, 7M, 7EM are for non MMU arms */
#define _ARM_ARCH_7
#endif

The problem is aarch64 clang port does not device __ARM_ARCH_8A__ as it does on arm. It does however define _ARM_ARCH=8.

__ARM_ARCH_8A__ is defined by clang/arm here:
https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets/ARM.cpp#L603

_ARM_ARCH=8 is defined bt clang/aarch64 here:
https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets/AArch64.cpp#L170
>How-To-Repeat:
Try building evbarm64 GENERIC64 kernel with clang using later trunk version of NetBSD.
>Fix:
Apply the following patch:

--- a/sys/arch/arm/include/cdefs.h
+++ b/sys/arch/arm/include/cdefs.h
@@ -10,7 +10,8 @@
 #endif
 
 
-#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A)
+#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A) || \
+    (defined (__ARM_ARCH) && __ARM_ARCH == 8)
        /* __ARM_ARCH_8A__ is a typo */
 #define _ARM_ARCH_8
 #endif



Home | Main Index | Thread Index | Old Index