Skip to contentSkip to conversation

arm64 softfloat

PATCH Leif Lindholm 3 participants 10 messages Jun 2, 2015 – Jun 3, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

As I mentioned yeaterday, I ran into some toolchain issues yesterday. When attempting my first build on Fedora 22, which uses GCC5.1, the build fails. First with an internal compiler error, and with a workaround for that, it simply refuses to go past.

Basically, AArch64 (arm64) does not define a soft-float ABI. Recent versions of GCC now (presumably correctly) bails out when encountering floating-point if +nofp has been specified in -march flags. Also, the UEFI specification mandates that for aarch64 the cpu is configured such that floating-point exceptions are not generated - so it should be safe to generate floating-point instructions.

So would it be possible to do something like the below?:

From a1821c9222bab447b2d3faccf69e518c65e0f638 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <[email protected]>
Date: Mon, 1 Jun 2015 23:58:44 +0100
Subject: [PATCH] arm64: do not force-enable soft-float

AArch64 (arm64) does not define a soft-float ABI. GCC5.1 now (presumably correctly) bails out when encountering floating-point if +nofp has been specified in -march flags. Also, the UEFI specification mandates that the cpu is configured such that floating-point exceptions are not generated - so it should be safe to generate floating-point instructions.

So drop +nofp and +nosimd from configure.ac for arm64.

---
 configure.ac | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
configure.ac +3 -12
index 891c14f..0a6d2e9 100644
@@ -686,9 +686,8 @@ if test x"$platform" != xemu ; then
   AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
     grub_cv_target_cc_soft_float=no
     if test "x$target_cpu" = xarm64; then
-       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-		         [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
+       CFLAGS="$TARGET_CFLAGS -Werror"
+       grub_cv_target_cc_soft_float=""
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
@@ -720,15 +719,7 @@ if test x"$platform" != xemu ; then
       TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
       ;;
   esac
-  case x"$grub_cv_target_cc_soft_float" in
-    x"-march=armv8-a+nofp+nosimd")
-      # +nosimd disables also the cache opcodes that we need in asm.
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
-      ;;
-    *)
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
-      ;;
-  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 
 fi
 
Signature · 1 line
2.1.4
#1 lore raw

Please give more details as to where we have floats. We shouldn't have any

Quoted 80 lines · Leif Lindholm

Hi,

As I mentioned yeaterday, I ran into some toolchain issues yesterday. When attempting my first build on Fedora 22, which uses GCC5.1, the build fails. First with an internal compiler error, and with a workaround for that, it simply refuses to go past.

Basically, AArch64 (arm64) does not define a soft-float ABI. Recent versions of GCC now (presumably correctly) bails out when encountering floating-point if +nofp has been specified in -march flags. Also, the UEFI specification mandates that for aarch64 the cpu is configured such that floating-point exceptions are not generated - so it should be safe to generate floating-point instructions.

So would it be possible to do something like the below?:

From a1821c9222bab447b2d3faccf69e518c65e0f638 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <[email protected]>
Date: Mon, 1 Jun 2015 23:58:44 +0100
Subject: [PATCH] arm64: do not force-enable soft-float

AArch64 (arm64) does not define a soft-float ABI. GCC5.1 now (presumably correctly) bails out when encountering floating-point if +nofp has been specified in -march flags. Also, the UEFI specification mandates that the cpu is configured such that floating-point exceptions are not generated - so it should be safe to generate floating-point instructions.

So drop +nofp and +nosimd from configure.ac for arm64.

---
 configure.ac | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
configure.ac +0 -0
index 891c14f..0a6d2e9 100644
@@ -686,9 +686,8 @@ if test x"$platform" != xemu ; then
   AC_CACHE_CHECK([for options to get soft-float],

grub_cv_target_cc_soft_float, [
grub_cv_target_cc_soft_float=no
if test "x$target_cpu" = xarm64; then

configure.ac +0 -3
-       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-

[grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])

configure.ac +3 -11
+       CFLAGS="$TARGET_CFLAGS -Werror"
+       grub_cv_target_cc_soft_float=""
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt
-Werror"
@@ -720,15 +719,7 @@ if test x"$platform" != xemu ; then
       TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
       ;;
   esac
-  case x"$grub_cv_target_cc_soft_float" in
-    x"-march=armv8-a+nofp+nosimd")
-      # +nosimd disables also the cache opcodes that we need in asm.
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
-      ;;
-    *)
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
-      ;;
-  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 
 fi
 
--

2.1.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Please give more details as to where we have floats. We shouldn't have any

Ok, seems I was tripping over myself with the internal compiler error workaround (-mgeneral-regs-only), and applying it on the host tools as well, where +nofp was (correctly) not being enforced, causing a clash.

So, rewinding a bit - in order to work around the gcc 5.1 build issue (which is not Fedora specific), we can use -mgeneral-regs-only instead of -march=armv8-a+nofp. If we do this, we can also get rid of the arm64-specific twiddling that drops the +nosimd.

Like so:

From 43d4231432838821cabe4f6aea4f0f50e87af9c4 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <[email protected]>
Date: Tue, 2 Jun 2015 15:41:09 +0100
Subject: [PATCH] configure.ac: clean up arm64 soft-float handling

Fix compilation with gcc 5.1 (avoid internal compiler error), by replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only.

This also enables the removal of some further conditional build flag setting.

---
 configure.ac | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
configure.ac +3 -11
index 891c14f..fd8a62e 100644
@@ -686,9 +686,9 @@ if test x"$platform" != xemu ; then
   AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
     grub_cv_target_cc_soft_float=no
     if test "x$target_cpu" = xarm64; then
-       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
+       CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-		         [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
+		         [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
@@ -720,15 +720,7 @@ if test x"$platform" != xemu ; then
       TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
       ;;
   esac
-  case x"$grub_cv_target_cc_soft_float" in
-    x"-march=armv8-a+nofp+nosimd")
-      # +nosimd disables also the cache opcodes that we need in asm.
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
-      ;;
-    *)
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
-      ;;
-  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 
 fi
 
Signature · 1 line
2.1.4
#3 lore raw
Quoted 8 lines · Leif Lindholm
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Please give more details as to where we have floats. We shouldn't have any

Ok, seems I was tripping over myself with the internal compiler error workaround (-mgeneral-regs-only), and applying it on the host tools as well, where +nofp was (correctly) not being enforced, causing a clash.

What is the relation of -mgeneral-regs-only with +nofp? The decription of -mgeneral-regs-only in manual is very vague

Quoted 55 lines

So, rewinding a bit - in order to work around the gcc 5.1 build issue (which is not Fedora specific), we can use -mgeneral-regs-only instead of -march=armv8-a+nofp. If we do this, we can also get rid of the arm64-specific twiddling that drops the +nosimd.

Like so:

Quoted 1 line

From 43d4231432838821cabe4f6aea4f0f50e87af9c4 Mon Sep 17 00:00:00 2001

From: Leif Lindholm <[email protected]>
Date: Tue, 2 Jun 2015 15:41:09 +0100
Subject: [PATCH] configure.ac: clean up arm64 soft-float handling

Fix compilation with gcc 5.1 (avoid internal compiler error), by replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only.

This also enables the removal of some further conditional build flag setting.

---
 configure.ac | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
configure.ac +3 -11
index 891c14f..fd8a62e 100644
@@ -686,9 +686,9 @@ if test x"$platform" != xemu ; then
   AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
     grub_cv_target_cc_soft_float=no
     if test "x$target_cpu" = xarm64; then
-       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
+       CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-		         [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
+		         [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
@@ -720,15 +720,7 @@ if test x"$platform" != xemu ; then
       TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
       ;;
   esac
-  case x"$grub_cv_target_cc_soft_float" in
-    x"-march=armv8-a+nofp+nosimd")
-      # +nosimd disables also the cache opcodes that we need in asm.
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
-      ;;
-    *)
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
-      ;;
-  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 
 fi
 
#4 lore raw

В Tue, 02 Jun 2015 18:37:32 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 11 lines · Leif Lindholm
Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line

Please give more details as to where we have floats. We shouldn't have any

Ok, seems I was tripping over myself with the internal compiler error workaround (-mgeneral-regs-only), and applying it on the host tools as well, where +nofp was (correctly) not being enforced, causing a clash.

What is the relation of -mgeneral-regs-only with +nofp? The decription of -mgeneral-regs-only in manual is very vague

According to
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774a/chr1392305446662.html

1.16 -mgeneral-regs-only

Prevents the use of floating-point instructions or floating-point registers.
Note
The -mgeneral-regs-only option is only valid with the aarch64-arm-none-eabi target. Use -mfpu=none to prevent the use of floating-point instructions or floating-point registers for the armv8a-arm-none-eabi target.

The description is for armclang; we can just hope that GCC is using the same semantic.

Quoted 57 lines
Quoted 55 lines

So, rewinding a bit - in order to work around the gcc 5.1 build issue (which is not Fedora specific), we can use -mgeneral-regs-only instead of -march=armv8-a+nofp. If we do this, we can also get rid of the arm64-specific twiddling that drops the +nosimd.

Like so:

Quoted 1 line

From 43d4231432838821cabe4f6aea4f0f50e87af9c4 Mon Sep 17 00:00:00 2001

From: Leif Lindholm <[email protected]>
Date: Tue, 2 Jun 2015 15:41:09 +0100
Subject: [PATCH] configure.ac: clean up arm64 soft-float handling

Fix compilation with gcc 5.1 (avoid internal compiler error), by replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only.

This also enables the removal of some further conditional build flag setting.

---
 configure.ac | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
configure.ac +3 -11
index 891c14f..fd8a62e 100644
@@ -686,9 +686,9 @@ if test x"$platform" != xemu ; then
   AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
     grub_cv_target_cc_soft_float=no
     if test "x$target_cpu" = xarm64; then
-       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
+       CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-		         [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
+		         [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
@@ -720,15 +720,7 @@ if test x"$platform" != xemu ; then
       TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
       ;;
   esac
-  case x"$grub_cv_target_cc_soft_float" in
-    x"-march=armv8-a+nofp+nosimd")
-      # +nosimd disables also the cache opcodes that we need in asm.
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
-      ;;
-    *)
-      TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
-      ;;
-  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 
 fi
 
#5 lore raw
Quoted 5 lines · Andrei Borzenkov
Quoted 2 lines

What is the relation of -mgeneral-regs-only with +nofp? The decription of -mgeneral-regs-only in manual is very vague

According to
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774a/chr1392305446662.html

That is ARM's commercial clang-based compiler suite though, not upstream clang.

Quoted 8 lines

1.16 -mgeneral-regs-only

Prevents the use of floating-point instructions or floating-point registers.
Note
The -mgeneral-regs-only option is only valid with the aarch64-arm-none-eabi target. Use -mfpu=none to prevent the use of floating-point instructions or floating-point registers for the armv8a-arm-none-eabi target.

The description is for armclang; we can just hope that GCC is using the same semantic.

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
---
Generate code which uses only the general registers.
---

http://clang.llvm.org/docs/UsersManual.html
---
Generate code which only uses the general purpose registers.

This option restricts the generated code to use general registers only. This only applies to the AArch64 architecture.
---

/
Leif

#6 lore raw

В Wed, 3 Jun 2015 12:06:50 +0100
Leif Lindholm <[email protected]> пишет:

Quoted 16 lines · Andrei Borzenkov
Quoted 5 lines
Quoted 2 lines

What is the relation of -mgeneral-regs-only with +nofp? The decription of -mgeneral-regs-only in manual is very vague

According to
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774a/chr1392305446662.html

That is ARM's commercial clang-based compiler suite though, not upstream clang.

Quoted 6 lines

1.16 -mgeneral-regs-only

Prevents the use of floating-point instructions or floating-point registers.
Note
The -mgeneral-regs-only option is only valid with the aarch64-arm-none-eabi target. Use -mfpu=none to prevent the use of floating-point instructions or floating-point registers for the armv8a-arm-none-eabi target.

Quoted 8 lines
Quoted 2 lines

The description is for armclang; we can just hope that GCC is using the same semantic.

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
---
Generate code which uses only the general registers.
---

Sure, I know this. Unfortunately it does not say how it is related to floating point arithmetic at all. armclang at least makes it explicit.

Quoted 15 lines

http://clang.llvm.org/docs/UsersManual.html
---
Generate code which only uses the general purpose registers.

This option restricts the generated code to use general registers only. This only applies to the AArch64 architecture.
---

/
Leif

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 22 lines · Andrei Borzenkov

В Wed, 3 Jun 2015 12:06:50 +0100
Leif Lindholm <[email protected]> пишет:

Quoted 19 lines · Andrei Borzenkov
Quoted 5 lines
Quoted 2 lines

What is the relation of -mgeneral-regs-only with +nofp? The decription of -mgeneral-regs-only in manual is very vague

According to
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774a/chr1392305446662.html

That is ARM's commercial clang-based compiler suite though, not upstream clang.

Quoted 8 lines

1.16 -mgeneral-regs-only

Prevents the use of floating-point instructions or floating-point registers.
Note
The -mgeneral-regs-only option is only valid with the aarch64-arm-none-eabi target. Use -mfpu=none to prevent the use of floating-point instructions or floating-point registers for the armv8a-arm-none-eabi target.

The description is for armclang; we can just hope that GCC is using the same semantic.

Quoted 7 lines
Quoted 4 lines

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
---
Generate code which uses only the general registers.
---

Sure, I know this. Unfortunately it does not say how it is related to floating point arithmetic at all. armclang at least makes it explicit.

While it could more explicit, I am not aware of any A64 floating-point instructions that can operate without floating-point registers.

Also, I spoke with the ARM gcc devs - the gcc documentation is intended to be improved to also state that "-mgeneral-regs-only is equivalent to +nofp being specified".

/
Leif

#8 lore raw

В Wed, 3 Jun 2015 17:52:12 +0100
Leif Lindholm <[email protected]> пишет:

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
---
Generate code which uses only the general registers.
---

Sure, I know this. Unfortunately it does not say how it is related to floating point arithmetic at all. armclang at least makes it explicit.

Quoted 7 lines

While it could more explicit, I am not aware of any A64 floating-point instructions that can operate without floating-point registers.

Also, I spoke with the ARM gcc devs - the gcc documentation is intended to be improved to also state that "-mgeneral-regs-only is equivalent to +nofp being specified".

Sounds like it is OK then.

#9 lore raw

Ok with me as well. Go ahead

Quoted 23 lines · Andrei Borzenkov

В Wed, 3 Jun 2015 17:52:12 +0100
Leif Lindholm <[email protected]> пишет:

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
---
Generate code which uses only the general registers.
---

Sure, I know this. Unfortunately it does not say how it is related to floating point arithmetic at all. armclang at least makes it explicit.

Quoted 7 lines

While it could more explicit, I am not aware of any A64 floating-point instructions that can operate without floating-point registers.

Also, I spoke with the ARM gcc devs - the gcc documentation is intended to be improved to also state that "-mgeneral-regs-only is equivalent to +nofp being specified".

Sounds like it is OK then.