Repository: spack/spack

Issue:
Installation issue: python3.8.0:3.8.2 %intel
 ### Steps to reproduce the issue

```console
$ spack install python@3.8.2%intel
```

### Information on your system

```console
$ spack debug report
* **Spack:** 0.13.3-2305-4b65efa
* **Python:** 3.7.2
* **Platform:** linux-rhel7-broadwell

$ cat ~/.spack/packages.yaml
packages:
  gettext:
    paths:
      gettext@0.19.8.1: /usr
    buildable: False
```

### Additional information

This issue appears across multiple systems, and only with python 3.8. I've successfully built python@3.7.7%intel from the same setup.

This is the build output. I'll attach the files separately.

```
==> 26527: python: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j16'

1 error found in build log:
     2884    	echo "generate-posix-vars failed" ; \
     2885    	rm -f ./pybuilddir.txt ; \
     2886    	exit 1 ; \
     2887    fi
     2888    /bin/sh: line 5: 44681 Segmentation fault      (core dumped) LD_LIBRARY_PATH=/tmp/becker33/spack-stage/spack-stage-python-3.8.2-g4sexg3dzya7jki2uz3aihxn4
             2ux6lk5/spack-src/spack-build ./python -E -S -m sysconfig --generate-posix-vars
     2889    generate-posix-vars failed
  >> 2890    make: *** [pybuilddir.txt] Error 1

See build log for details:
  /var/tmp/becker33/spack-stage/spack-stage-python-3.8.2-g4sexg3dzya7jki2uz3aihxn42ux6lk5/spack-build-out.txt

==> Error: Failed to install python due to ChildError: ProcessError: Command exited with status 2:
    'make' '-j16'
1 error found in build log:
     2884    	echo "generate-posix-vars failed" ; \
     2885    	rm -f ./pybuilddir.txt ; \
     2886    	exit 1 ; \
     2887    fi
     2888    /bin/sh: line 5: 44681 Segmentation fault      (core dumped) LD_LIBRARY_PATH=/tmp/becker33/spack-stage/spack-stage-python-3.8.2-g4sexg3dzya7jki2uz3aihxn4
             2ux6lk5/spack-src/spack-build ./python -E -S -m sysconfig --generate-posix-vars
     2889    generate-posix-vars failed
  >> 2890    make: *** [pybuilddir.txt] Error 1

See build log for details:
  /var/tmp/becker33/spack-stage/spack-stage-python-3.8.2-g4sexg3dzya7jki2uz3aihxn42ux6lk5/spack-build-out.txt
Traceback (most recent call last):
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/build_environment.py", line 813, in child_process
    return_value = function()
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/installer.py", line 1123, in build_process
    phase(pkg.spec, pkg.prefix)
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/package.py", line 108, in phase_wrapper
    phase(spec, prefix)
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/build_systems/autotools.py", line 305, in build
    inspect.getmodule(self).make(*self.build_targets)
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/build_environment.py", line 131, in __call__
    return super(MakeExecutable, self).__call__(*args, **kwargs)
  File "/g/g0/becker33/dev-spack/spack/lib/spack/spack/util/executable.py", line 189, in __call__
    proc.returncode, long_msg)
spack.util.executable.ProcessError: Command exited with status 2:
    'make' '-j16'

```

* [spack-build-out.txt](https://github.com/spack/spack/files/4611472/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/4611473/spack-build-env.txt)

@adamjstewart you're listed as a maintainer on this

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [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:
Update: This is also relevant for current Spack develop branch:

```console
$ spack debug report
* **Spack:** 0.14.2-1059-1367b63
* **Python:** 3.7.2
* **Platform:** linux-rhel7-broadwell
```
On further testing, this applies to all python@3.8.x

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
@@ -258,6 +258,15 @@ def setup_build_environment(self, env):
         env.unset('PYTHONPATH')
         env.unset('PYTHONHOME')
 
+    def flag_handler(self, name, flags):
+        # python 3.8 requires -fwrapv when compiled with intel
+        if self.spec.satisfies('@3.8: %intel'):
+            if name == 'cflags':
+                flags.append('-fwrapv')
+
+        # allow flags to be passed through compiler wrapper
+        return (flags, None, None)
+
     def configure_args(self):
         spec = self.spec
         config_args = []


Test patch: