targets: adjust packages to use new specific targets semantics

Seamless translation from 'target=<generic>' to either
- target.family == <generic> (in methods)
- 'target=<generic>:' (in directives)

Also updated docs to show ranges in directives.
This commit is contained in:
Massimiliano Culpo 2019-09-17 18:41:18 +02:00 committed by Todd Gamblin
parent 3c4322bf1a
commit 7daf860991
43 changed files with 80 additions and 68 deletions

View File

@ -410,6 +410,8 @@ For tarball downloads, Spack can currently support checksums using the
MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 algorithms. It
determines the algorithm to use based on the hash length.
.. _versions-and-fetching:
---------------------
Versions and fetching
---------------------
@ -3290,7 +3292,17 @@ Within directives each of the names above can be used to match a particular targ
# This patch is only applied on icelake microarchitectures
patch("icelake.patch", when="target=icelake")
in a similar way to what we have seen before for ``platform`` and ``os``.
It's also possible to select all the architectures belonging to the same family
using an open range:
.. code-block:: python
class Julia(Package):
# This patch is applied on all x86_64 microarchitectures.
# The trailing colon that denotes an open range of targets
patch("generic_x86_64.patch", when="target=x86_64:")
in a way that resembles what was shown in :ref:`versions-and-fetching` for versions.
Where ``target`` objects really shine though is when they are used in methods
called at configure, build or install time. In that case we can test targets
for supported features, for instance:

View File

@ -31,17 +31,17 @@ class Bowtie2(Package):
patch('bowtie2-2.3.1.patch', when='@2.3.1', level=0)
patch('bowtie2-2.3.0.patch', when='@2.3.0', level=0)
resource(name='simde', git="https://github.com/nemequ/simde",
destination='.', when='target=aarch64')
destination='.', when='target=aarch64:')
# seems to have trouble with 6's -std=gnu++14
conflicts('%gcc@6:', when='@:2.3.1')
conflicts('@:2.3.5.0', when='target=aarch64')
conflicts('@:2.3.5.0', when='target=aarch64:')
def patch(self):
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
copy_tree('simde', 'third_party/simde')
if self.spec.satisfies('%gcc@:4.8.9 target=aarch64'):
filter_file('-fopenmp-simd', '', 'Makefile')
if self.spec.satisfies('%gcc@:4.8.9'):
filter_file('-fopenmp-simd', '', 'Makefile')
@run_before('install')
def filter_sbang(self):
@ -66,7 +66,7 @@ def filter_sbang(self):
def install(self, spec, prefix):
make_arg = []
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
make_arg.append('POPCNT_CAPABILITY=0')
make(*make_arg)
mkdirp(prefix.bin)

View File

@ -105,7 +105,7 @@ class CbtfKrell(CMakePackage):
depends_on("gotcha")
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
parallel = False

View File

@ -24,7 +24,7 @@ class Cctools(AutotoolsPackage):
depends_on('swig')
# depends_on('xrootd')
depends_on('zlib')
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
# Generally SYS_foo is defined to __NR_foo (sys/syscall.h) which
# is then defined to a syscall number (asm/unistd_64.h). Certain

View File

@ -46,7 +46,7 @@ class Cudnn(Package):
def install(self, spec, prefix):
install_tree('.', prefix)
if 'target=ppc64le platform=linux' in spec:
if 'target=ppc64le: platform=linux' in spec:
symlink(os.path.join(prefix, 'targets', 'ppc64le-linux', 'lib'),
prefix.lib)
symlink(

View File

@ -24,7 +24,7 @@ def edit(self, spec, prefix):
makefile = FileFilter('Makefile')
makefile.filter(' -march=i686 ', ' ')
makefile.filter('CC=gcc', 'CC=%s' % spack_cc)
if spec.satisfies('target=aarch64'):
if spec.target.family == 'aarch64':
makefile.filter('-mfpmath=sse -msse -mmmx', ' ')
def install(self, spec, prefix):

View File

@ -18,7 +18,7 @@ class Diffsplice(MakefilePackage):
version('0.1.1', 'be90e6c072402d5aae0b4e2cbb8c10ac')
def edit(self, spec, prefix):
if spec.satisfies('target=aarch64'):
if spec.target.family == 'aarch64':
makefile = FileFilter(join_path(self.build_directory, 'Makefile'))
makefile.filter('-m64', '')

View File

@ -30,8 +30,7 @@ class Fasta(MakefilePackage):
def makefile_name(self):
if self.spec.satisfies('platform=darwin'):
name = 'Makefile.os_x86_64'
elif (self.spec.satisfies('platform=linux') and
self.spec.satisfies('target=x86_64')):
elif self.spec.satisfies('platform=linux target=x86_64:'):
name = 'Makefile.linux64_sse2'
else:
tty.die('''Unsupported platform/target, must be

View File

@ -96,8 +96,7 @@ def flag_handler(self, name, flags):
for targets, simds in target_simds.items():
if (
(arch not in targets)
and not any(
spec.satisfies('target={0}'.format(t)) for t in targets)
and str(spec.target.family) not in targets
):
if any(spec.satisfies('simd={0}'.format(x)) for x in simds):
raise ConflictsInSpecError(

View File

@ -21,14 +21,14 @@ class Flang(CMakePackage):
version('20180612', '62284e26214eaaff261a922c67f6878c')
depends_on('llvm@flang-develop', when='@develop')
depends_on('llvm@flang-20180921', when='@20180921 target=x86_64')
depends_on('llvm@flang-20180612', when='@20180612 target=x86_64')
depends_on('llvm@flang-20180921', when='@20180921 target=x86_64:')
depends_on('llvm@flang-20180612', when='@20180612 target=x86_64:')
depends_on('llvm@flang-20180921', when='@20180921 target=aarch64')
depends_on('llvm@flang-20180921', when='@20180921 target=aarch64:')
# LLVM version specific to OpenPOWER.
depends_on('llvm@flang-ppc64le-20180921', when='@20180921 target=ppc64le')
depends_on('llvm@flang-ppc64le-20180612', when='@20180612 target=ppc64le')
depends_on('llvm@flang-ppc64le-20180921', when='@20180921 target=ppc64le:')
depends_on('llvm@flang-ppc64le-20180612', when='@20180612 target=ppc64le:')
depends_on('pgmath@develop', when='@develop')
depends_on('pgmath@20180921', when='@20180921')

View File

@ -20,7 +20,7 @@ class Hisea(MakefilePackage):
depends_on('boost')
def patch(self):
if self.spec.satisfies("target=aarch64"):
if self.spec.target.family == 'aarch64':
filter_file('-mpopcnt', '', 'Makefile')
def install(self, spec, prefix):

View File

@ -73,7 +73,7 @@ class Hpctoolkit(AutotoolsPackage):
depends_on('zlib')
depends_on('cuda', when='+cuda')
depends_on('intel-xed', when='target=x86_64')
depends_on('intel-xed', when='target=x86_64:')
depends_on('mbedtls+pic', when='@gpu')
depends_on('papi', when='+papi')
depends_on('libpfm4', when='~papi')

View File

@ -68,7 +68,7 @@ def configure_args(self):
cflags.append('-O3')
if self.compiler.target in ['x86_64']:
cflags.append('-march=native')
elif not self.spec.satisfies('target=aarch64 %gcc@:5.9'):
elif not self.spec.satisfies('target=aarch64: %gcc@:5.9'):
cflags.append('-mcpu=native')
cflags.append('-mtune=native')
else:

View File

@ -27,7 +27,7 @@ class IbmJava(Package):
provides('java@8')
conflicts('target=x86_64', msg='ibm-java is only available for ppc64 and ppc64le')
conflicts('target=x86_64:', msg='ibm-java is only available for ppc64 and ppc64le')
# This assumes version numbers are 4-tuples: 8.0.5.30
def url_for_version(self, version):

View File

@ -196,7 +196,7 @@ class IntelParallelStudio(IntelPackage):
# MacOS does not support some of the auto dispatch settings
conflicts('auto_dispatch=SSE2', 'platform=darwin',
msg='SSE2 is not supported on MacOS')
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64',
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64:',
msg='SSE3 is not supported on MacOS x86_64')
def setup_dependent_environment(self, *args):

View File

@ -44,8 +44,8 @@ class IntelXed(Package):
depends_on('python@2.7:', type='build')
conflicts('target=ppc64', msg='intel-xed only runs on x86')
conflicts('target=ppc64le', msg='intel-xed only runs on x86')
conflicts('target=ppc64:', msg='intel-xed only runs on x86')
conflicts('target=ppc64le:', msg='intel-xed only runs on x86')
mycflags = []

View File

@ -53,7 +53,7 @@ class Intel(IntelPackage):
# MacOS does not support some of the auto dispatch settings
conflicts('auto_dispatch=SSE2', 'platform=darwin',
msg='SSE2 is not supported on MacOS')
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64',
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64:',
msg='SSE3 is not supported on MacOS x86_64')
# Since the current package is a subset of 'intel-parallel-studio',

View File

@ -35,6 +35,6 @@ class IsaacServer(CMakePackage):
# https://github.com/ComputationalRadiationPhysics/isaac/pull/70
patch('jpeg.patch', when='@:1.3.1')
patch('arm.patch', when='@:1.4.0 target=aarch64')
patch('arm.patch', when='@:1.4.0 target=aarch64:')
root_cmakelists_dir = 'server'

View File

@ -71,8 +71,8 @@ class Jdk(Package):
provides('java@8', when='@1.8.0:1.8.999')
provides('java@7', when='@1.7.0:1.7.999')
conflicts('target=ppc64', msg='jdk is only available for x86_64')
conflicts('target=ppc64le', msg='jdk is only available for x86_64')
conflicts('target=ppc64:', msg='jdk is only available for x86_64')
conflicts('target=ppc64le:', msg='jdk is only available for x86_64')
# FIXME:
# 1. `extends('java')` doesn't work, you need to use `extends('jdk')`

View File

@ -43,7 +43,7 @@ class Julia(Package):
patch('gc.patch', when='@0.4:0.4.5')
patch('openblas.patch', when='@0.4:0.4.5')
patch('armgcc.patch', when='@1.0.0:1.1.1 %gcc@:5.9 target=aarch64')
patch('armgcc.patch', when='@1.0.0:1.1.1 %gcc@:5.9 target=aarch64:')
variant('binutils', default=sys.platform != 'darwin',
description="Build via binutils")
@ -102,7 +102,7 @@ class Julia(Package):
depends_on("mpi", when="+mpi", type="run")
depends_on("py-matplotlib", when="+plot", type="run")
conflicts("@:0.7.0", when="target=aarch64")
conflicts("@:0.7.0", when="target=aarch64:")
def install(self, spec, prefix):
# Julia needs git tags
@ -133,7 +133,7 @@ def install(self, spec, prefix):
"BUILD_LLVM_CLANG=1",
"LLVM_ASSERTIONS=1",
"USE_LLVM_SHLIB=1"]
if spec.satisfies('target=aarch64'):
if spec.target.family == 'aarch64':
options += [
'JULIA_CPU_TARGET=generic',
'MARCH=armv8-a+crc']

View File

@ -23,8 +23,8 @@ class Libsharp(AutotoolsPackage):
depends_on('autoconf', type='build')
depends_on('mpi', when='+mpi')
patch('arm.patch', when='@2018-01-17 target=aarch64')
patch('1.0.0-arm.patch', when='@1.0.0 target=aarch64')
patch('arm.patch', when='@2018-01-17 target=aarch64:')
patch('1.0.0-arm.patch', when='@1.0.0 target=aarch64:')
def autoreconf(self, spec, prefix):
"""Generate autotools configuration"""

View File

@ -20,10 +20,10 @@ class Masurca(Package):
depends_on('perl', type=('build', 'run'))
depends_on('boost')
depends_on('zlib')
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
def patch(self):
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
for makefile in 'Makefile.am', 'Makefile.in':
m = join_path('global-1', 'prepare', makefile)
filter_file('-minline-all-stringops', '', m)

View File

@ -18,7 +18,7 @@ class Megahit(MakefilePackage):
depends_on('zlib')
patch('amd.patch', when='target=aarch64')
patch('amd.patch', when='target=aarch64:')
def install(self, spec, prefix):
mkdirp(prefix.bin)

View File

@ -18,14 +18,14 @@ class Minimap2(PythonPackage):
version('2.10', '52b36f726ec00bfca4a2ffc23036d1a2b5f96f0aae5a92fd826be6680c481c20')
version('2.2', '5b68e094f4fa3dfbd9b37d5b654b7715')
conflicts('target=aarch64', when='@:2.10')
conflicts('target=aarch64:', when='@:2.10')
depends_on('zlib', type='link')
depends_on('py-cython', type='build')
@run_after('install')
def install_minimap2(self):
make_arg = []
if self.spec.satisfies("target=aarch64"):
if self.spec.target.family == 'aarch64':
make_arg.extend([
'arm_neon=1',
'aarch64~1'

View File

@ -16,7 +16,8 @@ class Nanoflann(CMakePackage):
version('1.2.3', '92a0f44a631c41aa06f9716c51dcdb11')
def patch(self):
if self.spec.satisfies('target=aarch64 %gcc@:5.9'):
if self.spec.target.family == 'aarch64' and \
self.spec.satisfies('%gcc@:5.9'):
filter_file('-mtune=native', '', 'CMakeLists.txt')
def cmake_args(self):

View File

@ -86,7 +86,7 @@ class Openblas(MakefilePackage):
# Fixes compilation error on POWER8 with GCC 7
# https://github.com/xianyi/OpenBLAS/pull/1098
patch('power8.patch', when='@0.2.18:0.2.19 %gcc@7.1.0: target=ppc64')
patch('power8.patch', when='@0.2.18:0.2.19 %gcc@7.1.0: target=power8')
# Change file comments to work around clang 3.9 assembler bug
# https://github.com/xianyi/OpenBLAS/pull/982

View File

@ -34,8 +34,8 @@ class Openjdk(Package):
provides('java@11', when='@11.0:11.99')
provides('java@8', when='@1.8.0:1.8.999')
conflicts('target=ppc64', msg='openjdk is only available for x86_64')
conflicts('target=ppc64le', msg='openjdk is only available for x86_64')
conflicts('target=ppc64:', msg='openjdk is only available for x86_64')
conflicts('target=ppc64le:', msg='openjdk is only available for x86_64')
# FIXME:
# 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`

View File

@ -142,7 +142,7 @@ class OpenspeedshopUtils(CMakePackage):
depends_on("mrnet@5.0.1-3:+cti", when='@2.3.1.3:9999+cti', type=('build', 'link', 'run'))
depends_on("mrnet@5.0.1-3:+lwthreads", when='@2.3.1.3:9999', type=('build', 'link', 'run'))
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
parallel = False
build_directory = 'build_openspeedshop'

View File

@ -140,7 +140,7 @@ class Openspeedshop(CMakePackage):
depends_on("mrnet@5.0.1-3:+cti", when='@2.3.1.3:9999+cti', type=('build', 'link', 'run'))
depends_on("mrnet@5.0.1-3:+lwthreads", when='@2.3.1.3:9999', type=('build', 'link', 'run'))
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
parallel = False
build_directory = 'build_openspeedshop'

View File

@ -88,7 +88,7 @@ def install(self, spec, prefix):
# Makefile, leading to build errors.
env.pop('APPS', None)
if spec.satisfies('target=x86_64') or spec.satisfies('target=ppc64'):
if str(spec.target.family) in ('x86_64', 'ppc64'):
# This needs to be done for all 64-bit architectures (except Linux,
# where it happens automatically?)
env['KERNEL_BITS'] = '64'

View File

@ -30,7 +30,7 @@ def flag_handler(self, name, flags):
# FIXME; It is assumed that cray is x86_64.
# If you support arm on cray, you need to fix it.
arch = 'x86_64'
if (arch != 'x86_64' and not spec.satisfies("target=x86_64")):
if arch != 'x86_64' and spec.target.family != 'x86_64':
if spec.satisfies("+sse"):
raise ConflictsInSpecError(
spec,
@ -55,7 +55,7 @@ def flag_handler(self, name, flags):
@property
def makefile_file(self):
if not self.spec.satisfies('target=x86_64'):
if self.spec.target.family != 'x86_64':
return 'Makefile.nosse'
elif '+sse' in self.spec:
return 'Makefile.SSE3.gcc'
@ -73,7 +73,7 @@ def build(self, spec, prefix):
def install(self, spec, prefix):
mkdirp(prefix.bin)
if not self.spec.satisfies('target=x86_64'):
if self.spec.target.family != 'x86_64':
install('parsimonator', prefix.bin)
elif '+sse' in spec:
install('parsimonator-SSE3', prefix.bin)

View File

@ -27,7 +27,7 @@ class PlanckLikelihood(Package):
patch('fortran.patch')
patch('make.patch')
patch('arm.patch', when='target=aarch64')
patch('arm.patch', when='target=aarch64:')
resource(
name='baseline',

View File

@ -46,7 +46,7 @@ def patch(self):
)
# remove -m64 on aarch64
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
for f in ['lib/Makefile.am', 'src/Makefile.am']:
filter_file('-m64', '', f)

View File

@ -18,6 +18,6 @@ class PyFlye(PythonPackage):
depends_on('python@2.7:2.8', type=('build', 'run'))
def setup_environment(self, spack_env, run_env):
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
spack_env.set('arm_neon', '1')
spack_env.set('aarch64', '1')

View File

@ -21,4 +21,4 @@ class Rapidjson(CMakePackage):
# branch-fall-through warnings
patch('0001-turn-off-Werror.patch')
patch('arm.patch', when='@1.1.0 target=aarch64 %gcc@:5.9')
patch('arm.patch', when='@1.1.0 target=aarch64: %gcc@:5.9')

View File

@ -45,7 +45,7 @@ def flag_handler(self, name, flags):
# FIXME; It is assumed that cray is x86_64.
# If you support arm on cray, you need to fix it.
arch = 'x86_64'
if (arch != 'x86_64' and not spec.satisfies("target=x86_64")):
if arch != 'x86_64' and not spec.target.family == 'x86_64':
if spec.satisfies("+sse"):
raise ConflictsInSpecError(
spec,
@ -77,7 +77,7 @@ def install(self, spec, prefix):
if spec.satisfies('+mpi'):
makefile.filter('mpicc', self.spec['mpi'].mpicc)
if spec.satisfies('target=x86_64'):
if spec.target.family == 'x86_64':
if spec.satisfies('+mpi +avx +pthreads'):
make('-f', 'Makefile.AVX.HYBRID.gcc')
install('raxmlHPC-HYBRID-AVX', prefix.bin)

View File

@ -35,7 +35,8 @@ class Rocksdb(MakefilePackage):
phases = ['install']
def patch(self):
if (self.spec.satisfies('target=aarch64 %gcc@:5.9')):
if (self.spec.target.family == 'aarch64' and
self.spec.satisfies('%gcc@:5.9')):
filter_file(
'-march=native', '',
join_path('build_tools', 'build_detect_platform')

View File

@ -22,6 +22,6 @@ class Sdl2(CMakePackage):
def cmake_args(self):
return [
'-DSSEMATH={0}'.format(
'OFF' if self.spec.satisfies('target=aarch64') else 'ON'
'OFF' if self.spec.target.family == 'aarch64' else 'ON'
)
]

View File

@ -24,7 +24,7 @@ class Strace(AutotoolsPackage):
def configure_args(self):
args = []
if self.spec.satisfies('target=aarch64'):
if self.spec.target.family == 'aarch64':
args.append('--enable-mpers=no')
else:
args.append('--enable-mpers=yes')

View File

@ -30,7 +30,7 @@ def build(self, spec, prefix):
'CC_EXEC = {0}'.format(spack_cc),
'Makefile.Linux'
)
if spec.satisfies('target=aarch64'):
if spec.target.family == 'aarch64':
filter_file('-mtune=core2', '', 'Makefile.Linux')
if spec.satisfies('@1.6.2:1.6.4'):
filter_file(

View File

@ -25,7 +25,7 @@ class Tealeaf(MakefilePackage):
depends_on('mpi')
def edit(self, spec, prefix):
if (spec.satisfies('target=aarch64 %gcc@:5.9')):
if spec.target.family == 'aarch64' and spec.satisfies('%gcc@:5.9'):
filter_file(
'-march=native', '', join_path('TeaLeaf_ref', 'Makefile')
)

View File

@ -33,11 +33,11 @@ class Vdt(CMakePackage):
def flag_handler(self, name, flags):
arch = ''
spec = self.spec
if (spec.satisfies("platform=cray")):
if spec.satisfies("platform=cray"):
# FIXME; It is assumed that cray is x86_64.
# If you support arm on cray, you need to fix it.
arch = 'x86_64'
if (arch != 'x86_64' and not spec.satisfies("target=x86_64")):
if arch != 'x86_64' and not spec.satisfies("target=x86_64:"):
for s in self.simd_x86:
if (spec.satisfies("simd={0}".format(s))):
raise ConflictsInSpecError(
@ -51,8 +51,8 @@ def flag_handler(self, name, flags):
)]
)
# FIXME: It is assumed that arm 32 bit target is arm.
if (arch != 'arm' and not spec.satisfies("target=arm")):
if (spec.satisfies("simd=neon")):
if arch != 'arm' and not spec.satisfies("target=arm"):
if spec.satisfies("simd=neon"):
raise ConflictsInSpecError(
spec,
[(

View File

@ -18,7 +18,7 @@ class Velvet(MakefilePackage):
depends_on('zlib')
def edit(self, spec, prefix):
if spec.satisfies('target=aarch64'):
if spec.target.family == 'aarch64':
makefile = FileFilter('Makefile')
makefile.filter('-m64', '')