[PATCH] Add more ARM variants

2018-04-23 Thread John Ericson

 - arm6m: Add support for this mobile arch variant backport to ARM 6.
 - arm7[arm]: Already existed, but test more
 - arm8[arm]: Add support and likewise test.
---
 config.sub| 2 +-
 testsuite/config-sub.data | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/config.sub b/config.sub
index 657a862..94760ad 100755
--- a/config.sub
+++ b/config.sub
@@ -249,7 +249,7 @@ case $basic_machine in
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | 
alpha64pca5[67] \
| am33_2.0 \
| arc | arceb \
-   | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+   | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | 
armv[78][arm] \
| avr | avr32 \
| ba \
| be32 | be64 \
diff --git a/testsuite/config-sub.data b/testsuite/config-sub.data
index 474dce8..f609e18 100644
--- a/testsuite/config-sub.data
+++ b/testsuite/config-sub.data
@@ -61,6 +61,7 @@ arm-unknown-netbsdelf7.0  
arm-unknown-netbsdelf7.0
 arm-unknown-riscos arm-unknown-riscos
 armv2  armv2-unknown-none
 armv3l armv3l-unknown-none
+armv6m armv6m-unknown-none
 armv6-cloudabi-eabihf  armv6-unknown-cloudabi-eabihf
 armv6eb-unknown-netbsdelf7.0   armv6eb-unknown-netbsdelf7.0
 armv6eb-unknown-netbsdelf7.0-eabi  
armv6eb-unknown-netbsdelf7.0-eabi
@@ -70,6 +71,8 @@ armv6-unknown-netbsdelf7.0
armv6-unknown-netbsdelf7.0
 armv6-unknown-netbsdelf7.0-eabi
armv6-unknown-netbsdelf7.0-eabi
 armv6-unknown-netbsdelf7.0-eabihf  
armv6-unknown-netbsdelf7.0-eabihf
 armv7a armv7a-unknown-none
+armv7r armv7r-unknown-none
+armv7m armv7m-unknown-none
 armv7a-linux-gnueabi   armv7a-unknown-linux-gnueabi
 armv7-apple-iosarmv7-apple-ios
 armv7eb-unknown-netbsdelf7.0   armv7eb-unknown-netbsdelf7.0
@@ -79,6 +82,9 @@ armv7-unknown-netbsdelf7.0
armv7-unknown-netbsdelf7.0
 armv7-unknown-netbsdelf7.0-eabi
armv7-unknown-netbsdelf7.0-eabi
 armv7-unknown-netbsdelf7.0-eabihf  
armv7-unknown-netbsdelf7.0-eabihf
 armv8b-linux-gnueabi   armv8b-unknown-linux-gnueabi
+armv8a armv8a-unknown-none
+armv8r armv8r-unknown-none
+armv8m armv8m-unknown-none
 aros   i386-pc-aros
 asmjs  asmjs-unknown-none
 avr32  avr32-unknown-none
--
2.16.2


___
config-patches mailing list
config-patches@gnu.org
https://lists.gnu.org/mailman/listinfo/config-patches


4-component parsing, and arm*-*-none-eabi in particular

2018-04-23 Thread John Ericson

Hello,

I've long noticed that configs like `armv7m-unknown-none-eabi`, though 
supported by LLVM, are not supported by gnu-config. [LLVM would treat 
"none" as the kernel, and "eabi" as the OS/ABI.] I recently found the 
time to go investigate why, and this is what I found and patched.


The problem is the way 4-component configs (i.e. 3 dashes) are parsed. 
Commit b7ab42761455e051a57876252740cb398aa952eb is the source of this 
support, which works by special-casing certain KERNEL-OPERATING_SYSTEM 
pairs, to disambiguate between CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 
and CPU_TYPE-KERNEL-OPERATING_SYSTEM.


This is fine for 3-component triples, but is overkill in the 4-component 
case where the config is always unambiguously 
CPU_TYPE-KERNEL-OPERATING_SYSTEM. Additionally, the original `if [ 
$basic_machine != $1 ]` check to disambiguate between 1- and 2-component 
configs is a bit obtuse.


I rewrote the whole chunk of code in what I hope you all agree is a more 
readable manner, using sed only to pull out the (up to 4) components and 
then doing everything else with simple pure bash. Finally, I whitelisted 
and tested `arm*-*-none-eabi`, which I hope a conservative starting point.


Hopefully this all makes sense, and the commit messages add additional 
clarity.


Thanks,

John

From 2b71b72b78fa9097c2fd2a8b45ad6d6555e2ca56 Mon Sep 17 00:00:00 2001
From: John Ericson 
Date: Sat, 21 Apr 2018 22:01:26 -0400
Subject: [PATCH 1/3] Rewrite basic_machine `if` with `case`

This hopefully makes the condition more readable
---
 config.sub | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/config.sub b/config.sub
index 657a862..721d1dc 100755
--- a/config.sub
+++ b/config.sub
@@ -128,9 +128,14 @@ case $maybe_os in
 ;;
   *)
 basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
-if [ "$basic_machine" != "$1" ]
-then os=`echo "$1" | sed 's/.*-/-/'`
-else os=; fi
+case $1 in
+  *-*)
+os=`echo "$1" | sed 's/.*-/-/'`
+;;
+  *)
+os=
+;;
+esac
 ;;
 esac
 
-- 
2.16.2

From 1a9d4e86538b2c8dbd8ad11c4333f0db64febd50 Mon Sep 17 00:00:00 2001
From: John Ericson 
Date: Sat, 21 Apr 2018 22:58:24 -0400
Subject: [PATCH 2/3] Rewrite logic handling n `-`-separated components

The old logic was a bit hard to follow due to lots of sed and
unintuitive collapsing of cases. The code now works like this

 - 4 components is always parsed as
   CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM

 - 2 components is always parsed as
   CPU_TYPE-OPERATING_SYSTEM

 - 1 component is always parsed as
   CPU_TYPE

 - 3 components is ambiguous and parsed as either
   CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
   CPU_TYPE-KERNEL-OPERATING_SYSTEM

The old code differed semantically in that

 - The 4-case was awkwardly folded into the 3-case disambiguation

 - The "android-linux" ad-hoc fixdup did something different in the
   non-3 cases, but isn't intended to apply in those cases.
---
 config.sub | 60 ++--
 1 file changed, 38 insertions(+), 22 deletions(-)

diff --git a/config.sub b/config.sub
index 721d1dc..24ffe7c 100755
--- a/config.sub
+++ b/config.sub
@@ -110,33 +110,49 @@ case $# in
 exit 1;;
 esac
 
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | 
kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | cloudabi*-eabi* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-os=-$maybe_os
-basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-;;
-  android-linux)
-os=-linux-android
-basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+c1=`echo "$1" | sed 's/^\([^-]*\).*$/\1/'`
+c2=`echo "$1" | sed 's/^[^-]*-\([^-]*\).*$/\1/'`
+c3=`echo "$1" | sed 's/^[^-]*-[^-]*-\([^-]*\).*$/\1/'`
+c4=`echo "$1" | sed 's/^[^-]*-[^-]*-[^-]*-\([^-]*\).*$/\1/'`
+
+# Fix android-linux to be linux-android KERNEL-OS with unknown COMPANY
+if [ "$c2-$c3" = "android-linux" ]; then
+  c2=unknown
+  c3=linux
+  c4=android
+  set $c1-$c2-$c3-$c4
+fi
+
+case $1 in
+  *-*-*-*)
+basic_machine=$c1-$c2
+os=-$c3-$c4
 ;;
-  *)
-basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
-case $1 in
-  *-*)
-os=`echo "$1" | sed 's/.*-/-/'`
+  *-*-*)
+# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two 
parts
+maybe_os=$c2-$c3
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* 
| \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | 
kfreebsd*-gnu* | \
+