Repository: spack/spack

Issue:
Installation issue: ParaView internal compiler error with intel/19.0.4
<!-- 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! -->

@chuckatkins issue for the internal compiler error that is fixed by adding -no-ipo to the cmake flags `CMAKE_C_FLAGS` and `CMAKE_CXX_FLAGS`

### 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 paraview@5.6.2%intel@19.0.4 +osmesa+mpi+python3+plugins+kits
...
  >> 5621    ": internal error: ** The compiler has encountered an unexpected problem.
     5622    ** Segmentation violation signal raised. **
     5623    Access violation or stack overflow. Please contact Intel Support for assistance.
     5624    
  >> 5625    icc: error #10014: problem during multi-file optimization compilation (code 4)
  >> 5626    make[2]: *** [lib/libvtkhdf5_hl-pv5.6.so.1] Error 4
     5627    make[2]: Leaving directory `/tmp/stam/spack-stage/spack-stage-paraview-5.6.2-3qej6zqzuupmz3trh2tq2huvrgpw5rpc/spack-build'
  >> 5628    make[1]: *** [VTK/ThirdParty/hdf5/vtkhdf5/hl/src/CMakeFiles/vtkhdf5_hl_src.dir/all] Error 2
     5629    make[1]: *** Waiting for unfinished jobs....
```

### Information on your system

<!-- Please include the output of `spack debug report` -->

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

packages.yaml for llvm and mesa:
```yaml
packages:
  cmake:
    version: ['3.15.3']
  freetype:
    version: ['2.7.1']
  hdf5:
    version: ['1.10.2']
    variants: ['+mpi', '+hl']
  llvm:
    version: ['7.1.0']
    variants: ['+link_dylib', '~clang', '~compiler-rt', '~gold', '~internal_unwind', '~libcxx', '~lld', '~lldb', '~polly']
  mesa:
    version: ['18.3.6']
    variants: ['+llvm']
  ncurses:
    version: ['6.1']
    variants: ['+termlib']
  openblas:
    version: ['0.3.6']
  openmpi:
    version: ['2.1.2']
    externals:
    - spec: openmpi@2.1.2
      modules:
      - openmpi/2.1.2
    buildable: False
  openssl:
    version: ['1.0.2o']
  paraview:
    variants: ['+osmesa', '+opengl2', '+python3', '+plugins', '+kits']
  python:
    version: ['3.6.8']
  py-matplotlib:
    version: ['3.1.1']
  py-numpy:
    version: ['1.17.3']
```

compilers.yaml for intel/19.0.4:
```yaml
  - compiler:
      spec: intel@19.0.4
      paths:
        cc: /usr/projects/hpcsoft/toss3/common/x86_64/intel-clusterstudio/2019.4.070/compilers_and_libraries_2019/linux/bin/intel64/icc
        cxx: /usr/projects/hpcsoft/toss3/common/x86_64/intel-clusterstudio/2019.4.070/compilers_and_libraries_2019/linux/bin/intel64/icpc
        f77: /usr/projects/hpcsoft/toss3/common/x86_64/intel-clusterstudio/2019.4.070/compilers_and_libraries_2019/linux/bin/intel64/ifort
        fc: /usr/projects/hpcsoft/toss3/common/x86_64/intel-clusterstudio/2019.4.070/compilers_and_libraries_2019/linux/bin/intel64/ifort
      flags: {}
      operating_system: rhel7
      target: x86_64
      modules:
        - intel/19.0.4
      environment: {}
      extra_rpaths: []
```

### Additional information

<!-- 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. -->


Discussion:
Quick question before disabling IPO entirely, can you try using `-ipo1` or `-ipo-jobs1`? I've had issues with prior versions of the Intel compiler where large applications will by default generate more than one object file and cause a segfault between multithreaded components in the compiler; serializing IPO fixed that in my case.
@omor1 I haven't tried that, but I'll give it a shot. Thanks!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/paraview/package.py b/var/spack/repos/builtin/packages/paraview/package.py
--- a/var/spack/repos/builtin/packages/paraview/package.py
+++ b/var/spack/repos/builtin/packages/paraview/package.py
@@ -276,6 +276,11 @@ def flag_handler(self, name, flags):
         if name == 'ldflags' and self.spec.satisfies('%intel'):
             flags.append('-shared-intel')
             return(None, flags, None)
+        # -no-ipo prevents internal compiler error from multi-file
+        # optimization (https://github.com/spack/spack/issues/18192)
+        if (name == 'cflags' or name == 'cxxflags') and self.spec.satisfies('%intel'):
+            flags.append('-no-ipo')
+            return(None, None, flags)
         return(flags, None, None)
 
     def setup_run_environment(self, env):


Test patch: