diff options
author | Gregory Becker <becker33@llnl.gov> | 2016-05-11 14:56:41 -0700 |
---|---|---|
committer | Gregory Becker <becker33@llnl.gov> | 2016-05-11 14:56:41 -0700 |
commit | 566fec401521b32a0759977fc43116d8ef07b6fb (patch) | |
tree | bcbf88559433cef38f90a653c3c7d715d0e751d8 /lib | |
parent | 0b5836cfce4e701ec9487654fca0eabc905d9092 (diff) | |
download | spack-566fec401521b32a0759977fc43116d8ef07b6fb.tar.gz spack-566fec401521b32a0759977fc43116d8ef07b6fb.tar.bz2 spack-566fec401521b32a0759977fc43116d8ef07b6fb.tar.xz spack-566fec401521b32a0759977fc43116d8ef07b6fb.zip |
Fixed variants in new format and removed print statements from debugging
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/spack/env/cc | 27 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/cc.py | 72 |
3 files changed, 89 insertions, 12 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc index f3660272b8..0359dd8a11 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -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 diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index f94aa3ca4a..18dcc4a837 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -378,7 +378,7 @@ class VariantMap(HashableMap): _valid_compiler_flags = [ - 'cflags', 'cxxflags', 'fcflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags'] + 'cflags', 'cxxflags', 'fflags', 'ldflags', 'ldlibs', 'cppflags'] class FlagMap(HashableMap): def __init__(self, spec): diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py index 594cd6efe9..946d267c06 100644 --- a/lib/spack/spack/test/cc.py +++ b/lib/spack/spack/test/cc.py @@ -56,11 +56,16 @@ class CompilerTest(unittest.TestCase): 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 @@ class CompilerTest(unittest.TestCase): 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 @@ class CompilerTest(unittest.TestCase): 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, |