Fixed variants in new format and removed print statements from debugging
This commit is contained in:
parent
0b5836cfce
commit
566fec4015
27
lib/spack/env/cc
vendored
27
lib/spack/env/cc
vendored
@ -105,7 +105,7 @@ case "$command" in
|
|||||||
f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor)
|
f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor)
|
||||||
command="$SPACK_FC"
|
command="$SPACK_FC"
|
||||||
language="Fortran 90"
|
language="Fortran 90"
|
||||||
lang_flags=FC
|
lang_flags=F
|
||||||
;;
|
;;
|
||||||
f77|gfortran|ifort|pgfortran|xlf|nagfor)
|
f77|gfortran|ifort|pgfortran|xlf|nagfor)
|
||||||
command="$SPACK_F77"
|
command="$SPACK_F77"
|
||||||
@ -184,13 +184,13 @@ args=("$@")
|
|||||||
|
|
||||||
# Prepend cppflags, cflags, cxxflags, fcflags, fflags, and ldflags
|
# Prepend cppflags, cflags, cxxflags, fcflags, fflags, and ldflags
|
||||||
|
|
||||||
# Add cppflags
|
# Add ldflags
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
cppas|cc|ccld)
|
ld|ccld)
|
||||||
args=(${SPACK_CPPFLAGS[@]} "${args[@]}") ;;
|
args=(${SPACK_LDFLAGS[@]} "${args[@]}") ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Add compile flags.
|
# Add compiler flags.
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
cc|ccld)
|
cc|ccld)
|
||||||
# Add c, cxx, fc, and f flags
|
# Add c, cxx, fc, and f flags
|
||||||
@ -199,20 +199,25 @@ case "$mode" in
|
|||||||
args=(${SPACK_CFLAGS[@]} "${args[@]}") ;;
|
args=(${SPACK_CFLAGS[@]} "${args[@]}") ;;
|
||||||
CXX)
|
CXX)
|
||||||
args=(${SPACK_CXXFLAGS[@]} "${args[@]}") ;;
|
args=(${SPACK_CXXFLAGS[@]} "${args[@]}") ;;
|
||||||
FC)
|
|
||||||
args=(${SPACK_FCFLAGS[@]} "${args[@]}") ;;
|
|
||||||
F)
|
|
||||||
args=(${SPACK_FFLAGS[@]} "${args[@]}") ;;
|
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Add ldflags
|
# Add cppflags
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
ld|ccld)
|
cpp|as|cc|ccld)
|
||||||
args=(${SPACK_CPPFLAGS[@]} "${args[@]}") ;;
|
args=(${SPACK_CPPFLAGS[@]} "${args[@]}") ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
case "$mode" in cc|ccld)
|
||||||
|
# Add fortran flags
|
||||||
|
case $lang_flags in
|
||||||
|
F)
|
||||||
|
args=(${SPACK_FFLAGS[@]} "${args[@]}") ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Read spack dependencies from the path environment variable
|
# Read spack dependencies from the path environment variable
|
||||||
IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
|
IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
|
||||||
for dep in "${deps[@]}"; do
|
for dep in "${deps[@]}"; do
|
||||||
|
@ -378,7 +378,7 @@ def __str__(self):
|
|||||||
|
|
||||||
|
|
||||||
_valid_compiler_flags = [
|
_valid_compiler_flags = [
|
||||||
'cflags', 'cxxflags', 'fcflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags']
|
'cflags', 'cxxflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags']
|
||||||
|
|
||||||
class FlagMap(HashableMap):
|
class FlagMap(HashableMap):
|
||||||
def __init__(self, spec):
|
def __init__(self, spec):
|
||||||
|
@ -56,11 +56,16 @@ def setUp(self):
|
|||||||
self.cc = Executable(join_path(spack.build_env_path, "cc"))
|
self.cc = Executable(join_path(spack.build_env_path, "cc"))
|
||||||
self.ld = Executable(join_path(spack.build_env_path, "ld"))
|
self.ld = Executable(join_path(spack.build_env_path, "ld"))
|
||||||
self.cpp = Executable(join_path(spack.build_env_path, "cpp"))
|
self.cpp = Executable(join_path(spack.build_env_path, "cpp"))
|
||||||
|
self.cxx = Executable(join_path(spack.build_env_path, "c++"))
|
||||||
|
self.fc = Executable(join_path(spack.build_env_path, "fc"))
|
||||||
|
|
||||||
self.realcc = "/bin/mycc"
|
self.realcc = "/bin/mycc"
|
||||||
self.prefix = "/spack-test-prefix"
|
self.prefix = "/spack-test-prefix"
|
||||||
|
|
||||||
os.environ['SPACK_CC'] = self.realcc
|
os.environ['SPACK_CC'] = self.realcc
|
||||||
|
os.environ['SPACK_CXX'] = self.realcc
|
||||||
|
os.environ['SPACK_FC'] = self.realcc
|
||||||
|
|
||||||
os.environ['SPACK_PREFIX'] = self.prefix
|
os.environ['SPACK_PREFIX'] = self.prefix
|
||||||
os.environ['SPACK_ENV_PATH']="test"
|
os.environ['SPACK_ENV_PATH']="test"
|
||||||
os.environ['SPACK_DEBUG_LOG_DIR'] = "."
|
os.environ['SPACK_DEBUG_LOG_DIR'] = "."
|
||||||
@ -97,6 +102,15 @@ def check_cc(self, command, args, expected):
|
|||||||
self.assertEqual(self.cc(*args, output=str).strip(), expected)
|
self.assertEqual(self.cc(*args, output=str).strip(), expected)
|
||||||
|
|
||||||
|
|
||||||
|
def check_cxx(self, command, args, expected):
|
||||||
|
os.environ['SPACK_TEST_COMMAND'] = command
|
||||||
|
self.assertEqual(self.cxx(*args, output=str).strip(), expected)
|
||||||
|
|
||||||
|
def check_fc(self, command, args, expected):
|
||||||
|
os.environ['SPACK_TEST_COMMAND'] = command
|
||||||
|
self.assertEqual(self.fc(*args, output=str).strip(), expected)
|
||||||
|
|
||||||
|
|
||||||
def check_ld(self, command, args, expected):
|
def check_ld(self, command, args, expected):
|
||||||
os.environ['SPACK_TEST_COMMAND'] = command
|
os.environ['SPACK_TEST_COMMAND'] = command
|
||||||
self.assertEqual(self.ld(*args, output=str).strip(), expected)
|
self.assertEqual(self.ld(*args, output=str).strip(), expected)
|
||||||
@ -137,6 +151,64 @@ def test_ld_mode(self):
|
|||||||
self.check_ld('dump-mode', ['foo.o', 'bar.o', 'baz.o', '-o', 'foo', '-Wl,-rpath,foo'], "ld")
|
self.check_ld('dump-mode', ['foo.o', 'bar.o', 'baz.o', '-o', 'foo', '-Wl,-rpath,foo'], "ld")
|
||||||
|
|
||||||
|
|
||||||
|
def test_flags(self):
|
||||||
|
os.environ['SPACK_LDFLAGS'] = '-L foo'
|
||||||
|
os.environ['SPACK_LDLIBS'] = '-lfoo'
|
||||||
|
os.environ['SPACK_CPPFLAGS'] = '-g -O1'
|
||||||
|
os.environ['SPACK_CFLAGS'] = '-Wall'
|
||||||
|
os.environ['SPACK_CXXFLAGS'] = '-Werror'
|
||||||
|
os.environ['SPACK_FFLAGS'] = '-w'
|
||||||
|
|
||||||
|
# Test ldflags added properly in ld mode
|
||||||
|
self.check_ld('dump-args', test_command,
|
||||||
|
"ld " +
|
||||||
|
'-rpath ' + self.prefix + '/lib ' +
|
||||||
|
'-rpath ' + self.prefix + '/lib64 ' +
|
||||||
|
'-L foo ' +
|
||||||
|
' '.join(test_command) + ' ' +
|
||||||
|
'-lfoo')
|
||||||
|
|
||||||
|
# Test cppflags added properly in cpp mode
|
||||||
|
self.check_cpp('dump-args', test_command,
|
||||||
|
"cpp " +
|
||||||
|
'-g -O1 ' +
|
||||||
|
' '.join(test_command))
|
||||||
|
|
||||||
|
# Test ldflags, cppflags, and language specific flags are added in proper order
|
||||||
|
self.check_cc('dump-args', test_command,
|
||||||
|
self.realcc + ' ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib64 ' +
|
||||||
|
'-g -O1 ' +
|
||||||
|
'-Wall ' +
|
||||||
|
'-L foo ' +
|
||||||
|
' '.join(test_command) + ' ' +
|
||||||
|
'-lfoo')
|
||||||
|
|
||||||
|
self.check_cxx('dump-args', test_command,
|
||||||
|
self.realcc + ' ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib64 ' +
|
||||||
|
'-g -O1 ' +
|
||||||
|
'-Werror ' +
|
||||||
|
'-L foo ' +
|
||||||
|
' '.join(test_command) + ' ' +
|
||||||
|
'-lfoo')
|
||||||
|
|
||||||
|
self.check_fc('dump-args', test_command,
|
||||||
|
self.realcc + ' ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib ' +
|
||||||
|
'-Wl,-rpath,' + self.prefix + '/lib64 ' +
|
||||||
|
'-w ' +
|
||||||
|
'-g -O1 ' +
|
||||||
|
'-L foo ' +
|
||||||
|
' '.join(test_command) + ' ' +
|
||||||
|
'-lfoo')
|
||||||
|
|
||||||
|
os.environ['SPACK_LDFLAGS']=''
|
||||||
|
os.environ['SPACK_LDLIBS']=''
|
||||||
|
|
||||||
|
|
||||||
def test_dep_rpath(self):
|
def test_dep_rpath(self):
|
||||||
"""Ensure RPATHs for root package are added."""
|
"""Ensure RPATHs for root package are added."""
|
||||||
self.check_cc('dump-args', test_command,
|
self.check_cc('dump-args', test_command,
|
||||||
|
Loading…
Reference in New Issue
Block a user