Repository: spack/spack

Issue:
Installation issue: pytorch 1.13 (hunks failed error)
### Steps to reproduce the issue

```console
==> Concretized py-torch%clang@10.0.1+caffe2+cuda cuda_arch=70
 -   v6yjyzu  py-torch@1.13.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +caffe2+cuda+cudnn~debug+distributed+fbgemm+gloo+kineto~magma~metal~mkldnn+mpi~nccl+nnpack+numa+numpy+onnx_ml+openmp+qnnpack~rocm+tensorpipe~test+valgrind+xnnpack build_system=python_pip cuda_arch=70 patches=2fac519 arch=linux-rhel7-power9le
[+]  zqhjhif      ^cmake@3.21.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-rhel7-power9le
[+]  ohy62xg      ^cuda@11.8.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~allow-unsupported-compilers~dev build_system=generic arch=linux-rhel7-power9le
[+]  n6q5a4b      ^cudnn@8.4.0.27-11.6%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  ivnpmy6      ^eigen@3.4.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-rhel7-power9le
[+]  cgt57bn      ^fxdiv@2020-04-17%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-rhel7-power9le
[+]  4kbctbv      ^ninja@1.9.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  mvrcpzr      ^numactl@2.0.14%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools patches=4e1d78c,62fc8a8,ff37630 arch=linux-rhel7-power9le
[+]  g3waqkd          ^autoconf@2.69%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools patches=7793209 arch=linux-rhel7-power9le
[+]  4ctomtb          ^automake@1.13.4%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  fyjwelv          ^gnuconfig@2021-08-14%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  i2mob5z          ^libtool@2.4.7%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  yrjn2hu          ^m4@1.4.16%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +sigsegv build_system=autotools arch=linux-rhel7-power9le
[+]  uiglknb      ^openblas@0.3.21%gcc@8.3.1~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile patches=d3d9b15 symbol_suffix=none threads=none arch=linux-rhel7-power9le
[+]  q3bkmui          ^perl@5.16.3%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +cpanm+shared+threads build_system=generic patches=0eac10e,3bbd7d6 arch=linux-rhel7-power9le
[+]  aihael3      ^protobuf@3.21.7%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo+shared build_system=cmake build_type=Release arch=linux-rhel7-power9le
[+]  wn4qh4f          ^zlib@1.2.7%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +optimize+pic+shared build_system=makefile arch=linux-rhel7-power9le
[+]  p4pkx3m      ^psimd@2020-05-17%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-rhel7-power9le
[+]  v5eemzh      ^pthreadpool@2021-04-13%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-rhel7-power9le
[+]  a5ymndy      ^py-astunparse@1.6.3%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  fu32txi      ^py-cffi@1.15.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  l45qtjx          ^libffi@3.4.2%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  i3uzcn3          ^pkgconf@1.8.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  lav5umi          ^py-pycparser@2.21%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  vmi7ju7      ^py-future@0.18.2%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  crk3dp7      ^py-numpy@1.21.3%clang@14.0.5 cflags="-Wno-unused-command-line-argument --gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1" cxxflags="-Wno-unused-command-line-argument --gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1" +blas+lapack build_system=python_pip patches=802970a,873745d arch=linux-rhel7-power9le
[+]  taue7mv          ^py-cython@0.29.32%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  pdjnndt      ^py-pip@22.2.2%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  6qgkuhm      ^py-protobuf@3.20.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~cpp build_system=python_pip arch=linux-rhel7-power9le
[+]  mj47ep4      ^py-pybind11@2.10.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~ipo build_system=cmake build_type=RelWithDebInfo arch=linux-rhel7-power9le
[+]  ydw7zqo      ^py-pyyaml@6.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +libyaml build_system=python_pip arch=linux-rhel7-power9le
[+]  fi6ql4f          ^libyaml@0.2.5%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  lybx2uy      ^py-requests@2.28.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~socks build_system=python_pip arch=linux-rhel7-power9le
[+]  rmjruhf          ^py-certifi@2022.9.14%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  sxguwvh          ^py-charset-normalizer@2.0.12%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  3xbq5xw          ^py-idna@3.4%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  xnn3ler          ^py-urllib3@1.26.12%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~brotli~secure~socks build_system=python_pip arch=linux-rhel7-power9le
[+]  h3uzvg3      ^py-setuptools@59.4.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  kxxndql      ^py-six@1.16.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  tqktodp      ^py-tqdm@4.64.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~notebook~telegram build_system=python_pip arch=linux-rhel7-power9le
[+]  hno7nix          ^py-setuptools-scm@7.0.5%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +toml build_system=python_pip arch=linux-rhel7-power9le
[+]  dsslu4d              ^py-packaging@21.3%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  yn4kx5g                  ^py-pyparsing@3.0.9%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  gvhvum6              ^py-tomli@2.0.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  rxezh7h      ^py-typing-extensions@4.3.0%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  36najof          ^py-flit-core@3.7.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=python_pip arch=linux-rhel7-power9le
[+]  5t543th      ^py-wheel@0.37.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=generic arch=linux-rhel7-power9le
[+]  xcx3agw      ^python@3.8.3%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib build_system=generic patches=0d98e93,4c24573,f2fd060 arch=linux-rhel7-power9le
[+]  hz7n24t          ^bzip2@1.0.6%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~debug~pic+shared build_system=generic arch=linux-rhel7-power9le
[+]  hyoxtgt          ^expat@2.4.8%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +libbsd build_system=autotools arch=linux-rhel7-power9le
[+]  3hps6sb              ^libbsd@0.11.5%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  t2h4qdp                  ^libmd@1.0.4%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  2jmqqz3          ^gdbm@1.23%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  tymkwyw          ^gettext@0.21.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-rhel7-power9le
[+]  kbumwpb              ^libiconv@1.16%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools libs=shared,static arch=linux-rhel7-power9le
[+]  ykm3sxt              ^libxml2@2.10.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~python build_system=autotools arch=linux-rhel7-power9le
[+]  qruqdlh              ^tar@1.26%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools patches=08921fc,5c314db,d428578 zip=pigz arch=linux-rhel7-power9le
[+]  h62wgc2          ^ncurses@5.9.20130511%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~symlinks+termlib abi=5 build_system=autotools patches=f84b270 arch=linux-rhel7-power9le
[+]  obnnh3v          ^openssl@1.0.2k-fips%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~docs~shared build_system=generic certs=mozilla arch=linux-rhel7-power9le
[+]  sni5oyj          ^readline@8.1.2%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  hckomnf          ^sqlite@3.39.4%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +column_metadata~dynamic_extensions+fts+rtree build_system=autotools arch=linux-rhel7-power9le
[+]  7zokxvd          ^util-linux-uuid@2.38.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=autotools arch=linux-rhel7-power9le
[+]  zjoybpz          ^xz@5.2.2%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" ~pic build_system=autotools libs=shared,static arch=linux-rhel7-power9le
[+]  yuc6fvx      ^spectrum-mpi@rolling-release%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument"  build_system=bundle arch=linux-rhel7-ppc64le
[+]  yjzlzaz      ^valgrind@3.16.1%clang@10.0.1 cflags="-Wno-unused-command-line-argument" cxxflags="-Wno-unused-command-line-argument" +boost+mpi+only64bit~ubsan build_system=autotools libs=shared,static arch=linux-rhel7-power9le
```


### Error message

<details><summary>Error message</summary><pre>
==> Installing py-torch-1.13.0-v6yjyzuckwwfmarvivcbcfnm6wzznaps
==> No binary for py-torch-1.13.0-v6yjyzuckwwfmarvivcbcfnm6wzznaps found: installing from source
==> Using cached archive: /p/gpfs1/brodsky3/nexo/spack/var/spack/cache/_source-cache/git//pytorch/pytorch.git/v1.13.0.tar.gz
==> Warning: Fetching from mirror without a checksum!
  This package is normally checked out from a version control system, but it has been archived on a spack mirror.  This means we cannot know a checksum for the tarball in advance. Be sure that your connection to this mirror is secure!
==> Using cached archive: /p/gpfs1/brodsky3/nexo/spack/var/spack/cache/_source-cache/archive/2f/2fac519cca8997f074c263505657ff867e7ba2d6637fc8bda99c70a99be0442a
1 out of 6 hunks FAILED -- saving rejects to file torch/utils/cpp_extension.py.rej
==> Patch https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.12/recipe/0302-cpp-extension.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/usr/bin/patch' '-s' '-p' '1' '-i' '/var/tmp/brodsky3/spack-stage/spack-stage-_yswbp0s/0302-cpp-extension.patch' '-d' '.
</pre></details>
(same error reproduces if the source cache is removed and the source is downloaded fresh)

### Information on your system

* **Spack:** 0.19.0 (a86911246a8c5571ca210ff25fc990b8eb297a5c)
* **Python:** 3.8.2
* **Platform:** linux-rhel7-power9le
* **Concretizer:** clingo

### Additional information

@adamjstewart 

build log and env files are not generated, looks like spack stops before that happens.

### 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:
This should be easy to reproduce and fix, just need to update the patch files. I don't have access to PowerPC but this bug can be reproduced with `spack patch py-torch` for anyone who does. If you comment out the arch specifier, should be able to reproduce and test on x86_64 too.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-torch/package.py b/var/spack/repos/builtin/packages/py-torch/package.py
--- a/var/spack/repos/builtin/packages/py-torch/package.py
+++ b/var/spack/repos/builtin/packages/py-torch/package.py
@@ -293,35 +293,42 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
     )
 
     # Use patches from IBM's Open CE to enable building on Power systems
-    # 03xx - patch temporary to fix a problem that when fixed upstream can be removed
+    # 01xx patches are specific to open-ce, we only include 03xx patches used in meta.yaml
+    # https://github.com/open-ce/pytorch-feedstock
     patch(
-        "https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.10/recipe/0302-cpp-extension.patch",
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.10/recipe/0302-cpp-extension.patch",
         sha256="ecb3973fa7d0f4c8f8ae40433f3ca5622d730a7b16f6cb63325d1e95baff8aa2",
         when="@1.10:1.11 arch=ppc64le:",
     )
-
     patch(
-        "https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.10/recipe/0311-PR66085-Remove-unused-dump-method-from-VSX-vec256-methods.patch",
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.10/recipe/0311-PR66085-Remove-unused-dump-method-from-VSX-vec256-methods.patch",
         sha256="f05db59f3def4c4215db7142d81029c73fe330c660492159b66d65ca5001f4d1",
-        when="@1.10:1.11 arch=ppc64le:",
+        when="@1.10 arch=ppc64le:",
     )
-
     patch(
-        "https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.10/recipe/0312-PR67331-Dummpy-VSX-bfloat16-implementation.patch",
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.10/recipe/0312-PR67331-Dummpy-VSX-bfloat16-implementation.patch",
         sha256="860b64afa85f5e6647ebc3c91d5a0bb258784770900c9302c3599c98d5cff1ee",
-        when="@1.10:1.11 arch=ppc64le:",
+        when="@1.10 arch=ppc64le:",
     )
-
     patch(
-        "https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.10/recipe/0313-add-missing-vsx-dispatch.patch",
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.10/recipe/0313-add-missing-vsx-dispatch.patch",
         sha256="7393c2bc0b6d41ecc813c829a1e517bee864686652e91f174cb7bcdfb10ba451",
-        when="@1.10:1.11 arch=ppc64le:",
+        when="@1.10 arch=ppc64le:",
+    )
+    patch(
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.10/recipe/0314-fix-nullpointer-error.patch",
+        sha256="b9cff8966f316f58514c66a403b7a6786be3cdb252f1380a6b91c722686a4097",
+        when="@1.10 arch=ppc64le:",
     )
-
     patch(
-        "https://github.com/open-ce/pytorch-feedstock/raw/0a145060ca8523314ec3893af935c3b140e2d0b0/pytorch-1.12/recipe/0302-cpp-extension.patch",
+        "https://github.com/open-ce/pytorch-feedstock/raw/open-ce-v1.7.4/pytorch-1.12/recipe/0302-cpp-extension.patch",
         sha256="2fac519cca8997f074c263505657ff867e7ba2d6637fc8bda99c70a99be0442a",
-        when="@1.12: arch=ppc64le:",
+        when="@1.12 arch=ppc64le:",
+    )
+    patch(
+        "https://github.com/open-ce/pytorch-feedstock/raw/main/pytorch-1.13/recipe/0302-cpp-extension.patch",
+        sha256="a54db63640b90e5833cc1099c0935572f5297d2d8625f62f01ac1fda79ed4569",
+        when="@1.13 arch=ppc64le:",
     )
 
     # Cherry-pick a patch to allow earlier versions of PyTorch to work with CUDA 11.4


Test patch: