Repository: spack/spack

Issue:
Installation issue: python
### Steps to reproduce the issue

```
$ spack install intel-oneapi-compilers
$ spack compiler add `spack location -i intel-oneapi-compilers`/compiler/latest/linux/bin
$ spack install python@3.8.10%oneapi
```

### Information on your system

```
$ spack debug report
* **Spack:** 0.16.1-2581-aacba57
* **Python:** 3.5.2
* **Platform:** linux-ubuntu16.04-sandybridge
* **Concretizer:** original
```

No relevant configuration details (reproducible on a clean `spack` clone).

### Additional information

The `install` phase is stuck. `top` shows a few `python` processes running at 100%. Attaching with `gdb` to one of these processes shows that the process is stuck in an infinite loop in `_Py_HashDouble()` around [here](https://github.com/python/cpython/blob/b05955d6f5f149523b5855a335444b7c6324bdb7/Python/pyhash.c#L116) (the `m` variable is equal to `inf` and the `while` loop never ends).

* [spack-build-out.txt](https://github.com/spack/spack/files/6460615/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/6460617/spack-build-env.txt)

@adamjstewart @skosukhin 

I was unsure if I should mention the maintainers of `intel-oneapi-compilers` too.

### 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:
How long did you let it run for? I don't see anything obviously suspicious in the log. Are you able to build Python without Spack?
I let it run for more than 3 hours. I don't think it can escape that while loop if `m=inf`.

Also, if I download Python 3.8.10 from the web, I cannot build it with the OneAPI compiler installed by Spack. I have tried to install the OneAPI compiler on my own but I am having problems.
I found that passing `CFLAGS="-fp-model=strict"` to `configure` fixes the problem. This sounds like another overzealous non-IEEE754 Intel optimization...
Want to submit a PR to add that flag to the Spack package? If not I can get to it sometime next week.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -383,6 +383,7 @@ def flag_handler(self, name, flags):
     def configure_args(self):
         spec = self.spec
         config_args = []
+        cflags = []
 
         # setup.py needs to be able to read the CPPFLAGS and LDFLAGS
         # as it scans for the library and headers to build
@@ -444,7 +445,7 @@ def configure_args(self):
             config_args.append('--without-ensurepip')
 
         if '+pic' in spec:
-            config_args.append('CFLAGS={0}'.format(self.compiler.cc_pic_flag))
+            cflags.append(self.compiler.cc_pic_flag)
 
         if '+ssl' in spec:
             if spec.satisfies('@3.7:'):
@@ -479,6 +480,12 @@ def configure_args(self):
         if spec.satisfies('@3.2: +sqlite3'):
             config_args.append('--enable-loadable-sqlite-extensions')
 
+        if spec.satisfies('%oneapi'):
+            cflags.append('-fp-model=strict')
+
+        if cflags:
+            config_args.append('CFLAGS={0}'.format(' '.join(cflags)))
+
         return config_args
 
     @run_after('install')


Test patch: