This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: verify NEON support in cross toolchain


Hi all,

Just for if it help attached a patch i have locally that applies to crosstool-ng-1.8.2 which adds support for "softfp" optimized toolchains.

Some background: I needed a cortex_a8 optimized toolchain for some of our embedded products. Crosstool-NG allows to optimize somewhat the toolchain through:

"Architecture level"
"Emit assembly for CPU"
"Tune for CPU" options

but on the Floating point option it only allows to *soft* and *hard*.

According to GCC man page:

Use -mfloat-abi=softfp with the appropriate -mfpu option to allow the compiler
to generate code that makes use of the hardware floating-point capabilities
for these CPUs

To have a toolchain which defaults to "-mfloat-abi=softfp" you need to pass "--with-float=softfp" instead of "--with-float=soft|hard" which is what crosstool-ng is doing when building GCC.


With my basic knowledge on how crosstool-ng works i created a patch to solve this problem for us. The patch is posted here for if it helps someone or with some rework may be included in future releases of crosstool-ng.

The patch is based on version 1.8.2.

--
Regards,

Javier Viguera

diff -Naur crosstool-ng-1.8.2.orig/config/arch/arm.in crosstool-ng-1.8.2/config/arch/arm.in
--- crosstool-ng-1.8.2.orig/config/arch/arm.in	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/config/arch/arm.in	2010-10-19 14:30:12.000000000 +0200
@@ -11,6 +11,7 @@
     select ARCH_SUPPORT_CPU
     select ARCH_SUPPORT_TUNE
     select ARCH_SUPPORT_FPU
+    select ARCH_SUPPORT_SOFTFP
     help
       The ARM architecture, as defined by:
         http://www.arm.com/
diff -Naur crosstool-ng-1.8.2.orig/config/target.in crosstool-ng-1.8.2/config/target.in
--- crosstool-ng-1.8.2.orig/config/target.in	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/config/target.in	2010-10-19 14:30:12.000000000 +0200
@@ -15,6 +15,7 @@
 config ARCH_SUPPORT_CPU
 config ARCH_SUPPORT_TUNE
 config ARCH_SUPPORT_FPU
+config ARCH_SUPPORT_SOFTFP
 
 config ARCH_DEFAULT_HAS_MMU
 config ARCH_DEFAULT_BE
@@ -34,6 +35,7 @@
 config ARCH_BITNESS
 config ARCH_FLOAT_HW
 config ARCH_FLOAT_SW
+config ARCH_FLOAT_SOFTFP
 config TARGET_CFLAGS
 config TARGET_LDFLAGS
 
@@ -159,6 +161,10 @@
     bool
     default n
 
+config ARCH_SUPPORT_SOFTFP
+    bool
+    default n
+
 config ARCH_ARCH
     string
     prompt "Architecture level"
@@ -286,6 +292,11 @@
       If your processor has no FPU, then you most probably want this, as it
       is faster than emulating the FPU in the kernel.
 
+config ARCH_FLOAT_SOFTFP
+    bool
+    prompt "softfp"
+    depends on ARCH_SUPPORT_SOFTFP
+
 endchoice
 
 config TARGET_CFLAGS
diff -Naur crosstool-ng-1.8.2.orig/scripts/build/arch/arm.sh crosstool-ng-1.8.2/scripts/build/arch/arm.sh
--- crosstool-ng-1.8.2.orig/scripts/build/arch/arm.sh	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/scripts/build/arch/arm.sh	2010-10-19 14:30:12.000000000 +0200
@@ -4,6 +4,9 @@
     # The architecture part of the tuple:
     CT_TARGET_ARCH="${CT_ARCH}${target_endian_eb}"
 
+    # gcc ./configure flags
+    [ "${CT_ARCH_FLOAT_SOFTFP}" ] && { CT_ARCH_FLOAT_CFLAG="-mfloat-abi=softfp"; CT_ARCH_WITH_FLOAT="--with-float=softfp"; }
+
     # The system part of the tuple:
     case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in
         *glibc,y)   CT_TARGET_SYS=gnueabi;;
diff -Naur crosstool-ng-1.8.2.orig/scripts/build/libc/eglibc.sh crosstool-ng-1.8.2/scripts/build/libc/eglibc.sh
--- crosstool-ng-1.8.2.orig/scripts/build/libc/eglibc.sh	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/scripts/build/libc/eglibc.sh	2010-10-19 14:30:12.000000000 +0200
@@ -287,9 +287,10 @@
         *) extra_config+=("--disable-shared");;
     esac
 
-    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
-        y,) extra_config+=("--with-fp");;
-        ,y) extra_config+=("--without-fp");;
+    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW},${CT_ARCH_FLOAT_SOFTFP}" in
+        y,,) extra_config+=("--with-fp");;
+        ,y,) extra_config+=("--without-fp");;
+        ,,y) extra_config+=("--without-fp");;
     esac
 
     case "$(do_libc_add_ons_list ,)" in
diff -Naur crosstool-ng-1.8.2.orig/scripts/build/libc/glibc.sh crosstool-ng-1.8.2/scripts/build/libc/glibc.sh
--- crosstool-ng-1.8.2.orig/scripts/build/libc/glibc.sh	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/scripts/build/libc/glibc.sh	2010-10-19 14:30:12.000000000 +0200
@@ -255,9 +255,10 @@
         y) extra_config+=("--enable-shared");;
         *) extra_config+=("--disable-shared");;
     esac
-    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
-        y,) extra_config+=("--with-fp");;
-        ,y) extra_config+=("--without-fp");;
+    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW},${CT_ARCH_FLOAT_SOFTFP}" in
+        y,,) extra_config+=("--with-fp");;
+        ,y,) extra_config+=("--without-fp");;
+        ,,y) extra_config+=("--without-fp");;
     esac
     # Obviously, we want threads, as we come here only for NPTL
     extra_config+=("--with-__thread")
@@ -364,9 +365,10 @@
         *) extra_config+=("--disable-shared");;
     esac
 
-    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
-        y,) extra_config+=("--with-fp");;
-        ,y) extra_config+=("--without-fp");;
+    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW},${CT_ARCH_FLOAT_SOFTFP}" in
+        y,,) extra_config+=("--with-fp");;
+        ,y,) extra_config+=("--without-fp");;
+        ,,y) extra_config+=("--without-fp");;
     esac
 
     case "$(do_libc_add_ons_list ,)" in
diff -Naur crosstool-ng-1.8.2.orig/scripts/build/libc/uClibc.sh crosstool-ng-1.8.2/scripts/build/libc/uClibc.sh
--- crosstool-ng-1.8.2.orig/scripts/build/libc/uClibc.sh	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/scripts/build/libc/uClibc.sh	2010-10-19 14:30:12.000000000 +0200
@@ -318,13 +318,18 @@
 
     # Accomodate for old and new uClibc version, where the
     # way to select between hard/soft float has changed
-    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
-        y,) cat <<-ENDSED
+    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW},${CT_ARCH_FLOAT_SOFTFP}" in
+        y,,) cat <<-ENDSED
 				s/^[^_]*(HAS_FPU).*/\\1=y/
 				s/.*(UCLIBC_HAS_FPU).*/\\1=y/
 				ENDSED
             ;;
-        ,y) cat <<-ENDSED
+        ,y,) cat <<-ENDSED
+				s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
+				s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
+				ENDSED
+            ;;
+        ,,y) cat <<-ENDSED
 				s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
 				s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
 				ENDSED
diff -Naur crosstool-ng-1.8.2.orig/scripts/showSamples.sh crosstool-ng-1.8.2/scripts/showSamples.sh
--- crosstool-ng-1.8.2.orig/scripts/showSamples.sh	2010-10-04 00:26:27.000000000 +0200
+++ crosstool-ng-1.8.2/scripts/showSamples.sh	2010-10-19 14:30:12.000000000 +0200
@@ -126,7 +126,7 @@
             printf "  ${CT_LIBC_VERSION}  "
         fi
         printf "|  ${CT_THREADS:-none}  "
-        printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
+        printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft}${CT_ARCH_FLOAT_SOFTFP:+softfp} float  "
         printf "|  C"
         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]