diff options
author | Glenn Johnson <glenn-johnson@uiowa.edu> | 2020-01-02 19:30:13 -0600 |
---|---|---|
committer | Adam J. Stewart <ajstewart426@gmail.com> | 2020-01-02 19:30:13 -0600 |
commit | 729e43ffac23ba512da0014cfef83f3e3d3e2919 (patch) | |
tree | 1eb9759392f2a9429909baab38691e7da428caff | |
parent | 39a09691c555ea26c03742b2163519e3a06214b2 (diff) | |
download | spack-729e43ffac23ba512da0014cfef83f3e3d3e2919.tar.gz spack-729e43ffac23ba512da0014cfef83f3e3d3e2919.tar.bz2 spack-729e43ffac23ba512da0014cfef83f3e3d3e2919.tar.xz spack-729e43ffac23ba512da0014cfef83f3e3d3e2919.zip |
Get py-numpy > 1.16 to build with Intel compiler (#14360)
Beginning with numpy > 1.16 when using older versions of gcc the
`std=c99` flag must be used. The Intel compiler depends on gcc for its
language extensions so the version of gcc is important. If the version
of gcc used by the Intel compiler is one that requires the `-std=c99`
flag then that flag will have to be used for a build with the Intel
compiler as well.
This PR tests the version of gcc used by the Intel compiler and will
abort the build if the gcc version is < 4.8 and inject the `-std=c99`
flag if >= 4.8 and < 5.1. This will cover the system gcc compiler and
any gcc environment module loaded at build time.
-rw-r--r-- | var/spack/repos/builtin/packages/py-numpy/package.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/py-numpy/package.py b/var/spack/repos/builtin/packages/py-numpy/package.py index 9d5427347d..af045b2674 100644 --- a/var/spack/repos/builtin/packages/py-numpy/package.py +++ b/var/spack/repos/builtin/packages/py-numpy/package.py @@ -5,6 +5,7 @@ from spack import * import platform +import subprocess class PyNumpy(PythonPackage): @@ -95,6 +96,28 @@ class PyNumpy(PythonPackage): # -std=c99 at least required, old versions of GCC default to -std=c90 if self.spec.satisfies('%gcc@:5.1') and name == 'cflags': flags.append(self.compiler.c99_flag) + # Check gcc version in use by intel compiler + # This will essentially check the system gcc compiler unless a gcc + # module is already loaded. + if self.spec.satisfies('%intel') and name == 'cflags': + p1 = subprocess.Popen( + [self.compiler.cc, '-v'], + stderr=subprocess.PIPE + ) + p2 = subprocess.Popen( + ['grep', 'compatibility'], + stdin=p1.stderr, + stdout=subprocess.PIPE + ) + p1.stderr.close() + out, err = p2.communicate() + gcc_version = Version(out.split()[5].decode('utf-8')) + if gcc_version < Version('4.8'): + raise InstallError('The GCC version that the Intel compiler ' + 'uses must be >= 4.8. The GCC in use is ' + '{0}'.format(gcc_version)) + if gcc_version <= Version('5.1'): + flags.append(self.compiler.c99_flag) return (flags, None, None) @run_before('build') |