Repository: spack/spack

Issue:
Installation issue: VTK, internal compiler error with Intel 19.0.5
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack install vtk@8.2.0 ~mpi +opengl2 %intel ^freetype%gcc ^hdf5~mpi
...
  >> 1846    ": internal error: ** The compiler has encountered an unexpected problem.
     1847    ** Segmentation violation signal raised. **
     1848    Access violation or stack overflow. Please contact Intel Support for assistance.
     1849
  >> 1850    icpc: error #10014: problem during multi-file optimization compilation (code 4)
  >> 1851    make[2]: *** [lib/libvtkCommonMath-8.2.so.1] Error 4
     1852    make[2]: Leaving directory `/tmp/bamboo_sta/spack-stage/spack-stage-vtk-8.2.0-jugxugntvxvvhv2hm
             qadjumisr4xs7sn/spack-build-jugxugn'
  >> 1853    make[1]: *** [Common/Math/CMakeFiles/vtkCommonMath.dir/all] Error 2
```

### Information on your system

<!-- Please include the output of `spack debug report` -->

* **Spack:** 0.16.0
* **Python:** 3.6.8
* **Platform:** linux-centos7-broadwell
[spack-build-out.txt](https://github.com/spack/spack/files/5714900/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/5714901/spack-build-env.txt)



<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt]()
* [spack-build-env.txt]()

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

@chuckatkins @danlipsa 

### 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:
Would this fix it?
https://github.com/spack/spack/pull/18193
> Would this fix it?
> #18193

I think so, yes.
Can you please try it and file a PR. Thanks! 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/vtk/package.py b/var/spack/repos/builtin/packages/vtk/package.py
--- a/var/spack/repos/builtin/packages/vtk/package.py
+++ b/var/spack/repos/builtin/packages/vtk/package.py
@@ -265,11 +265,10 @@ def cmake_args(self):
                     '-DVTK_USE_X:BOOL=ON',
                     '-DVTK_USE_COCOA:BOOL=OFF'])
 
+        compile_flags = []
+
         if spec.satisfies('@:6.1.0'):
-            cmake_args.extend([
-                '-DCMAKE_C_FLAGS=-DGLX_GLXEXT_LEGACY',
-                '-DCMAKE_CXX_FLAGS=-DGLX_GLXEXT_LEGACY'
-            ])
+            compile_flags.append('-DGLX_GLXEXT_LEGACY')
 
             # VTK 6.1.0 (and possibly earlier) does not use
             # NETCDF_CXX_ROOT to detect NetCDF C++ bindings, so
@@ -298,4 +297,16 @@ def cmake_args(self):
                 cmake_args.append(
                     '-DVTK_MODULE_ENABLE_VTK_IOMotionFX:BOOL=OFF')
 
+        # -no-ipo prevents an internal compiler error from multi-file
+        # optimization (https://github.com/spack/spack/issues/20471)
+        if '%intel' in spec:
+            compile_flags.append('-no-ipo')
+
+        if compile_flags:
+            compile_flags = ' '.join(compile_flags)
+            cmake_args.extend([
+                '-DCMAKE_C_FLAGS={0}'.format(compile_flags),
+                '-DCMAKE_CXX_FLAGS={0}'.format(compile_flags)
+            ])
+
         return cmake_args


Test patch: