Repository: spack/spack

Issue:
Installation issue: py-torch +breakpad fails to build on RHEL@9.2
### Steps to reproduce the issue

```console
$ spack install py-torch@1.10%gcc=7.5.0 arch=x86_64
```


### Error message

<details><summary>Error message</summary>

<pre>
  >> 3433    /tmp/sbulut/spack-stage/spack-stage-py-torch-1.10.0-56lrpr454rywkayd2smjuvrtjuvqssa3/spack-src/third_par
             ty/breakpad/src/client/linux/handler/exception_handler.cc:141:65: error: no matching function for call t
             o 'max(int, long int)'
     3434       static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);
     3435                                                                     ^
     3436    In file included from /disk/hpcpm/3vg_spack/0171/opt/spack/linux-rhel9-x86_64/gcc-11.3.1/gcc-7.5.0-ldgnc
             vpwbmnr3kjxaxdzarrvecdyl5ov/include/c++/7.5.0/bits/char_traits.h:39:0,
     3437                     from /disk/hpcpm/3vg_spack/0171/opt/spack/linux-rhel9-x86_64/gcc-11.3.1/gcc-7.5.0-ldgnc
             vpwbmnr3kjxaxdzarrvecdyl5ov/include/c++/7.5.0/string:40,
     3438                     from /tmp/sbulut/spack-stage/spack-stage-py-torch-1.10.0-56lrpr454rywkayd2smjuvrtjuvqss
             a3/spack-src/third_party/breakpad/src/client/linux/handler/exception_handler.h:38,
     3439                     from /tmp/sbulut/spack-stage/spack-stage-py-torch-1.10.0-56lrpr454rywkayd2smjuvrtjuvqss
             a3/spack-src/third_party/breakpad/src/client/linux/handler/exception_handler.cc:66:

</pre></details>


### Information on your system

$ spack debug report
* **Spack:** 0.17.1
* **Python:** 3.9.16
* **Platform:** linux-rhel9-skylake_avx512
* **Concretizer:** clingo


### Additional information

can provide build out later if necessary.

### 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:
my spack env with py-torch was building fine on centos7. It seems `+breakpad` is enabled by default. Not sure, if it's useful for me, so I'll disable it. However, it would be nice to be able build the same spack env without any modifications on RHEL9.2.
The issue was also reported to py-torch:
https://github.com/pytorch/pytorch/issues/70297
a fix was proposed at: https://github.com/pytorch/pytorch/pull/70298
if i understand correctly, breakpad was removed in later versions of py-torch:
https://github.com/pytorch/pytorch/pull/75394
@adamjstewart should breakpad be disabled by default?
I would rather match the defaults used by [CMakeLists.txt](https://github.com/pytorch/pytorch/blob/v1.11.0/CMakeLists.txt#L212) as I also don't know what they're for or whether or not they're important.

Out of curiosity, why do you need PyTorch 1.10? If you use a modern version, this should no longer be an issue. If you really need 1.10, I'll work on patching the submodule.
We're using version 1.10 since that's the latest version that came with spack@0.17.1 Also, If I remember correctly, before we switched to Spack to build our computational environment,  this version enabled a smooth transition from cuda@10 to cuda@11, and hence we continued with it. It's essential that version 1.10 builds since it's used in our production environment, currently running on centos7, and it's useful to replicate this environment in our next distro, RHEL9.2. That being said, we'll probably upgrade spack and a lot packages in our spack env within the next year.

It would be great if you could patch it. Thanks @adamjstewart 

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
@@ -103,7 +103,7 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
         "breakpad",
         default=True,
         description="Enable breakpad crash dump library",
-        when="@1.9:1.11",
+        when="@1.10:1.11",
     )
 
     conflicts("+cuda+rocm")
@@ -286,6 +286,14 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
         when="@1.1:1.8.1",
     )
 
+    # https://github.com/pytorch/pytorch/issues/70297
+    patch(
+        "https://github.com/google/breakpad/commit/605c51ed96ad44b34c457bbca320e74e194c317e.patch?full_index=1",
+        sha256="694d83db3a2147d543357f22ba5c8d5683d0ed43e693d42bca8f24ec50080f98",
+        when="+breakpad",
+        working_dir="third_party/breakpad",
+    )
+
     # Fixes CMake configuration error when XNNPACK is disabled
     # https://github.com/pytorch/pytorch/pull/35607
     # https://github.com/pytorch/pytorch/pull/37865


Test patch: