CONFIG_ARCH_SUPPORTS_INT128 for AArch64
Hi folks,
Older versions of gcc are horrible for int128_t on aarch64, emitting a __multi3 call, which is slow and defeats the purpose. However, more recent versions of gcc (since 5, IIRC), do the right thing and produce the proper inlined instructions.
Do we have the infrastructure available to test for this, and conditionally set CONFIG_ARCH_SUPPORTS_INT128 if we do?
Thanks,
Jason
Mark Rutland
reviewerQuoted 9 lines · Jason A. Donenfeld
Hi folks,
Older versions of gcc are horrible for
int128_ton aarch64, emitting a__multi3call, which is slow and defeats the purpose. However, more recent versions of gcc (since 5, IIRC), do the right thing and produce the proper inlined instructions.Do we have the infrastructure available to test for this, and conditionally set
CONFIG_ARCH_SUPPORTS_INT128if we do?
Judging by Documentation/kbuild/makefiles.txt, we could do something like the below in the arm64 Makefile:
cflags-y += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
Note that I havent tested this at all.
Thanks,
Hi Mark,
Quoted 4 lines · Mark Rutland
Judging by
Documentation/kbuild/makefiles.txt, we could do something like the below in the arm64Makefile:cflags-y += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
Okay, in that case, I'll re-research the gcc commit that made int128 work properly on aarch64, confirm the release version, and then submit a patch doing this.
Jason
PATCH 1/1 arm64: support __int128 on gcc 5+
Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, horrible performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.
The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
--- arch/arm64/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Makefile +2 -0
@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
Signature · 1 line
2.14.2
Re: [PATCH] arm64: support __int128 on gcc 5+
Quoted 21 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, horrible performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351dThis commit appears to be part of the gcc 5 release.
Signed-off-by Jason A. Donenfeld <[email protected]>--- arch/arm64/Makefile | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/Makefile +0
-0
arch/arm64/Makefile KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) · line 60
Quoted 8 lines
arch/arm64/Makefile +2
-0@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
Which code in the kernel actually uses 128-bit types directly? I know we have some unfortunate occurences in our headers (including uapi) for the vector registers, but I thought we generally used asm or copy routines to access those.
Are you seeing a performance issue without this?
Will
Re: [PATCH] arm64: support __int128 on gcc 5+
Hi Will,
Quoted 4 lines · Will Deacon
Which code in the kernel actually uses 128-bit types directly? I know we have some unfortunate occurences in our headers (including uapi) for the vector registers, but I thought we generally used asm or copy routines to access those.
math64.h provides it, and various things throughout use those functions. Notably, the scheduler and kvm use those the __int128 functions. There's also an elliptic curve implementation that uses it, which makes a big difference. And soon I'll be adding an implementation of curve25519 that will make heavy use of these instructions for significant speedups as well.
Generally, adding this CONFIG_ARCH key is a hint for current and future bits of code, so that they can use the faster 128-bit implementations when available. Not providing it when it's there and available would be silly. This wasn't originally added to the architecture, because when the Kconfig symbol was added, gcc didn't have sane support for it on aarch64. But now it does, so let's support it.
Jason
Re: [PATCH] arm64: support __int128 on gcc 5+
Hi Jason,
Quoted 6 lines · Jason A. Donenfeld
Quoted 4 lines · Will Deacon
Which code in the kernel actually uses 128-bit types directly? I know we have some unfortunate occurences in our headers (including uapi) for the vector registers, but I thought we generally used asm or copy routines to access those.
Quoted 6 lines
math64.hprovides it, and various things throughout use those functions. Notably, the scheduler and kvm use those the__int128functions. There's also an elliptic curve implementation that uses it, which makes a big difference. And soon I'll be adding an implementation of curve25519 that will make heavy use of these instructions for significant speedups as well.
Thanks for the info. It does indeed look like mul_u64_u64_shr improves pretty drastically with this patch, so that sounds good to me. We don't ever call that function on arm64, but hey.
Quoted 7 lines
Generally, adding this
CONFIG_ARCHkey is a hint for current and future bits of code, so that they can use the faster 128-bit implementations when available. Not providing it when it's there and available would be silly. This wasn't originally added to the architecture, because when theKconfigsymbol was added, gcc didn't have sane support for it on aarch64. But now it does, so let's support it.
Sure, I'll wait for your patch that matches the relevant compiler versions.
Will
Re: [PATCH] arm64: support __int128 on gcc 5+
Quoted 2 lines · Will Deacon
Sure, I'll wait for your patch that matches the relevant compiler versions.
That's the patch in this thread:
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-October/539943.html
As mentioned in there, gcc does the right thing for 5 and up:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
Re: [PATCH] arm64: support __int128 on gcc 5+
In reply to Jason A. DonenfeldHi Jason,
Quoted 21 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, horrible performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351dThis commit appears to be part of the gcc 5 release.
Signed-off-by Jason A. Donenfeld <[email protected]>--- arch/arm64/Makefile | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/Makefile +0
-0
arch/arm64/Makefile KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) · line 60
Quoted 8 lines
arch/arm64/Makefile +2
-0@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
This breaks an allmodconfig build:
lib/ubsan.o: In function `get_signed_val':
ubsan.c:(.text.unlikely+0x13c): undefined reference to __ashlti3' ubsan.c:(.text.unlikely+0x144): undefined reference to __ashrti3'
make: *** [vmlinux] Error 1
so I'm going to drop it for now. My toolchain is:
gcc version 7.1.1 20170707 (Linaro GCC 7.1-2017.08)
Will
PATCH v2 1/1 arm64: support __int128 on gcc 5+
Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.
The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
There are still a few instructions, such as __ashlti3 and __ashrti3, that require libgcc, which is fine. So, we also link to libgcc for these functions when needed, which is what several other architectures already have been doing for a long time.
--- arch/arm64/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/Makefile +3 -1
@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
@@ -108,7 +110,7 @@ core-$(CONFIG_NET) += arch/arm64/net/ core-$(CONFIG_KVM) += arch/arm64/kvm/ core-$(CONFIG_XEN) += arch/arm64/xen/ core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ -libs-y := arch/arm64/lib/ $(libs-y) +libs-y := arch/arm64/lib/ $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) $(libs-y) core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a # Default target when executing plain make
Signature · 1 line
2.14.2
Re: [PATCH v2] arm64: support __int128 on gcc 5+
Hi Jason,
[+Ard]
Quoted 15 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.There are still a few instructions, such as
__ashlti3and__ashrti3, that require libgcc, which is fine. So, we also link to libgcc for these functions when needed, which is what several other architectures already have been doing for a long time.
Quoted 4 lines
Signed-off-by Jason A. Donenfeld <[email protected]>--- arch/arm64/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
We used to link against libgcc way back when, but that dependency was removed in commit d67703a8a69e ("arm64: kill off the libgcc dependency") and I'm really not keen to add it back. I also think that there might be licensing concerns if you link against it and make use of GCC plugins, but IANAL.
Shouldn't we just provide our own implementations of __ashlti3 and __ashrti3 instead?
Cheers,
Will
Quoted 25 lines
arch/arm64/Makefile +3
-1@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__@@ -108,7 +110,7 @@ core-$(CONFIG_NET) += arch/arm64/net/ core-$(CONFIG_KVM) += arch/arm64/kvm/ core-$(CONFIG_XEN) += arch/arm64/xen/ core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ -libs-y := arch/arm64/lib/ $(libs-y) +libs-y := arch/arm64/lib/ $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) $(libs-y) core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a # Default target when executing plain makeSignature · 1 line
2.14.2
Re: [PATCH v2] arm64: support __int128 on gcc 5+
Quoted 28 lines · Will Deacon
Hi Jason,
[+Ard]
Quoted 16 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.There are still a few instructions, such as
__ashlti3and__ashrti3, that require libgcc, which is fine. So, we also link to libgcc for these functions when needed, which is what several other architectures already have been doing for a long time.Quoted 4 lines
Signed-off-by Jason A. Donenfeld <[email protected]>---
arch/arm64/Makefile| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 6 lines
We used to link against libgcc way back when, but that dependency was removed in commit
d67703a8a69e("arm64: kill off the libgcc dependency") and I'm really not keen to add it back. I also think that there might be licensing concerns if you link against it and make use of GCC plugins, but IANAL.
Is it guaranteed that libgcc doesn?t use neon/vfp? We can?t use it in the kernel otherwise.
Quoted 32 lines
Shouldn't we just provide our own implementations of
__ashlti3and__ashrti3instead?Cheers,
Will
Quoted 25 lines
arch/arm64/Makefile +2
-0@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
KBUILD_CPPFLAGS+= -mbig-endian
CHECKFLAGS += -D__AARCH64EB__arch/arm64/Makefile +0
-0@@ -108,7 +110,7 @@ core-$(CONFIG_NET) += arch/arm64/net/core-$(CONFIG_KVM) +=
arch/arm64/kvm/
core-$(CONFIG_XEN) +=arch/arm64/xen/
core-$(CONFIG_CRYPTO) +=arch/arm64/crypto/arch/arm64/Makefile +1
-1-libs-y := arch/arm64/lib/ $(libs-y) +libs-y := arch/arm64/lib/ $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) $(libs-y)core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
# Default target when executing plain make
Signature · 1 line
2.14.2
Re: [PATCH v2] arm64: support __int128 on gcc 5+
In reply to Will DeaconQuoted 5 lines · Will Deacon
We used to link against libgcc way back when, but that dependency was removed in commit
d67703a8a69e("arm64: kill off the libgcc dependency") and I'm really not keen to add it back. I also think that there might be licensing concerns if you link against it and make use of GCC plugins, but IANAL.
Considering many other architectures link to it, that seems strange to me...
Quoted 3 lines
Shouldn't we just provide our own implementations of
__ashlti3and__ashrti3instead?
I just coded up an implementation. I'm testing it now and I'll have v3 for you shortly.
Jason
PATCH v3 1/1 arm64: support __int128 on gcc 5+
Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.
The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
There are still a few instructions, __ashlti3 and __ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.
---
Changes v2->v3:
- We now just provide trivial implementations for the missing functions, rather than linking to libgcc.
arch/arm64/Makefile | 2 ++ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/tishift.S | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/lib/tishift.S
arch/arm64/Makefile +2 -0
@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
arch/arm64/lib/Makefile +1 -1
@@ -2,7 +2,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ - strchr.o strrchr.o + strchr.o strrchr.o tishift.o # Tell the compiler to treat all general purpose registers (with the # exception of the IP registers, which are already handled by the caller
arch/arm64/lib/tishift.S new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.14.2
PATCH v4 1/1 arm64: support __int128 on gcc 5+
Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.
The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
There are still a few instructions, __ashlti3 and __ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.
---
Changes v3->v4:
- Typo in comment
- Relabel second function
arch/arm64/Makefile | 2 ++ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/tishift.S | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/lib/tishift.S
arch/arm64/Makefile +2 -0
@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
arch/arm64/lib/Makefile +1 -1
@@ -2,7 +2,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ - strchr.o strrchr.o + strchr.o strrchr.o tishift.o # Tell the compiler to treat all general purpose registers (with the # exception of the IP registers, which are already handled by the caller
arch/arm64/lib/tishift.S new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.15.0
Catalin Marinas
maintainerRe: [PATCH v4] arm64: support __int128 on gcc 5+
Quoted 10 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
Quoted 5 lines
There are still a few instructions,
__ashlti3and__ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.Signed-off-by Jason A. Donenfeld <[email protected]>
According to Arnd, linux-next (with this patch included) fails to build with gcc-7 (config: https://pastebin.com/raw/sgvPe96e).
Will is managing the upcoming merging window for arm64 but is travelling this week. I'll wait for couple of days, he'll probably catch up with emails but my suggestion is that we revert the patch and push it back again into -next after the 4.15 merging window.
Signature · 1 line
Catalin
Catalin Marinas
maintainerRe: [PATCH v4] arm64: support __int128 on gcc 5+
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
Quoted 8 lines
Quoted 5 lines
There are still a few instructions,
__ashlti3and__ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.Signed-off-by Jason A. Donenfeld <[email protected]>According to Arnd, linux-next (with this patch included) fails to build with gcc-7 (config: https://pastebin.com/raw/sgvPe96e).
Actually, it fails with gcc-6 as well (gcc (Debian 6.3.0-18) 6.3.0 20170516) with this error:
kernel/sched/fair.o: In function `__calc_delta':
fair.c:(.text+0x84c): undefined reference to __lshrti3' kernel/time/timekeeping.o: In function timekeeping_resume':
timekeeping.c:(.text+0x2cac): undefined reference to `__lshrti3'
So I'm for reverting the commit and we should allow more randconfig tests for the 4.16 merging window.
Signature · 1 line
Catalin
A message that is not in the archive (sent off-list or not yet received): CAHmME9p+ef-+fmdiO15LU7X3Sr-CDyngpPwKZN2FqOQmZNjLtg@mail.gmail.com
Re: [PATCH v4] arm64: support __int128 on gcc 5+
Quoted 5 lines · Jason A. Donenfeld
Wait, please don't jump to that decision so quickly.
Are you sure the fail is for v4? Will mentioned this with v1, which is whay this current v4 is supposed to fix up.
It appears your v4 adds __ashlti3() and __ashrti3, whereas the error is about __lshrti3() being undefined.
Quoted 39 lines · Catalin Marinas
Quoted 12 lines · Catalin Marinas
Quoted 11 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.Quoted 8 lines
Quoted 5 lines
There are still a few instructions,
__ashlti3and__ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.Signed-off-by Jason A. Donenfeld <[email protected]>According to Arnd, linux-next (with this patch included) fails to build with gcc-7 (config: https://pastebin.com/raw/sgvPe96e).
Actually, it fails with gcc-6 as well (gcc (Debian 6.3.0-18) 6.3.0 20170516) with this error:
kernel/sched/fair.o: In function `__calc_delta':
fair.c:(.text+0x84c): undefined reference to__lshrti3' kernel/time/timekeeping.o: In functiontimekeeping_resume':
timekeeping.c:(.text+0x2cac): undefined reference to `__lshrti3'So I'm for reverting the commit and we should allow more randconfig tests for the 4.16 merging window.
--
Catalin
PATCH v5 1/1 arm64: support __int128 on gcc 5+
Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.
The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.
There are still a few instructions, __ashlti3, __ashrti3, and __lshrti3 which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.
---
Changes v4->v5:
- Add implementation of __lshrti3. (Note that __lshlti3 is not a function.)
arch/arm64/Makefile | 2 ++ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/tishift.S | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/lib/tishift.S
arch/arm64/Makefile +2 -0
@@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
arch/arm64/lib/Makefile +1 -1
@@ -3,7 +3,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ - strchr.o strrchr.o + strchr.o strrchr.o tishift.o # Tell the compiler to treat all general purpose registers (with the # exception of the IP registers, which are already handled by the caller
arch/arm64/lib/tishift.S new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.15.0
Re: [PATCH v4] arm64: support __int128 on gcc 5+
In reply to Ard BiesheuvelQuoted 2 lines · Ard Biesheuvel
It appears your v4 adds
__ashlti3()and__ashrti3, whereas the error is about__lshrti3()being undefined.
Whoopsie. v5 adds the final missing function. Looks like it now compiles for -next with the config you provided me.
Re: [PATCH v4] arm64: support __int128 on gcc 5+
In reply to Catalin MarinasQuoted 17 lines · Catalin Marinas
Quoted 10 lines · Jason A. Donenfeld
Versions of gcc prior to gcc 5 emitted a
__multi3function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups.The gcc commit that added proper Aarch64 support is:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d
This commit appears to be part of the gcc 5 release.Quoted 5 lines
There are still a few instructions,
__ashlti3and__ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated.Signed-off-by Jason A. Donenfeld <[email protected]>
Quoted 7 lines
According to Arnd, linux-next (with this patch included) fails to build with gcc-7 (config: https://pastebin.com/raw/sgvPe96e).
Will is managing the upcoming merging window for arm64 but is travelling this week. I'll wait for couple of days, he'll probably catch up with emails but my suggestion is that we revert the patch and push it back again into -next after the 4.15 merging window.
So I pushed a fixup patch on top of for-next/core, but I suggest we temporarily revert the- DCONFIG_ARCH_SUPPORTS_INT128 option if any other issues crop up.
Cheers,
Will
Re: [PATCH v4] arm64: support __int128 on gcc 5+
Hi Will,
Quoted 3 lines · Will Deacon
So I pushed a fixup patch on top of for-next/core, but I suggest we temporarily revert the-
DCONFIG_ARCH_SUPPORTS_INT128option if any other issues crop up.
The fixup looks good to me.
If there are additional problems, I'm happy to keep providing patches until it's sorted. I just did an allyesconfig and didn't have any problems, though, so I think we're all set now.
Jason
Re: [PATCH] arm64: support __int128 on gcc 5+
In reply to Will DeaconHi Will,
Nice catch. I posted a v2 that addresses that.
Thanks,
Jason