Implemented flags as lists for subsetting
This commit is contained in:
parent
2ac5ea42af
commit
528f9cd583
4 changed files with 72 additions and 44 deletions
39
lib/spack/env/cc
vendored
39
lib/spack/env/cc
vendored
|
@ -91,41 +91,53 @@ case "$command" in
|
||||||
cc|gcc|c89|c99|clang|xlc)
|
cc|gcc|c89|c99|clang|xlc)
|
||||||
command=("$SPACK_CC")
|
command=("$SPACK_CC")
|
||||||
if [ "$SPACK_CFLAGS" ]; then
|
if [ "$SPACK_CFLAGS" ]; then
|
||||||
command+=("$SPACK_CFLAGS")
|
for flag in ${SPACK_CFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
language="C"
|
language="C"
|
||||||
;;
|
;;
|
||||||
c++|CC|g++|clang++|xlC)
|
c++|CC|g++|clang++|xlC)
|
||||||
command=("$SPACK_CXX")
|
command=("$SPACK_CXX")
|
||||||
if [ "$SPACK_CXXFLAGS" ]; then
|
if [ "$SPACK_CXXFLAGS" ]; then
|
||||||
command+=("$SPACK_CXXFLAGS")
|
for flag in ${SPACK_CXXFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
language="C++"
|
language="C++"
|
||||||
;;
|
;;
|
||||||
f77|xlf)
|
f77|xlf)
|
||||||
command=("$SPACK_F77")
|
command=("$SPACK_F77")
|
||||||
if [ "$SPACK_FFLAGS" ]; then
|
if [ "$SPACK_FFLAGS" ]; then
|
||||||
command+=("$SPACK_FFLAGS")
|
for flag in ${SPACK_FFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
language="Fortran 77"
|
language="Fortran 77"
|
||||||
;;
|
;;
|
||||||
fc|f90|f95|xlf90)
|
fc|f90|f95|xlf90)
|
||||||
command="$SPACK_FC"
|
command="$SPACK_FC"
|
||||||
if [ "$SPACK_FFLAGS" ]; then
|
if [ "$SPACK_FFLAGS" ]; then
|
||||||
command+=("$SPACK_FFLAGS")
|
for flag in ${SPACK_FFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
language="Fortran 90"
|
language="Fortran 90"
|
||||||
;;
|
;;
|
||||||
cpp)
|
cpp)
|
||||||
mode=cpp
|
mode=cpp
|
||||||
if [ "$SPACK_CPPFLAGS" ]; then
|
if [ "$SPACK_CPPFLAGS" ]; then
|
||||||
command+=("$SPACK_CPPFLAGS")
|
for flag in ${SPACK_CPPFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ld)
|
ld)
|
||||||
mode=ld
|
mode=ld
|
||||||
if [ "$SPACK_LDFLAGS" ]; then
|
if [ "$SPACK_LDFLAGS" ]; then
|
||||||
command+=("$SPACK_LDFLAGS")
|
for flag in ${SPACK_LDFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -137,7 +149,9 @@ esac
|
||||||
if [ -z "$mode" ]; then
|
if [ -z "$mode" ]; then
|
||||||
mode=ccld
|
mode=ccld
|
||||||
if [ "$SPACK_LDFLAGS" ]; then
|
if [ "$SPACK_LDFLAGS" ]; then
|
||||||
command+=("$SPACK_LDFLAGS")
|
for flag in ${SPACK_LDFLAGS[@]}; do
|
||||||
|
command+=("$flag");
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ "$arg" = -v -o "$arg" = -V -o "$arg" = --version -o "$arg" = -dumpversion ]; then
|
if [ "$arg" = -v -o "$arg" = -V -o "$arg" = --version -o "$arg" = -dumpversion ]; then
|
||||||
|
@ -340,7 +354,6 @@ done
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
full_command=("${command[@]}")
|
full_command=("${command[@]}")
|
||||||
#full_command+=("$SPACK_CFLAGS")
|
|
||||||
full_command+=("${args[@]}")
|
full_command+=("${args[@]}")
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -353,7 +366,11 @@ if [ "$SPACK_DEBUG" = "TRUE" ]; then
|
||||||
echo "$mode ${full_command[@]}" >> $output_log
|
echo "$mode ${full_command[@]}" >> $output_log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------" > /g/g0/becker33/cflag_test
|
#echo "---------------------------"
|
||||||
echo "${full_command[@]}" >> /g/g0/becker33/cflag_test
|
#echo "---------------------------"
|
||||||
echo "---------------------------" >> /g/g0/becker33/cflag_test
|
#echo "---------------------------"
|
||||||
|
#echo "${full_command[@]}"
|
||||||
|
#echo "---------------------------"
|
||||||
|
#echo "---------------------------"
|
||||||
|
#echo "---------------------------"
|
||||||
exec "${full_command[@]}"
|
exec "${full_command[@]}"
|
||||||
|
|
|
@ -108,7 +108,7 @@ def set_compiler_environment_variables(pkg):
|
||||||
for flag in Compiler.valid_compiler_flags():
|
for flag in Compiler.valid_compiler_flags():
|
||||||
# Concreteness guarantees key safety here
|
# Concreteness guarantees key safety here
|
||||||
if flags[flag] != '':
|
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)
|
os.environ['SPACK_COMPILER_SPEC'] = str(pkg.spec.compiler)
|
||||||
|
|
||||||
|
|
|
@ -183,24 +183,47 @@ def concretize_compiler_flags(self, spec):
|
||||||
"""
|
"""
|
||||||
ret = False
|
ret = False
|
||||||
for flag in Compiler.valid_compiler_flags():
|
for flag in Compiler.valid_compiler_flags():
|
||||||
if flag in spec.compiler_flags:
|
# if flag in spec.compiler_flags:
|
||||||
continue
|
# continue
|
||||||
try:
|
try:
|
||||||
nearest = next(p for p in spec.traverse(direction='parents')
|
nearest = next(p for p in spec.traverse(direction='parents')
|
||||||
if ((p.compiler == spec.compiler and p is not spec)
|
if ((p.compiler == spec.compiler and p is not spec)
|
||||||
and flag in p.compiler_flags))
|
and flag in p.compiler_flags))
|
||||||
if ((not flag in spec.compiler_flags) or
|
if ((not flag in spec.compiler_flags) or
|
||||||
spec.compiler_flags[flag] != nearest.compiler_flags[flag]):
|
sorted(spec.compiler_flags[flag]) != sorted(nearest.compiler_flags[flag])):
|
||||||
spec.compiler_flags[flag] = 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
|
ret = True
|
||||||
|
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
if (flag in spec.root.compiler_flags and ((not flag in spec.compiler_flags) or
|
if (flag in spec.root.compiler_flags and ((not flag in spec.compiler_flags) or
|
||||||
spec.compiler_flags[flag] != spec.root.compiler_flags[flag])):
|
sorted(spec.compiler_flags[flag]) != sorted(spec.root.compiler_flags[flag]))):
|
||||||
spec.compiler_flags[flag] = 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
|
ret = True
|
||||||
else:
|
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
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -381,11 +381,11 @@ def __init__(self, spec):
|
||||||
def satisfies(self, other, strict=False):
|
def satisfies(self, other, strict=False):
|
||||||
#"strict" makes no sense if this works, but it matches how we need it. Maybe
|
#"strict" makes no sense if this works, but it matches how we need it. Maybe
|
||||||
if strict:
|
if strict:
|
||||||
return all(k in self and self[k] == other[k]
|
return all(f in self and set(self[f]) == set(other[f])
|
||||||
for k in other if other[k] != "")
|
for f in other if other[f] != [])
|
||||||
else:
|
else:
|
||||||
return all(k in self and self[k] == other[k]
|
return all(f in self and set(self[f]) >= set(other[f])
|
||||||
for k in other)
|
for f in other)
|
||||||
|
|
||||||
|
|
||||||
def constrain(self, other):
|
def constrain(self, other):
|
||||||
|
@ -396,13 +396,11 @@ def constrain(self, other):
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
# 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] != '':
|
if k in self and self[k] != other[k]:
|
||||||
if self[k] != other[k]:
|
self[k] = list(set(self[k]) | set(other[k]))
|
||||||
# This will not recognize incompatible flags, merely concatenates
|
changed = True
|
||||||
self[k] += ' ' + other[k]
|
|
||||||
changed = True
|
|
||||||
else:
|
else:
|
||||||
self[k] = other[k]
|
self[k] = other[k]
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -422,13 +420,13 @@ def copy(self):
|
||||||
|
|
||||||
|
|
||||||
def _cmp_key(self):
|
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):
|
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 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):
|
class DependencyMap(HashableMap):
|
||||||
|
@ -516,7 +514,7 @@ def _add_flag(self, name, value):
|
||||||
self._set_architecture(value)
|
self._set_architecture(value)
|
||||||
elif name in valid_flags:
|
elif name in valid_flags:
|
||||||
assert(self.compiler_flags is not None)
|
assert(self.compiler_flags is not None)
|
||||||
self.compiler_flags[name] = value
|
self.compiler_flags[name] = value.split()
|
||||||
else:
|
else:
|
||||||
self._add_variant(self,name,value)
|
self._add_variant(self,name,value)
|
||||||
|
|
||||||
|
@ -816,6 +814,7 @@ 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()
|
||||||
|
|
||||||
|
@ -929,16 +928,6 @@ def concretize(self):
|
||||||
changed = any(changes)
|
changed = any(changes)
|
||||||
force=True
|
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
|
self._concrete = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1907,7 +1896,6 @@ def spec(self, name, check_valid_token = False):
|
||||||
self.token.value = self.token.value[1:-1]
|
self.token.value = self.token.value[1:-1]
|
||||||
else:
|
else:
|
||||||
self.expect(ID)
|
self.expect(ID)
|
||||||
print "about to add", option, "=", self.token.value
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue