From 729e43ffac23ba512da0014cfef83f3e3d3e2919 Mon Sep 17 00:00:00 2001 From: Glenn Johnson Date: Thu, 2 Jan 2020 19:30:13 -0600 Subject: 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. --- .../repos/builtin/packages/py-numpy/package.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'var') 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') -- cgit v1.2.3-70-g09d2