summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorscheibelp <scheibel1@llnl.gov>2017-03-16 21:07:35 -0700
committerbecker33 <becker33@llnl.gov>2017-03-16 21:07:35 -0700
commit5936ad2ca78566fd13ad11081a75e333697b2065 (patch)
treec9a9610619fffc0e67081b7cbb13ff3fd174f03c /lib
parent328b2142f5ea49ce07d6813073f37906b8a9c47d (diff)
downloadspack-5936ad2ca78566fd13ad11081a75e333697b2065.tar.gz
spack-5936ad2ca78566fd13ad11081a75e333697b2065.tar.bz2
spack-5936ad2ca78566fd13ad11081a75e333697b2065.tar.xz
spack-5936ad2ca78566fd13ad11081a75e333697b2065.zip
Dont propagate flags between different compilers (#3379)
* Dont propagate flags between different compilers Fixes #2786 Previously when a spec had no parents with an equivalent compiler, Spack would default to adding the compiler flags associated with the root of the DAG. This eliminates that default. * added test for compiler flag propagation * simplify compiler flag propagation logic
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/concretize.py59
-rw-r--r--lib/spack/spack/test/concretize.py10
2 files changed, 28 insertions, 41 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 1be0a7a81e..3d38f22cb6 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -377,41 +377,26 @@ class DefaultConcretizer(object):
# running.
return True
+ compiler_match = lambda other: (
+ spec.compiler == other.compiler and
+ spec.architecture == other.architecture)
+
ret = False
for flag in spack.spec.FlagMap.valid_compiler_flags():
+ if flag not in spec.compiler_flags:
+ spec.compiler_flags[flag] = list()
try:
nearest = next(p for p in spec.traverse(direction='parents')
- if ((p.compiler == spec.compiler and
- p is not spec) and
+ if (compiler_match(p) and
+ (p is not spec) and
flag in p.compiler_flags))
- if flag not in spec.compiler_flags or \
- not (sorted(spec.compiler_flags[flag]) >=
- sorted(nearest.compiler_flags[flag])):
- if flag in spec.compiler_flags:
- spec.compiler_flags[flag] = list(
- set(spec.compiler_flags[flag]) |
- set(nearest.compiler_flags[flag]))
- else:
- spec.compiler_flags[
- flag] = nearest.compiler_flags[flag]
+ nearest_flags = set(nearest.compiler_flags.get(flag, []))
+ flags = set(spec.compiler_flags.get(flag, []))
+ if (nearest_flags - flags):
+ spec.compiler_flags[flag] = list(nearest_flags | flags)
ret = True
-
except StopIteration:
- if (flag in spec.root.compiler_flags and
- ((flag not in spec.compiler_flags) or
- sorted(spec.compiler_flags[flag]) !=
- sorted(spec.root.compiler_flags[flag]))):
- if flag in spec.compiler_flags:
- spec.compiler_flags[flag] = list(
- set(spec.compiler_flags[flag]) |
- set(spec.root.compiler_flags[flag]))
- else:
- spec.compiler_flags[
- flag] = spec.root.compiler_flags[flag]
- ret = True
- else:
- if flag not in spec.compiler_flags:
- spec.compiler_flags[flag] = []
+ pass
# Include the compiler flag defaults from the config files
# This ensures that spack will detect conflicts that stem from a change
@@ -419,19 +404,11 @@ class DefaultConcretizer(object):
compiler = spack.compilers.compiler_for_spec(
spec.compiler, spec.architecture)
for flag in compiler.flags:
- if flag not in spec.compiler_flags:
- spec.compiler_flags[flag] = compiler.flags[flag]
- if compiler.flags[flag] != []:
- ret = True
- else:
- if ((sorted(spec.compiler_flags[flag]) !=
- sorted(compiler.flags[flag])) and
- (not set(spec.compiler_flags[flag]) >=
- set(compiler.flags[flag]))):
- ret = True
- spec.compiler_flags[flag] = list(
- set(spec.compiler_flags[flag]) |
- set(compiler.flags[flag]))
+ config_flags = set(compiler.flags.get(flag, []))
+ flags = set(spec.compiler_flags.get(flag, []))
+ spec.compiler_flags[flag] = list(config_flags | flags)
+ if (config_flags - flags):
+ ret = True
return ret
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index b7cad503a3..0cb3a34a48 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -175,6 +175,16 @@ class TestConcretize(object):
assert Spec('builtin.mock.multi-provider-mpi@1.10.0') in providers
assert Spec('builtin.mock.multi-provider-mpi@1.8.8') in providers
+ def test_different_compilers_get_different_flags(self):
+ client = Spec('cmake-client %gcc@4.7.2 platform=test os=fe target=fe' +
+ ' ^cmake %clang@3.5 platform=test os=fe target=fe')
+ client.concretize()
+ cmake = client['cmake']
+ assert set(client.compiler_flags['cflags']) == set(['-O0'])
+ assert set(cmake.compiler_flags['cflags']) == set(['-O3'])
+ assert set(client.compiler_flags['fflags']) == set(['-O0'])
+ assert not set(cmake.compiler_flags['fflags'])
+
def concretize_multi_provider(self):
s = Spec('mpileaks ^multi-provider-mpi@3.0')
s.concretize()