summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2016-01-12 15:22:15 -0800
committerGregory Becker <becker33@llnl.gov>2016-01-12 15:22:15 -0800
commit528f9cd5830f6c825f6d309d369268b0211923ba (patch)
tree265c997c9870cd2649dffc8ce8515ab59405f962
parent2ac5ea42af0d0a09fcc47e9e9035c267c7e3019b (diff)
downloadspack-528f9cd5830f6c825f6d309d369268b0211923ba.tar.gz
spack-528f9cd5830f6c825f6d309d369268b0211923ba.tar.bz2
spack-528f9cd5830f6c825f6d309d369268b0211923ba.tar.xz
spack-528f9cd5830f6c825f6d309d369268b0211923ba.zip
Implemented flags as lists for subsetting
-rwxr-xr-xlib/spack/env/cc39
-rw-r--r--lib/spack/spack/build_environment.py2
-rw-r--r--lib/spack/spack/concretize.py37
-rw-r--r--lib/spack/spack/spec.py38
4 files changed, 72 insertions, 44 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index b15c7b429b..846bfd0ff9 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -91,41 +91,53 @@ case "$command" in
cc|gcc|c89|c99|clang|xlc)
command=("$SPACK_CC")
if [ "$SPACK_CFLAGS" ]; then
- command+=("$SPACK_CFLAGS")
+ for flag in ${SPACK_CFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
language="C"
;;
c++|CC|g++|clang++|xlC)
command=("$SPACK_CXX")
if [ "$SPACK_CXXFLAGS" ]; then
- command+=("$SPACK_CXXFLAGS")
+ for flag in ${SPACK_CXXFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
language="C++"
;;
f77|xlf)
command=("$SPACK_F77")
if [ "$SPACK_FFLAGS" ]; then
- command+=("$SPACK_FFLAGS")
+ for flag in ${SPACK_FFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
language="Fortran 77"
;;
fc|f90|f95|xlf90)
command="$SPACK_FC"
if [ "$SPACK_FFLAGS" ]; then
- command+=("$SPACK_FFLAGS")
+ for flag in ${SPACK_FFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
language="Fortran 90"
;;
cpp)
mode=cpp
if [ "$SPACK_CPPFLAGS" ]; then
- command+=("$SPACK_CPPFLAGS")
+ for flag in ${SPACK_CPPFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
;;
ld)
mode=ld
if [ "$SPACK_LDFLAGS" ]; then
- command+=("$SPACK_LDFLAGS")
+ for flag in ${SPACK_LDFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
;;
*)
@@ -137,7 +149,9 @@ esac
if [ -z "$mode" ]; then
mode=ccld
if [ "$SPACK_LDFLAGS" ]; then
- command+=("$SPACK_LDFLAGS")
+ for flag in ${SPACK_LDFLAGS[@]}; do
+ command+=("$flag");
+ done
fi
for arg in "$@"; do
if [ "$arg" = -v -o "$arg" = -V -o "$arg" = --version -o "$arg" = -dumpversion ]; then
@@ -340,7 +354,6 @@ done
export PATH
full_command=("${command[@]}")
-#full_command+=("$SPACK_CFLAGS")
full_command+=("${args[@]}")
#
@@ -353,7 +366,11 @@ if [ "$SPACK_DEBUG" = "TRUE" ]; then
echo "$mode ${full_command[@]}" >> $output_log
fi
-echo "---------------------------" > /g/g0/becker33/cflag_test
-echo "${full_command[@]}" >> /g/g0/becker33/cflag_test
-echo "---------------------------" >> /g/g0/becker33/cflag_test
+#echo "---------------------------"
+#echo "---------------------------"
+#echo "---------------------------"
+#echo "${full_command[@]}"
+#echo "---------------------------"
+#echo "---------------------------"
+#echo "---------------------------"
exec "${full_command[@]}"
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 43824d7388..2a5ecde19f 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -108,7 +108,7 @@ def set_compiler_environment_variables(pkg):
for flag in Compiler.valid_compiler_flags():
# Concreteness guarantees key safety here
if flags[flag] != '':
- os.environ['SPACK_'+flag.upper()] = flags[flag]
+ os.environ['SPACK_'+flag.upper()] = ' '.join(f for f in flags[flag])
os.environ['SPACK_COMPILER_SPEC'] = str(pkg.spec.compiler)
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 801d3f162a..6631a1afce 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -183,24 +183,47 @@ class DefaultConcretizer(object):
"""
ret = False
for flag in Compiler.valid_compiler_flags():
- if flag in spec.compiler_flags:
- continue
+# if flag in spec.compiler_flags:
+# continue
try:
nearest = next(p for p in spec.traverse(direction='parents')
if ((p.compiler == spec.compiler and p is not spec)
and flag in p.compiler_flags))
if ((not flag in spec.compiler_flags) or
- spec.compiler_flags[flag] != nearest.compiler_flags[flag]):
- spec.compiler_flags[flag] = nearest.compiler_flags[flag]
+ 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.compielr_flags[flag] = nearest.compiler_flags[flag]
ret = True
except StopIteration:
if (flag in spec.root.compiler_flags and ((not flag in spec.compiler_flags) or
- spec.compiler_flags[flag] != spec.root.compiler_flags[flag])):
- spec.compiler_flags[flag] = spec.root.compiler_flags[flag]
+ 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:
- spec.compiler_flags[flag] = ''
+ if not flag in spec.compiler_flags:
+ spec.compiler_flags[flag] = []
+
+ # Include the compiler flag defaults from the config files
+ # This ensures that spack will detect conflicts that stem from a change
+ # in default compiler flags.
+ compiler = spack.compilers.compiler_for_spec(spec.compiler)
+ for flag in compiler.flags:
+ if flag not in spec.compiler_flags or spec.compiler_flags[flag] == []:
+ spec.compiler_flags[flag] = 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]))
return ret
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 406bb6aa43..f7cdcc128f 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -381,11 +381,11 @@ class FlagMap(HashableMap):
def satisfies(self, other, strict=False):
#"strict" makes no sense if this works, but it matches how we need it. Maybe
if strict:
- return all(k in self and self[k] == other[k]
- for k in other if other[k] != "")
+ return all(f in self and set(self[f]) == set(other[f])
+ for f in other if other[f] != [])
else:
- return all(k in self and self[k] == other[k]
- for k in other)
+ return all(f in self and set(self[f]) >= set(other[f])
+ for f in other)
def constrain(self, other):
@@ -396,13 +396,11 @@ class FlagMap(HashableMap):
changed = False
# 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:
- if k in self and self[k] != '':
- if self[k] != other[k]:
- # This will not recognize incompatible flags, merely concatenates
- self[k] += ' ' + other[k]
- changed = True
+ if k in self and self[k] != other[k]:
+ self[k] = list(set(self[k]) | set(other[k]))
+ changed = True
else:
self[k] = other[k]
changed = True
@@ -422,13 +420,13 @@ class FlagMap(HashableMap):
def _cmp_key(self):
- return ''.join(str(key)+str(value) for key, value in sorted(self.items()))
+ return ''.join(str(key) + ' '.join(str(v) for v in value) for key, value in sorted(self.items()))
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 ''
- return cond_symbol + '+'.join(str(key) + '=\"' + str(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)
class DependencyMap(HashableMap):
@@ -516,7 +514,7 @@ class Spec(object):
self._set_architecture(value)
elif name in valid_flags:
assert(self.compiler_flags is not None)
- self.compiler_flags[name] = value
+ self.compiler_flags[name] = value.split()
else:
self._add_variant(self,name,value)
@@ -816,6 +814,7 @@ class Spec(object):
concretized, they're added to the presets, and ancestors
will prefer the settings of their children.
"""
+
if presets is None: presets = {}
if visited is None: visited = set()
@@ -929,16 +928,6 @@ class Spec(object):
changed = any(changes)
force=True
- # Include the compiler flag defaults from the config files
- # This ensures that spack will detect conflicts that stemp from a change
- # in default compiler flags.
- pkg = spack.db.get(self)
- for flag in pkg.compiler.flags:
- if self.compiler_flags[flag] == '':
- self.compiler_flags[flag] += pkg.compiler.flags[flag]
- else:
- self.compiler_flags[flag] += ' ' + pkg.compiler.flags[flag]
-
self._concrete = True
@@ -1907,7 +1896,6 @@ class SpecParser(spack.parse.Parser):
self.token.value = self.token.value[1:-1]
else:
self.expect(ID)
- print "about to add", option, "=", self.token.value
spec._add_flag(option,self.token.value)
else:
spec._add_variant(self.variant(option),True)