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.
This commit is contained in:
parent
39a09691c5
commit
729e43ffac
@ -5,6 +5,7 @@
|
||||
|
||||
from spack import *
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
|
||||
class PyNumpy(PythonPackage):
|
||||
@ -95,6 +96,28 @@ def flag_handler(self, name, flags):
|
||||
# -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')
|
||||
|
Loading…
Reference in New Issue
Block a user