[PATCH] config.sub: Accept LLVM-style $cpu-$vendor-windows-cygnus

2023-08-16 Thread John Ericson
In 91f6a7f616b161c25ba2001861a40e662e18c4ad I supported `windows-gnu`
and `windows-msvc`, but I forgot about the last one: `windows-cygnus`.

This LLVM commit [1] introduced all 3. (I wish I had found it before!)
But at least we can use it to ensure I am not missing one now.

This came up in this Nixpkgs PR [2] where I was told my previous patch
only partially solved the problem, because I forgot about this case.

[1]: 
https://github.com/llvm/llvm-project/commit/edbdd2e5df8b59dac8ae5f45059407f8a79850d6

[2]: https://github.com/NixOS/nixpkgs/pull/249090
---
 config.sub| 6 +++---
 testsuite/config-sub.data | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/config.sub b/config.sub
index 6ae2502..bea4f3a 100755
--- a/config.sub
+++ b/config.sub
@@ -1744,7 +1744,7 @@ case $os in
;;
none)
;;
-   kernel* | msvc* )
+   kernel* | msvc* | cygnus* )
# Restricted further below
;;
*)
@@ -1763,7 +1763,7 @@ case $kernel-$os in
;;
managarm-mlibc* | managarm-kernel* )
;;
-   windows*-gnu* | windows*-msvc*)
+   windows*-gnu* | windows*-msvc* | windows*-cygnus* )
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
# These are just libc implementations, not actual OSes, and thus
@@ -1779,7 +1779,7 @@ case $kernel-$os in
echo "Invalid configuration '$1': '$kernel' does not support 
'$os'." 1>&2
exit 1
;;
-   *-msvc* )
+   *-msvc* | *-cygnus* )
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
exit 1
;;
diff --git a/testsuite/config-sub.data b/testsuite/config-sub.data
index ba934b6..3752f0d 100644
--- a/testsuite/config-sub.data
+++ b/testsuite/config-sub.data
@@ -887,6 +887,7 @@ x86_64-twizzler 
x86_64-pc-twizzler
 x86_64-unknown-ptx x86_64-sequent-ptx
 x86_64-windows x86_64-pc-windows
 x86_64-windows-gnu x86_64-pc-windows-gnu
+x86_64-windows-cygnus  x86_64-pc-windows-cygnus
 x86_64-windows-msvcx86_64-pc-windows-msvc
 x86_64-wrs-vxworks x86_64-wrs-vxworks
 x86_64-wrs-vxworks-simlinuxx86_64-wrs-vxworks-simlinux
-- 
2.40.1




[PATCH] config.sub: add javascript-unknown-ghcjs

2023-08-16 Thread Adam Joseph
GHC has been using a custom triple "javascript-unknown-ghcjs" for their (non
asm.js, non wasm) javascript-emitting kernel-less target.

  
https://gitlab.haskell.org/ghc/ghc/-/commit/6636b670233522f01d002c9b97827d00289dbf5c

This triple is a bit of an oddball, so the support for it is highly restricted
in order to discourage further proliferation of the javascript "cpu" or ghcjs
"operating system", which are valid only in combination with each other.

In the (quite large) corpus of software packaged for nixpkgs we've needed to
allow non-config.sub-accepted triples in only three situations [1]; this is one
of them.  We'd like to upstream this case to GNU config since GHC has already
shipped compilers that use it and they don't appear to be having any second
thoughts about it.

[1] https://github.com/NixOS/nixpkgs/pull/235230#discussion_r1295333268






[PATCH] config.sub: add javascript-unknown-ghcjs

2023-08-16 Thread Adam Joseph
GHC has been using a custom triple "javascript-unknown-ghcjs" for
their (non asm.js, non wasm) javascript-emitting kernel-less target.

  
https://gitlab.haskell.org/ghc/ghc/-/commit/6636b670233522f01d002c9b97827d00289dbf5c

This triple is a bit of an oddball, so the support for it is highly
restricted in order to discourage further proliferation of the
javascript "cpu" or ghcjs "operating system", which are valid only
in combination with each other.
---
 config.sub| 19 +++
 testsuite/config-sub.data |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/config.sub b/config.sub
index 6ae2502..0eee4b6 100755
--- a/config.sub
+++ b/config.sub
@@ -1200,6 +1200,7 @@ case $cpu-$vendor in
| d10v | d30v | dlx | dsp16xx \
| e2k | elxsi | epiphany \
| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+   | javascript \
| h8300 | h8500 \
| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
@@ -1702,6 +1703,9 @@ case $os in
# VxWorks passes extra cpu info in the 4th filed.
simlinux | simwindows | spe)
;;
+   # See `case $cpu-$os` validation below
+   ghcjs)
+   ;;
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
@@ -1884,6 +1888,21 @@ case $vendor in
;;
 esac
 
+# Here we handle the constraint that a (synthetic) cpu and os are
+# valid only in combination with each other and nowhere else.
+case $cpu-$os in
+   # The "javascript-unknown-ghcjs" triple is used by GHC; we
+   # accept it here in order to tolerate that, but reject any
+   # variations.
+   javascript-ghcjs)
+   ;;
+   javascript-* | *-ghcjs)
+   echo "Invalid configuration '$1': cpu '$cpu' is not valid with 
os '$os'" 1>&2
+   exit 1
+   ;;
+esac
+
+
 echo "$cpu-$vendor-${kernel:+$kernel-}$os"
 exit
 
diff --git a/testsuite/config-sub.data b/testsuite/config-sub.data
index ba934b6..6fd722c 100644
--- a/testsuite/config-sub.data
+++ b/testsuite/config-sub.data
@@ -341,6 +341,8 @@ isi68   
m68k-isi-sysv
 j90j90-cray-unicos
 j90-cray   j90-cray-unicos
 j90-unicos j90-cray-unicos
+javascript-ghcjs   javascript-unknown-ghcjs
+javascript-unknown-ghcjs   javascript-unknown-ghcjs
 k1om   k1om-unknown-none
 k1om-linux k1om-unknown-linux-gnu
 kvx-coskvx-unknown-cos
-- 
2.41.0