python: added a variant to enable PGO + using --with-icc if compiled with Intel (#7496)
Added a variant to enable default optimizations for production builds. Uses --with-icc if built with Intel compilers.
This commit is contained in:
parent
8890dbe3d9
commit
dffd8f384c
@ -86,6 +86,11 @@ class Python(AutotoolsPackage):
|
|||||||
description='Produce position-independent code (for shared libs)')
|
description='Produce position-independent code (for shared libs)')
|
||||||
|
|
||||||
variant('dbm', default=True, description='Provide support for dbm')
|
variant('dbm', default=True, description='Provide support for dbm')
|
||||||
|
variant(
|
||||||
|
'optimizations',
|
||||||
|
default=False,
|
||||||
|
description='Enable expensive build-time optimizations, if available'
|
||||||
|
)
|
||||||
|
|
||||||
depends_on("openssl")
|
depends_on("openssl")
|
||||||
depends_on("bzip2")
|
depends_on("bzip2")
|
||||||
@ -104,10 +109,21 @@ class Python(AutotoolsPackage):
|
|||||||
patch('cray-rpath-2.3.patch', when="@2.3:3.0.1 platform=cray")
|
patch('cray-rpath-2.3.patch', when="@2.3:3.0.1 platform=cray")
|
||||||
patch('cray-rpath-3.1.patch', when="@3.1:3.99 platform=cray")
|
patch('cray-rpath-3.1.patch', when="@3.1:3.99 platform=cray")
|
||||||
|
|
||||||
|
# For more information refer to this bug report:
|
||||||
|
# https://bugs.python.org/issue29712
|
||||||
|
conflicts(
|
||||||
|
'@:2.8 +shared',
|
||||||
|
when='+optimizations',
|
||||||
|
msg='+optimizations is incompatible with +shared in python@2.X'
|
||||||
|
)
|
||||||
|
|
||||||
_DISTUTIL_VARS_TO_SAVE = ['LDSHARED']
|
_DISTUTIL_VARS_TO_SAVE = ['LDSHARED']
|
||||||
_DISTUTIL_CACHE_FILENAME = 'sysconfig.json'
|
_DISTUTIL_CACHE_FILENAME = 'sysconfig.json'
|
||||||
_distutil_vars = None
|
_distutil_vars = None
|
||||||
|
|
||||||
|
# An in-source build with --enable-optimizations fails for python@3.X
|
||||||
|
build_directory = 'spack-build'
|
||||||
|
|
||||||
@when('@2.7:2.8,3.4:')
|
@when('@2.7:2.8,3.4:')
|
||||||
def patch(self):
|
def patch(self):
|
||||||
# NOTE: Python's default installation procedure makes it possible for a
|
# NOTE: Python's default installation procedure makes it possible for a
|
||||||
@ -122,7 +138,6 @@ def patch(self):
|
|||||||
|
|
||||||
def setup_environment(self, spack_env, run_env):
|
def setup_environment(self, spack_env, run_env):
|
||||||
spec = self.spec
|
spec = self.spec
|
||||||
prefix = self.prefix
|
|
||||||
|
|
||||||
# TODO: The '--no-user-cfg' option for Python installation is only in
|
# TODO: The '--no-user-cfg' option for Python installation is only in
|
||||||
# Python v2.7 and v3.4+ (see https://bugs.python.org/issue1180) and
|
# Python v2.7 and v3.4+ (see https://bugs.python.org/issue1180) and
|
||||||
@ -133,8 +148,6 @@ def setup_environment(self, spack_env, run_env):
|
|||||||
'user configurations are present.').format(self.version))
|
'user configurations are present.').format(self.version))
|
||||||
|
|
||||||
# Need this to allow python build to find the Python installation.
|
# Need this to allow python build to find the Python installation.
|
||||||
spack_env.set('PYTHONHOME', prefix)
|
|
||||||
spack_env.set('PYTHONPATH', prefix)
|
|
||||||
spack_env.set('MACOSX_DEPLOYMENT_TARGET', platform.mac_ver()[0])
|
spack_env.set('MACOSX_DEPLOYMENT_TARGET', platform.mac_ver()[0])
|
||||||
|
|
||||||
def configure_args(self):
|
def configure_args(self):
|
||||||
@ -148,9 +161,18 @@ def configure_args(self):
|
|||||||
'CPPFLAGS=-I{0}'.format(' -I'.join(dp.include for dp in dep_pfxs)),
|
'CPPFLAGS=-I{0}'.format(' -I'.join(dp.include for dp in dep_pfxs)),
|
||||||
'LDFLAGS=-L{0}'.format(' -L'.join(dp.lib for dp in dep_pfxs)),
|
'LDFLAGS=-L{0}'.format(' -L'.join(dp.lib for dp in dep_pfxs)),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if spec.satisfies('@2.7.13:2.8,3.5.3:', strict=True) \
|
||||||
|
and '+optimizations' in spec:
|
||||||
|
config_args.append('--enable-optimizations')
|
||||||
|
|
||||||
if spec.satisfies('%gcc platform=darwin'):
|
if spec.satisfies('%gcc platform=darwin'):
|
||||||
config_args.append('--disable-toolbox-glue')
|
config_args.append('--disable-toolbox-glue')
|
||||||
|
|
||||||
|
if spec.satisfies('%intel', strict=True) and \
|
||||||
|
spec.satisfies('@2.7.12:2.8,3.5.2:', strict=True):
|
||||||
|
config_args.append('--with-icc')
|
||||||
|
|
||||||
if '+shared' in spec:
|
if '+shared' in spec:
|
||||||
config_args.append('--enable-shared')
|
config_args.append('--enable-shared')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user