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)
|
||||
command="$SPACK_FC"
|
||||
language="Fortran 90"
|
||||
lang_flags=FC
|
||||
lang_flags=F
|
||||
;;
|
||||
f77|gfortran|ifort|pgfortran|xlf|nagfor)
|
||||
command="$SPACK_F77"
|
||||
@ -184,13 +184,13 @@ args=("$@")
|
||||
|
||||
# Prepend cppflags, cflags, cxxflags, fcflags, fflags, and ldflags
|
||||
|
||||
# Add cppflags
|
||||
# Add ldflags
|
||||
case "$mode" in
|
||||
cppas|cc|ccld)
|
||||
args=(${SPACK_CPPFLAGS[@]} "${args[@]}") ;;
|
||||
ld|ccld)
|
||||
args=(${SPACK_LDFLAGS[@]} "${args[@]}") ;;
|
||||
esac
|
||||
|
||||
# Add compile flags.
|
||||
# Add compiler flags.
|
||||
case "$mode" in
|
||||
cc|ccld)
|
||||
# Add c, cxx, fc, and f flags
|
||||
@ -199,20 +199,25 @@ case "$mode" in
|
||||
args=(${SPACK_CFLAGS[@]} "${args[@]}") ;;
|
||||
CXX)
|
||||
args=(${SPACK_CXXFLAGS[@]} "${args[@]}") ;;
|
||||
FC)
|
||||
args=(${SPACK_FCFLAGS[@]} "${args[@]}") ;;
|
||||
F)
|
||||
args=(${SPACK_FFLAGS[@]} "${args[@]}") ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# Add ldflags
|
||||
# Add cppflags
|
||||
case "$mode" in
|
||||
ld|ccld)
|
||||
cpp|as|cc|ccld)
|
||||
args=(${SPACK_CPPFLAGS[@]} "${args[@]}") ;;
|
||||
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
|
||||
IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
|
||||
for dep in "${deps[@]}"; do
|
||||
|
@ -378,7 +378,7 @@ def __str__(self):
|
||||
|
||||
|
||||
_valid_compiler_flags = [
|
||||
'cflags', 'cxxflags', 'fcflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags']
|
||||
'cflags', 'cxxflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags']
|
||||
|
||||
class FlagMap(HashableMap):
|
||||
def __init__(self, spec):
|
||||
|
@ -56,11 +56,16 @@ def setUp(self):
|
||||
self.cc = Executable(join_path(spack.build_env_path, "cc"))
|
||||
self.ld = Executable(join_path(spack.build_env_path, "ld"))
|
||||
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.prefix = "/spack-test-prefix"
|
||||
|
||||
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_ENV_PATH']="test"
|
||||
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)
|
||||
|
||||
|
||||
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):
|
||||
os.environ['SPACK_TEST_COMMAND'] = command
|
||||
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")
|
||||
|
||||
|
||||
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):
|
||||
"""Ensure RPATHs for root package are added."""
|
||||
self.check_cc('dump-args', test_command,
|
||||
|
Loading…
Reference in New Issue
Block a user