Skip to contentSkip to conversation

arm64: support __int128 with clang

PATCH In review Jason A. Donenfeld 3 participants 7 messages Dec 23, 2017 – Apr 24, 2018 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: support __int128 with clang

Commit fb8722735f50 ("arm64: support __int128 on gcc 5+") added support for arm64 __int128 with gcc with a version-conditional, but neglected to enable this for clang, which in fact appears to support aarch64 __int128. This commit therefore enables it if the compiler is clang, using the same type of makefile conditional used elsewhere in the tree.

---
 arch/arm64/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/Makefile +4 -0
index b481b4a7c011..16c2e8b58546 100644
@@ -57,7 +57,11 @@ KBUILD_AFLAGS	+= $(lseinstr) $(brokengasinst)
 KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
 
+ifeq ($(cc-name),clang)
+KBUILD_CFLAGS	+= -DCONFIG_ARCH_SUPPORTS_INT128
+else
 KBUILD_CFLAGS	+= $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
Signature · 1 line
2.15.1
#1 lore raw

Hi Will,

Would you review/merge this when you have a chance?

Thanks,
Jason

Quoted 30 lines · Jason A. Donenfeld

Commit fb8722735f50 ("arm64: support __int128 on gcc 5+") added support for arm64 __int128 with gcc with a version-conditional, but neglected to enable this for clang, which in fact appears to support aarch64 __int128. This commit therefore enables it if the compiler is clang, using the same type of makefile conditional used elsewhere in the tree.

---
 arch/arm64/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/Makefile +4 -1
index b481b4a7c011..16c2e8b58546 100644
@@ -57,7 +57,11 @@ KBUILD_AFLAGS        += $(lseinstr) $(brokengasinst)
 KBUILD_CFLAGS  += $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS  += $(call cc-option,-mabi=lp64)
 
+ifeq ($(cc-name),clang)
+KBUILD_CFLAGS  += -DCONFIG_ARCH_SUPPORTS_INT128
+else
 KBUILD_CFLAGS  += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
--

2.15.1

#2 lore raw
Quoted 1 line · Jason A. Donenfeld

Would you review/merge this when you have a chance?

No real objection from me, but does the arm64 kernel actually build with clang?

Will

Quoted 31 lines · Jason A. Donenfeld
Quoted 30 lines

Commit fb8722735f50 ("arm64: support __int128 on gcc 5+") added support for arm64 __int128 with gcc with a version-conditional, but neglected to enable this for clang, which in fact appears to support aarch64 __int128. This commit therefore enables it if the compiler is clang, using the same type of makefile conditional used elsewhere in the tree.

---
 arch/arm64/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/Makefile +4 -1
index b481b4a7c011..16c2e8b58546 100644
@@ -57,7 +57,11 @@ KBUILD_AFLAGS        += $(lseinstr) $(brokengasinst)
 KBUILD_CFLAGS  += $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS  += $(call cc-option,-mabi=lp64)
 
+ifeq ($(cc-name),clang)
+KBUILD_CFLAGS  += -DCONFIG_ARCH_SUPPORTS_INT128
+else
 KBUILD_CFLAGS  += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
--

2.15.1

#3 lore raw
Quoted 5 lines · Will Deacon
Quoted 1 line · Jason A. Donenfeld

Would you review/merge this when you have a chance?

No real objection from me, but does the arm64 kernel actually build with clang?

I've been told that Android is moving their kernel builds over to clang entirely.

#4 lore raw
Quoted 9 lines · Jason A. Donenfeld
Quoted 5 lines · Will Deacon
Quoted 1 line · Jason A. Donenfeld

Would you review/merge this when you have a chance?

No real objection from me, but does the arm64 kernel actually build with clang?

I've been told that Android is moving their kernel builds over to clang entirely.

More info:
https://github.com/nathanchance/android-kernel-clang
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/#llvm-users
https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/809774

I think we have good reason for merging this patch.

reviewer
#5 lore raw
In reply to Will Deacon
Quoted 5 lines · Will Deacon
Quoted 1 line · Jason A. Donenfeld

Would you review/merge this when you have a chance?

No real objection from me, but does the arm64 kernel actually build with clang?

I belevie that currently it is not possible to use a released version of clang to build a working kernel without additional patches (at least 5.0.0, there don't seem to be any 6.0.0 binaries that can target AArch64). Issues include:

* Released versions of clang don't support the 's' constraint used in some hyp code.

* Released versions of clang don't support 'rX' as a register name, as is used by some workaround code shared between arm/arm64.

* Additional flags need to be passed for hyp code to function correctly, since clang will convert switch statements into jump tables, meaning they aren't position-independent.

I tried building a tip-of-tree clang recently (r330441 with llvm r330440) to see what was solved so far, but this blew up when bulding the kernel, and I was going to wait for the 7.0.0 release before trying again.

Thanks,
Mark.

reviewer
#6 lore raw
Quoted 11 lines · Mark Rutland

I belevie that currently it is not possible to use a released version of clang to build a working kernel without additional patches (at least 5.0.0, there don't seem to be any 6.0.0 binaries that can target AArch64). Issues include:

* Released versions of clang don't support the 's' constraint used in some hyp code.

* Released versions of clang don't support 'rX' as a register name, as is used by some workaround code shared between arm/arm64.

This case will apparently be fixed for 6.0.1 (and presumably 7.0.0):

https://reviews.llvm.org/rL328829
https://bugs.llvm.org/show_bug.cgi?id=36862

Neither have been released yet.

Mark.