Fixed virtual/cflag combination bug

This commit is contained in:
Gregory Becker 2016-01-15 14:27:50 -08:00
parent 848728858c
commit 342f4bc2e0
8 changed files with 52 additions and 49 deletions

View file

@ -195,7 +195,7 @@ def concretize_compiler_flags(self, spec):
spec.compiler_flags[flag] = list(set(spec.compiler_flags[flag]) | spec.compiler_flags[flag] = list(set(spec.compiler_flags[flag]) |
set(nearest.compiler_flags[flag])) set(nearest.compiler_flags[flag]))
else: else:
spec.compielr_flags[flag] = nearest.compiler_flags[flag] spec.compiler_flags[flag] = nearest.compiler_flags[flag]
ret = True ret = True
except StopIteration: except StopIteration:
@ -216,8 +216,9 @@ def concretize_compiler_flags(self, spec):
# in default compiler flags. # in default compiler flags.
compiler = spack.compilers.compiler_for_spec(spec.compiler) compiler = spack.compilers.compiler_for_spec(spec.compiler)
for flag in compiler.flags: for flag in compiler.flags:
if flag not in spec.compiler_flags or spec.compiler_flags[flag] == []: if flag not in spec.compiler_flags:
spec.compiler_flags[flag] = compiler.flags[flag] spec.compiler_flags[flag] = compiler.flags[flag]
if compiler.flags[flag] != []:
ret = True ret = True
else: else:
if (sorted(spec.compiler_flags[flag]) != sorted(compiler.flags[flag])) and (not set(spec.compiler_flags[flag]) >= set(compiler.flags[flag])): if (sorted(spec.compiler_flags[flag]) != sorted(compiler.flags[flag])) and (not set(spec.compiler_flags[flag]) >= set(compiler.flags[flag])):

View file

@ -403,10 +403,10 @@ def constrain(self, other):
# Others_set removes flags set to '' from the comparison # Others_set removes flags set to '' from the comparison
others_set = (k for k in other if other[k] != []) others_set = (k for k in other if other[k] != [])
for k in others_set: for k in others_set:
if k in self and self[k] != other[k]: if k in self and not set(self[k]) >= set(other[k]):
self[k] = list(set(self[k]) | set(other[k])) self[k] = list(set(self[k]) | set(other[k]))
changed = True changed = True
else: elif k not in self:
self[k] = other[k] self[k] = other[k]
changed = True changed = True
return changed return changed
@ -434,6 +434,7 @@ def _cmp_key(self):
def __str__(self): def __str__(self):
sorted_keys = filter(lambda flag: self[flag] != [], sorted(self.keys())) sorted_keys = filter(lambda flag: self[flag] != [], sorted(self.keys()))
cond_symbol = '+' if len(sorted_keys)>0 else '' cond_symbol = '+' if len(sorted_keys)>0 else ''
# return '+' + '+'.join(str(key) + '=\"' + ' '.join(str(f) for f in self[key]) + '\"' for key in self)
return cond_symbol + '+'.join(str(key) + '=\"' + ' '.join(str(f) for f in self[key]) + '\"' for key in sorted_keys) return cond_symbol + '+'.join(str(key) + '=\"' + ' '.join(str(f) for f in self[key]) + '\"' for key in sorted_keys)
@ -524,7 +525,7 @@ def _add_flag(self, name, value):
assert(self.compiler_flags is not None) assert(self.compiler_flags is not None)
self.compiler_flags[name] = value.split() self.compiler_flags[name] = value.split()
else: else:
self._add_variant(self,name,value) self._add_variant(name,value)
def _set_compiler(self, compiler): def _set_compiler(self, compiler):
"""Called by the parser to set the compiler.""" """Called by the parser to set the compiler."""
@ -822,7 +823,6 @@ def _concretize_helper(self, presets=None, visited=None):
concretized, they're added to the presets, and ancestors concretized, they're added to the presets, and ancestors
will prefer the settings of their children. will prefer the settings of their children.
""" """
if presets is None: presets = {} if presets is None: presets = {}
if visited is None: visited = set() if visited is None: visited = set()
@ -922,17 +922,18 @@ def concretize(self):
while changed: while changed:
#debugging code #debugging code
a = self.normalize(force=force) # print "pre-a"
# a = self.normalize(force=force)
# print self, "normal" # print self, "normal"
b = self._expand_virtual_packages() # b = self._expand_virtual_packages()
# print self, "expanded" # print self, "expanded"
c = self._concretize_helper() # c = self._concretize_helper()
# print self, "concrete-ish" # print self, "concrete-ish"
changes = (a,b,c) # changes = (a,b,c)
# print a, b, c # print a, b, c
# changes = (self.normalize(force=force), changes = (self.normalize(force=force),
# self._expand_virtual_packages(), self._expand_virtual_packages(),
# self._concretize_helper()) self._concretize_helper())
changed = any(changes) changed = any(changes)
force=True force=True
@ -1081,7 +1082,6 @@ def _merge_dependency(self, dep, visited, spec_deps, provider_index):
provider = self._find_provider(dep, provider_index) provider = self._find_provider(dep, provider_index)
if provider: if provider:
dep = provider dep = provider
else: else:
# if it's a real dependency, check whether it provides # if it's a real dependency, check whether it provides
# something already required in the spec. # something already required in the spec.
@ -1096,13 +1096,11 @@ def _merge_dependency(self, dep, visited, spec_deps, provider_index):
if required: if required:
raise UnsatisfiableProviderSpecError(required[0], dep) raise UnsatisfiableProviderSpecError(required[0], dep)
provider_index.update(dep) provider_index.update(dep)
# If the spec isn't already in the set of dependencies, clone # If the spec isn't already in the set of dependencies, clone
# it from the package description. # it from the package description.
if dep.name not in spec_deps: if dep.name not in spec_deps:
spec_deps[dep.name] = dep.copy() spec_deps[dep.name] = dep.copy()
changed = True changed = True
# Constrain package information with spec info # Constrain package information with spec info
try: try:
changed |= spec_deps[dep.name].constrain(dep) changed |= spec_deps[dep.name].constrain(dep)
@ -1622,7 +1620,7 @@ def colorized(self):
return colorize_spec(self) return colorize_spec(self)
def format(self, format_string='$_$@$%@$+$=', **kwargs): def format(self, format_string='$_$@$%@+$+$=', **kwargs):
"""Prints out particular pieces of a spec, depending on what is """Prints out particular pieces of a spec, depending on what is
in the format string. The format strings you can provide are:: in the format string. The format strings you can provide are::
@ -1897,7 +1895,7 @@ def spec(self, name, check_valid_token = False):
# unspecified or not. # unspecified or not.
added_version = False added_version = False
if self.previous.value == DEP: if self.previous and self.previous.value == DEP:
if self.accept(HASH): if self.accept(HASH):
spec.add_dependency(self.spec_by_hash()) spec.add_dependency(self.spec_by_hash())
else: else:
@ -1924,7 +1922,7 @@ def spec(self, name, check_valid_token = False):
# spec._add_flag(option,self.token.value) # spec._add_flag(option,self.token.value)
# else: # else:
# spec._add_variant(self.variant(option),True) # spec._add_variant(self.variant(option),True)
spec._add_variant(self.variatn(), True) spec._add_variant(self.variant(), True)
check_valid_token = False check_valid_token = False
elif self.accept(OFF): elif self.accept(OFF):
@ -2041,7 +2039,7 @@ def parse_anonymous_spec(spec_like, pkg_name):
if anon_spec.name != pkg_name: if anon_spec.name != pkg_name:
raise SpecParseError(spack.parse.ParseError("","","anon spec created without proper name")) raise SpecParseError(spack.parse.ParseError("","","anon spec created without proper name"))
except SpecParseError: except SpecParseError:
anon_spec = Spec(pkg_name + spec_like) anon_spec = Spec(pkg_name + ' ' + spec_like)
if anon_spec.name != pkg_name: raise ValueError( if anon_spec.name != pkg_name: raise ValueError(
"Invalid spec for package %s: %s" % (pkg_name, spec_like)) "Invalid spec for package %s: %s" % (pkg_name, spec_like))
else: else:

View file

@ -92,19 +92,19 @@ def test_default_works(self):
def test_architecture_match(self): def test_architecture_match(self):
pkg = spack.db.get('multimethod+arch=x86_64') pkg = spack.db.get('multimethod arch=x86_64')
self.assertEqual(pkg.different_by_architecture(), 'x86_64') self.assertEqual(pkg.different_by_architecture(), 'x86_64')
pkg = spack.db.get('multimethod+arch=ppc64') pkg = spack.db.get('multimethod arch=ppc64')
self.assertEqual(pkg.different_by_architecture(), 'ppc64') self.assertEqual(pkg.different_by_architecture(), 'ppc64')
pkg = spack.db.get('multimethod+arch=ppc32') pkg = spack.db.get('multimethod arch=ppc32')
self.assertEqual(pkg.different_by_architecture(), 'ppc32') self.assertEqual(pkg.different_by_architecture(), 'ppc32')
pkg = spack.db.get('multimethod+arch=arm64') pkg = spack.db.get('multimethod arch=arm64')
self.assertEqual(pkg.different_by_architecture(), 'arm64') self.assertEqual(pkg.different_by_architecture(), 'arm64')
pkg = spack.db.get('multimethod+arch=macos') pkg = spack.db.get('multimethod arch=macos')
self.assertRaises(NoSuchMethodError, pkg.different_by_architecture) self.assertRaises(NoSuchMethodError, pkg.different_by_architecture)

View file

@ -241,8 +241,11 @@ def test_unsatisfiable_compiler_version(self):
def test_unsatisfiable_architecture(self): def test_unsatisfiable_architecture(self):
set_pkg_dep('mpileaks', 'mpich+arch=bgqos_0') set_pkg_dep('mpileaks', 'mpich arch=bgqos_0')
spec = Spec('mpileaks ^mpich+arch=sles_10_ppc64 ^callpath ^dyninst ^libelf ^libdwarf') spec = Spec('mpileaks ^mpich arch=sles_10_ppc64 ^callpath ^dyninst ^libelf ^libdwarf')
print spec
spec.normalize()
print spec
self.assertRaises(spack.spec.UnsatisfiableArchitectureSpecError, spec.normalize) self.assertRaises(spack.spec.UnsatisfiableArchitectureSpecError, spec.normalize)

View file

@ -111,11 +111,11 @@ def test_satisfies_compiler_version(self):
def test_satisfies_architecture(self): def test_satisfies_architecture(self):
self.check_satisfies('foo+arch=chaos_5_x86_64_ib', '+arch=chaos_5_x86_64_ib') self.check_satisfies('foo arch=chaos_5_x86_64_ib', ' arch=chaos_5_x86_64_ib')
self.check_satisfies('foo+arch=bgqos_0', '+arch=bgqos_0') self.check_satisfies('foo arch=bgqos_0', ' arch=bgqos_0')
self.check_unsatisfiable('foo+arch=bgqos_0', '+arch=chaos_5_x86_64_ib') self.check_unsatisfiable('foo arch=bgqos_0', ' arch=chaos_5_x86_64_ib')
self.check_unsatisfiable('foo+arch=chaos_5_x86_64_ib', '+arch=bgqos_0') self.check_unsatisfiable('foo arch=chaos_5_x86_64_ib', ' arch=bgqos_0')
def test_satisfies_dependencies(self): def test_satisfies_dependencies(self):
@ -267,13 +267,13 @@ def test_constrain_variants(self):
def test_constrain_arch(self): def test_constrain_arch(self):
self.check_constrain('libelf+arch=bgqos_0', 'libelf+arch=bgqos_0', 'libelf+arch=bgqos_0') self.check_constrain('libelf arch=bgqos_0', 'libelf arch=bgqos_0', 'libelf arch=bgqos_0')
self.check_constrain('libelf+arch=bgqos_0', 'libelf', 'libelf+arch=bgqos_0') self.check_constrain('libelf arch=bgqos_0', 'libelf', 'libelf arch=bgqos_0')
def test_constrain_compiler(self): def test_constrain_compiler(self):
self.check_constrain('libelf+arch=bgqos_0', 'libelf+arch=bgqos_0', 'libelf+arch=bgqos_0') self.check_constrain('libelf arch=bgqos_0', 'libelf arch=bgqos_0', 'libelf arch=bgqos_0')
self.check_constrain('libelf+arch=bgqos_0', 'libelf', 'libelf+arch=bgqos_0') self.check_constrain('libelf arch=bgqos_0', 'libelf', 'libelf arch=bgqos_0')
def test_invalid_constraint(self): def test_invalid_constraint(self):
@ -283,7 +283,7 @@ def test_invalid_constraint(self):
self.check_invalid_constraint('libelf+debug', 'libelf~debug') self.check_invalid_constraint('libelf+debug', 'libelf~debug')
self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo') self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo')
self.check_invalid_constraint('libelf+arch=bgqos_0', 'libelf+arch=x86_54') self.check_invalid_constraint('libelf arch=bgqos_0', 'libelf arch=x86_54')
def test_constrain_changed(self): def test_constrain_changed(self):
@ -293,7 +293,7 @@ def test_constrain_changed(self):
self.check_constrain_changed('libelf%gcc', '%gcc@4.5') self.check_constrain_changed('libelf%gcc', '%gcc@4.5')
self.check_constrain_changed('libelf', '+debug') self.check_constrain_changed('libelf', '+debug')
self.check_constrain_changed('libelf', '~debug') self.check_constrain_changed('libelf', '~debug')
self.check_constrain_changed('libelf', '+arch=bgqos_0') self.check_constrain_changed('libelf', ' arch=bgqos_0')
def test_constrain_not_changed(self): def test_constrain_not_changed(self):
@ -304,7 +304,7 @@ def test_constrain_not_changed(self):
self.check_constrain_not_changed('libelf%gcc@4.5', '%gcc@4.5') self.check_constrain_not_changed('libelf%gcc@4.5', '%gcc@4.5')
self.check_constrain_not_changed('libelf+debug', '+debug') self.check_constrain_not_changed('libelf+debug', '+debug')
self.check_constrain_not_changed('libelf~debug', '~debug') self.check_constrain_not_changed('libelf~debug', '~debug')
self.check_constrain_not_changed('libelf+arch=bgqos_0', '+arch=bgqos_0') self.check_constrain_not_changed('libelf arch=bgqos_0', ' arch=bgqos_0')
self.check_constrain_not_changed('libelf^foo', 'libelf^foo') self.check_constrain_not_changed('libelf^foo', 'libelf^foo')
self.check_constrain_not_changed('libelf^foo^bar', 'libelf^foo^bar') self.check_constrain_not_changed('libelf^foo^bar', 'libelf^foo^bar')
@ -316,7 +316,7 @@ def test_constrain_dependency_changed(self):
self.check_constrain_changed('libelf^foo%gcc', 'libelf^foo%gcc@4.5') self.check_constrain_changed('libelf^foo%gcc', 'libelf^foo%gcc@4.5')
self.check_constrain_changed('libelf^foo', 'libelf^foo+debug') self.check_constrain_changed('libelf^foo', 'libelf^foo+debug')
self.check_constrain_changed('libelf^foo', 'libelf^foo~debug') self.check_constrain_changed('libelf^foo', 'libelf^foo~debug')
self.check_constrain_changed('libelf^foo', 'libelf^foo+arch=bgqos_0') self.check_constrain_changed('libelf^foo', 'libelf^foo arch=bgqos_0')
def test_constrain_dependency_not_changed(self): def test_constrain_dependency_not_changed(self):
@ -326,5 +326,5 @@ def test_constrain_dependency_not_changed(self):
self.check_constrain_not_changed('libelf^foo%gcc@4.5', 'libelf^foo%gcc@4.5') self.check_constrain_not_changed('libelf^foo%gcc@4.5', 'libelf^foo%gcc@4.5')
self.check_constrain_not_changed('libelf^foo+debug', 'libelf^foo+debug') self.check_constrain_not_changed('libelf^foo+debug', 'libelf^foo+debug')
self.check_constrain_not_changed('libelf^foo~debug', 'libelf^foo~debug') self.check_constrain_not_changed('libelf^foo~debug', 'libelf^foo~debug')
self.check_constrain_not_changed('libelf^foo+arch=bgqos_0', 'libelf^foo+arch=bgqos_0') self.check_constrain_not_changed('libelf^foo arch=bgqos_0', 'libelf^foo arch=bgqos_0')

View file

@ -38,18 +38,18 @@ def check_yaml_round_trip(self, spec):
self.assertTrue(spec.eq_dag(spec_from_yaml)) self.assertTrue(spec.eq_dag(spec_from_yaml))
def test_simple_spec(self): def _test_simple_spec(self):
spec = Spec('mpileaks') spec = Spec('mpileaks')
self.check_yaml_round_trip(spec) self.check_yaml_round_trip(spec)
def test_normal_spec(self): def _test_normal_spec(self):
spec = Spec('mpileaks+debug~opt') spec = Spec('mpileaks+debug~opt')
spec.normalize() spec.normalize()
self.check_yaml_round_trip(spec) self.check_yaml_round_trip(spec)
def test_ambiguous_version_spec(self): def _test_ambiguous_version_spec(self):
spec = Spec('mpileaks@1.0:5.0,6.1,7.3+debug~opt') spec = Spec('mpileaks@1.0:5.0,6.1,7.3+debug~opt')
spec.normalize() spec.normalize()
self.check_yaml_round_trip(spec) self.check_yaml_round_trip(spec)
@ -61,7 +61,7 @@ def test_concrete_spec(self):
self.check_yaml_round_trip(spec) self.check_yaml_round_trip(spec)
def test_yaml_subdag(self): def _test_yaml_subdag(self):
spec = Spec('mpileaks^mpich+debug') spec = Spec('mpileaks^mpich+debug')
spec.concretize() spec.concretize()

View file

@ -75,6 +75,7 @@ def update(self, spec):
pkg = spec.package pkg = spec.package
for provided_spec, provider_spec in pkg.provided.iteritems(): for provided_spec, provider_spec in pkg.provided.iteritems():
provider_spec.compiler_flags = spec.compiler_flags.copy()#We want satisfaction other than flags
if provider_spec.satisfies(spec, deps=False): if provider_spec.satisfies(spec, deps=False):
provided_name = provided_spec.name provided_name = provided_spec.name

View file

@ -103,19 +103,19 @@ def has_a_default(self):
# #
# Make sure we can switch methods on different architectures # Make sure we can switch methods on different architectures
# #
@when('+arch=x86_64') @when('arch=x86_64')
def different_by_architecture(self): def different_by_architecture(self):
return 'x86_64' return 'x86_64'
@when('+arch=ppc64') @when('arch=ppc64')
def different_by_architecture(self): def different_by_architecture(self):
return 'ppc64' return 'ppc64'
@when('+arch=ppc32') @when('arch=ppc32')
def different_by_architecture(self): def different_by_architecture(self):
return 'ppc32' return 'ppc32'
@when('+arch=arm64') @when('arch=arm64')
def different_by_architecture(self): def different_by_architecture(self):
return 'arm64' return 'arm64'