Repository: spack/spack

Issue:
Installation issue: openssh %oneapi
### Steps to reproduce the issue

```console
(base) ulrich@heisenbug:~$ spack spec -I openssh %oneapi
Input spec
--------------------------------
 -   openssh%oneapi

Concretized
--------------------------------
 -   openssh@9.4p1%oneapi@2022.2.0+gssapi build_system=autotools arch=linux-debian11-zen2
[+]      ^krb5@1.20.1%oneapi@2022.2.0+shared build_system=autotools arch=linux-debian11-zen2
[+]          ^bison@3.3.2%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]              ^m4@1.4.19%gcc@12.2.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-debian11-zen2
[+]                  ^diffutils@3.9%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]                      ^libiconv@1.17%gcc@12.2.0 build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]                  ^libsigsegv@2.14%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]          ^diffutils@3.9%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]              ^libiconv@1.17%oneapi@2022.2.0 build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]          ^findutils@4.9.0%oneapi@2022.2.0 build_system=autotools patches=440b954 arch=linux-debian11-zen2
[+]          ^gettext@0.21.1%oneapi@2022.2.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-debian11-zen2
[+]              ^bzip2@1.0.8%oneapi@2022.2.0~debug~pic+shared build_system=generic arch=linux-debian11-zen2
[+]              ^libxml2@2.10.3%oneapi@2022.2.0+pic~python+shared build_system=autotools arch=linux-debian11-zen2
[+]              ^tar@1.34%oneapi@2022.2.0 build_system=autotools zip=pigz arch=linux-debian11-zen2
[+]                  ^pigz@2.7%oneapi@2022.2.0 build_system=makefile arch=linux-debian11-zen2
[+]                  ^zstd@1.5.5%oneapi@2022.2.0+programs build_system=makefile compression=none libs=shared,static arch=linux-debian11-zen2
[+]              ^xz@5.4.1%oneapi@2022.2.0~pic build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]      ^libedit@3.1-20210216%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]          ^pkgconf@1.9.5%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]      ^libxcrypt@4.4.35%oneapi@2022.2.0~obsolete_api build_system=autotools patches=4885da3 arch=linux-debian11-zen2
[+]          ^perl@5.38.0%oneapi@2022.2.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=linux-debian11-zen2
[+]              ^berkeley-db@18.1.40%oneapi@2022.2.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-debian11-zen2
[+]              ^gdbm@1.23%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]                  ^readline@8.2%oneapi@2022.2.0 build_system=autotools patches=bbf97f1 arch=linux-debian11-zen2
[+]      ^ncurses@6.4%oneapi@2022.2.0~symlinks+termlib abi=none build_system=autotools arch=linux-debian11-zen2
[+]      ^openssl@3.1.3%oneapi@2022.2.0~docs+shared build_system=generic certs=mozilla arch=linux-debian11-zen2
[+]          ^ca-certificates-mozilla@2023-05-30%oneapi@2022.2.0 build_system=generic arch=linux-debian11-zen2
[+]      ^zlib-ng@2.1.3%oneapi@2022.2.0+compat+opt build_system=autotools patches=299b958,ae9077a,b692621 arch=linux-debian11-zen2
```


### Error message

<details><summary>  >> 2106    make: *** [Makefile:447: host-key] Error 139</summary>
(base) ulrich@heisenbug:~$ spack install -j 40 openssh %oneapi
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/bzip2-1.0.8-ehsrho6rozzrajupddgs3gkca6tltavg
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libiconv-1.17-fwzpkionbhetkxfl5s3iitiroq67vnkd
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/xz-5.4.1-dnmydejz3cmtnjeojzxmzjc6p6cexty5
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/zlib-ng-2.1.3-7sdprul3y56pwtz35nca2bj4tzstsarf
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/ncurses-6.4-vcsqwgm26mqsxncsvs7ffmq6mvwsfchq
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/zstd-1.5.5-nt3obr5aqop7xovc25nylb32kiyfzztz
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libxcrypt-4.4.35-mefrchx4s4uvk3u5oeazbouhruh5rl7i
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/pigz-2.7-zsunl47wvegna5dmwvhd6u3lrsjgu4ux
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssl-3.1.3-aveo5c3pmfphjzr27dasjplbsgsvf5kz
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libxml2-2.10.3-mg6e4hc22rook5zeaop6yn7awumgfo3m
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libedit-3.1-20210216-ugn7idx2hetdkbbrglb42plafv3pg76a
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/tar-1.34-nkmcfniagvat5lih4rqjstee56yesufq
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/gettext-0.21.1-tryx5lmx6suvojlw4vwj2nwguna5lqe6
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/krb5-1.20.1-pvxusvllhuebhpgvv5alvws4ug5miit7
==> Installing openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg [15/15]
==> No binary for openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg found: installing from source
==> Warning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
==> Using cached archive: /import/exception-dump/ulrich/spack/var/spack/cache/_source-cache/archive/36/3608fd9088db2163ceb3e600c85ab79d0de3d221e59192ea1923e23263866a85.tar.gz
==> Ran patch() for openssh
==> openssh: Executing phase: 'autoreconf'
==> openssh: Executing phase: 'configure'
==> openssh: Executing phase: 'build'
==> openssh: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j1' 'install'

1 error found in build log:
     2100    /usr/bin/install -c -m 644 sftp-server.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man8/
             sftp-server.8
     2101    /usr/bin/install -c -m 644 ssh-keysign.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man8/
             ssh-keysign.8
     2102    /usr/bin/install -c -m 644 ssh-pkcs11-helper.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man
             /man8/ssh-pkcs11-helper.8
     2103    /usr/bin/install -c -m 644 ssh-sk-helper.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man
             8/ssh-sk-helper.8
     2104    /usr/bin/mkdir -p /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/etc
     2105    /usr/bin/bash: line 3: 921663 Segmentation fault      ./ssh-keygen -A
  >> 2106    make: *** [Makefile:447: host-key] Error 139

See build log for details:
  /tmp/ulrich/spack-stage/spack-stage-openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/spack-build-out.txt


</pre></details>


### Information on your system

* **Spack:** 0.21.0.dev0 (931fce2c24a79eec0ec20c388d949ee088a82e28)
* **Python:** 3.9.2
* **Platform:** linux-debian11-zen2
* **Concretizer:** clingo


### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/13248878/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/13248879/spack-build-env.txt)

@bernhardkaindl

A direct fix (inspired by https://github.com/spack/spack/pull/40044) is:
```diff
--- a/var/spack/repos/builtin/packages/openssh/package.py
+++ b/var/spack/repos/builtin/packages/openssh/package.py
@@ -104,7 +104,7 @@ def patch(self):
         filter_file(r"if \(n != 3 && n != 4\)", "if (n < 2)", "configure")
 
         # https://github.com/Homebrew/homebrew-core/blob/7aabdeb30506be9b01708793ae553502c115dfc8/Formula/o/openssh.rb#L71-L77
-        if self.spec.target.family == "x86_64" and self.spec.platform == "darwin":
+        if self.spec.target.family == "x86_64" and self.spec.platform in ["darwin", "linux"]:
             filter_file(r"-fzero-call-used-regs=all", "-fzero-call-used-regs=used", "configure")
 
     def configure_args(self):
```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate
Installation issue: openssh %oneapi
### Steps to reproduce the issue

```console
(base) ulrich@heisenbug:~$ spack spec -I openssh %oneapi
Input spec
--------------------------------
 -   openssh%oneapi

Concretized
--------------------------------
 -   openssh@9.4p1%oneapi@2022.2.0+gssapi build_system=autotools arch=linux-debian11-zen2
[+]      ^krb5@1.20.1%oneapi@2022.2.0+shared build_system=autotools arch=linux-debian11-zen2
[+]          ^bison@3.3.2%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]              ^m4@1.4.19%gcc@12.2.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-debian11-zen2
[+]                  ^diffutils@3.9%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]                      ^libiconv@1.17%gcc@12.2.0 build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]                  ^libsigsegv@2.14%gcc@12.2.0 build_system=autotools arch=linux-debian11-zen2
[+]          ^diffutils@3.9%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]              ^libiconv@1.17%oneapi@2022.2.0 build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]          ^findutils@4.9.0%oneapi@2022.2.0 build_system=autotools patches=440b954 arch=linux-debian11-zen2
[+]          ^gettext@0.21.1%oneapi@2022.2.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-debian11-zen2
[+]              ^bzip2@1.0.8%oneapi@2022.2.0~debug~pic+shared build_system=generic arch=linux-debian11-zen2
[+]              ^libxml2@2.10.3%oneapi@2022.2.0+pic~python+shared build_system=autotools arch=linux-debian11-zen2
[+]              ^tar@1.34%oneapi@2022.2.0 build_system=autotools zip=pigz arch=linux-debian11-zen2
[+]                  ^pigz@2.7%oneapi@2022.2.0 build_system=makefile arch=linux-debian11-zen2
[+]                  ^zstd@1.5.5%oneapi@2022.2.0+programs build_system=makefile compression=none libs=shared,static arch=linux-debian11-zen2
[+]              ^xz@5.4.1%oneapi@2022.2.0~pic build_system=autotools libs=shared,static arch=linux-debian11-zen2
[+]      ^libedit@3.1-20210216%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]          ^pkgconf@1.9.5%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]      ^libxcrypt@4.4.35%oneapi@2022.2.0~obsolete_api build_system=autotools patches=4885da3 arch=linux-debian11-zen2
[+]          ^perl@5.38.0%oneapi@2022.2.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=linux-debian11-zen2
[+]              ^berkeley-db@18.1.40%oneapi@2022.2.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-debian11-zen2
[+]              ^gdbm@1.23%oneapi@2022.2.0 build_system=autotools arch=linux-debian11-zen2
[+]                  ^readline@8.2%oneapi@2022.2.0 build_system=autotools patches=bbf97f1 arch=linux-debian11-zen2
[+]      ^ncurses@6.4%oneapi@2022.2.0~symlinks+termlib abi=none build_system=autotools arch=linux-debian11-zen2
[+]      ^openssl@3.1.3%oneapi@2022.2.0~docs+shared build_system=generic certs=mozilla arch=linux-debian11-zen2
[+]          ^ca-certificates-mozilla@2023-05-30%oneapi@2022.2.0 build_system=generic arch=linux-debian11-zen2
[+]      ^zlib-ng@2.1.3%oneapi@2022.2.0+compat+opt build_system=autotools patches=299b958,ae9077a,b692621 arch=linux-debian11-zen2
```


### Error message

<details><summary>  >> 2106    make: *** [Makefile:447: host-key] Error 139</summary>
(base) ulrich@heisenbug:~$ spack install -j 40 openssh %oneapi
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/bzip2-1.0.8-ehsrho6rozzrajupddgs3gkca6tltavg
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libiconv-1.17-fwzpkionbhetkxfl5s3iitiroq67vnkd
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/xz-5.4.1-dnmydejz3cmtnjeojzxmzjc6p6cexty5
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/zlib-ng-2.1.3-7sdprul3y56pwtz35nca2bj4tzstsarf
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/ncurses-6.4-vcsqwgm26mqsxncsvs7ffmq6mvwsfchq
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/zstd-1.5.5-nt3obr5aqop7xovc25nylb32kiyfzztz
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libxcrypt-4.4.35-mefrchx4s4uvk3u5oeazbouhruh5rl7i
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/pigz-2.7-zsunl47wvegna5dmwvhd6u3lrsjgu4ux
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssl-3.1.3-aveo5c3pmfphjzr27dasjplbsgsvf5kz
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libxml2-2.10.3-mg6e4hc22rook5zeaop6yn7awumgfo3m
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/libedit-3.1-20210216-ugn7idx2hetdkbbrglb42plafv3pg76a
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/tar-1.34-nkmcfniagvat5lih4rqjstee56yesufq
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/gettext-0.21.1-tryx5lmx6suvojlw4vwj2nwguna5lqe6
[+] /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/krb5-1.20.1-pvxusvllhuebhpgvv5alvws4ug5miit7
==> Installing openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg [15/15]
==> No binary for openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg found: installing from source
==> Warning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
==> Using cached archive: /import/exception-dump/ulrich/spack/var/spack/cache/_source-cache/archive/36/3608fd9088db2163ceb3e600c85ab79d0de3d221e59192ea1923e23263866a85.tar.gz
==> Ran patch() for openssh
==> openssh: Executing phase: 'autoreconf'
==> openssh: Executing phase: 'configure'
==> openssh: Executing phase: 'build'
==> openssh: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j1' 'install'

1 error found in build log:
     2100    /usr/bin/install -c -m 644 sftp-server.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man8/
             sftp-server.8
     2101    /usr/bin/install -c -m 644 ssh-keysign.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man8/
             ssh-keysign.8
     2102    /usr/bin/install -c -m 644 ssh-pkcs11-helper.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man
             /man8/ssh-pkcs11-helper.8
     2103    /usr/bin/install -c -m 644 ssh-sk-helper.8.out /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/share/man/man
             8/ssh-sk-helper.8
     2104    /usr/bin/mkdir -p /import/exception-dump/ulrich/myLibs/spack-packages/linux-debian11-zen2/oneapi-2022.2.0/openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/etc
     2105    /usr/bin/bash: line 3: 921663 Segmentation fault      ./ssh-keygen -A
  >> 2106    make: *** [Makefile:447: host-key] Error 139

See build log for details:
  /tmp/ulrich/spack-stage/spack-stage-openssh-9.4p1-l6rl4vepw5voy7klcqfepwkhhyax6ubg/spack-build-out.txt


</pre></details>


### Information on your system

* **Spack:** 0.21.0.dev0 (931fce2c24a79eec0ec20c388d949ee088a82e28)
* **Python:** 3.9.2
* **Platform:** linux-debian11-zen2
* **Concretizer:** clingo


### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/13248878/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/13248879/spack-build-env.txt)

@bernhardkaindl

A direct fix (inspired by https://github.com/spack/spack/pull/40044) is:
```diff
--- a/var/spack/repos/builtin/packages/openssh/package.py
+++ b/var/spack/repos/builtin/packages/openssh/package.py
@@ -104,7 +104,7 @@ def patch(self):
         filter_file(r"if \(n != 3 && n != 4\)", "if (n < 2)", "configure")
 
         # https://github.com/Homebrew/homebrew-core/blob/7aabdeb30506be9b01708793ae553502c115dfc8/Formula/o/openssh.rb#L71-L77
-        if self.spec.target.family == "x86_64" and self.spec.platform == "darwin":
+        if self.spec.target.family == "x86_64" and self.spec.platform in ["darwin", "linux"]:
             filter_file(r"-fzero-call-used-regs=all", "-fzero-call-used-regs=used", "configure")
 
     def configure_args(self):
```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openssh/package.py b/var/spack/repos/builtin/packages/openssh/package.py
--- a/var/spack/repos/builtin/packages/openssh/package.py
+++ b/var/spack/repos/builtin/packages/openssh/package.py
@@ -25,6 +25,8 @@ class Openssh(AutotoolsPackage):
 
     license("SSH-OpenSSH")
 
+    version("9.7p1", sha256="490426f766d82a2763fcacd8d83ea3d70798750c7bd2aff2e57dc5660f773ffd")
+    version("9.6p1", sha256="910211c07255a8c5ad654391b40ee59800710dd8119dd5362de09385aa7a777c")
     version("9.5p1", sha256="f026e7b79ba7fb540f75182af96dc8a8f1db395f922bbc9f6ca603672686086b")
     version("9.4p1", sha256="3608fd9088db2163ceb3e600c85ab79d0de3d221e59192ea1923e23263866a85")
     version("9.3p1", sha256="e9baba7701a76a51f3d85a62c383a3c9dcd97fa900b859bc7db114c1868af8a8")
@@ -106,9 +108,13 @@ def patch(self):
         # #39599: fix configure to parse zlib 1.3's version number to prevent build fail
         filter_file(r"if \(n != 3 && n != 4\)", "if (n < 2)", "configure")
 
-        # https://github.com/Homebrew/homebrew-core/blob/7aabdeb30506be9b01708793ae553502c115dfc8/Formula/o/openssh.rb#L71-L77
-        if self.spec.target.family == "x86_64" and self.spec.platform == "darwin":
-            filter_file(r"-fzero-call-used-regs=all", "-fzero-call-used-regs=used", "configure")
+        # Clang-based compilers (known at least 14-17) may randomly mis-compile
+        # openssh according to this thread even when -fzero-call-used-regs=used:
+        # https://www.mail-archive.com/openssh-bugs@mindrot.org/msg17461.html
+        # Therefore, remove -fzero-call-used-regs=all for these compilers:
+        spec = self.spec
+        if spec.version < Version("9.6p1") and self.compiler.name.endswith(("clang", "oneapi")):
+            filter_file("-fzero-call-used-regs=all", "", "configure")
 
     def configure_args(self):
         # OpenSSH's privilege separation path defaults to /var/empty. At


Test patch: