Compare commits
2 Commits
develop
...
hs/compile
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4c2dae308a | ||
![]() |
bb735478fe |
@ -216,16 +216,13 @@ def check_args_contents(cc, args, must_contain, must_not_contain):
|
|||||||
assert a not in cc_modified_args
|
assert a not in cc_modified_args
|
||||||
|
|
||||||
|
|
||||||
def check_env_var(executable, var, expected):
|
def check_wrapper_var(exe, *args, var, expected):
|
||||||
"""Check environment variables updated by the passed compiler wrapper
|
"""Check variables set by the compiler wrapper. This works by setting SPACK_TEST_COMMAND to
|
||||||
|
dump-var-<variable-to-debug>, which will print the variable and exit."""
|
||||||
This assumes that cc will print debug output when it's environment
|
executable = Executable(str(exe))
|
||||||
contains SPACK_TEST_COMMAND=dump-env-<variable-to-debug>
|
with set_env(SPACK_TEST_COMMAND=f"dump-var-{var}"):
|
||||||
"""
|
output = executable(*args, output=str).strip()
|
||||||
executable = Executable(str(executable))
|
assert f"{executable.path}: {var}: {expected}" == output
|
||||||
with set_env(SPACK_TEST_COMMAND="dump-env-" + var):
|
|
||||||
output = executable(*test_args, output=str).strip()
|
|
||||||
assert executable.path + ": " + var + ": " + expected == output
|
|
||||||
|
|
||||||
|
|
||||||
def dump_mode(cc, args):
|
def dump_mode(cc, args):
|
||||||
@ -749,11 +746,22 @@ def test_system_path_cleanup(wrapper_environment, wrapper_dir):
|
|||||||
"""
|
"""
|
||||||
cc = wrapper_dir / "cc"
|
cc = wrapper_dir / "cc"
|
||||||
system_path = "/bin:/usr/bin:/usr/local/bin"
|
system_path = "/bin:/usr/bin:/usr/local/bin"
|
||||||
with set_env(SPACK_COMPILER_WRAPPER_PATH=str(wrapper_dir), SPACK_CC="true"):
|
with set_env(SPACK_COMPILER_WRAPPER_PATH=str(wrapper_dir)):
|
||||||
with set_env(PATH=str(wrapper_dir) + ":" + system_path):
|
with set_env(PATH=str(wrapper_dir) + ":" + system_path):
|
||||||
check_env_var(cc, "PATH", system_path)
|
check_wrapper_var(cc, *test_args, var="PATH", expected=system_path)
|
||||||
with set_env(PATH=str(wrapper_dir) + "/:" + system_path):
|
with set_env(PATH=str(wrapper_dir) + "/:" + system_path):
|
||||||
check_env_var(cc, "PATH", system_path)
|
check_wrapper_var(cc, *test_args, var="PATH", expected=system_path)
|
||||||
|
|
||||||
|
|
||||||
|
def test_language_from_flags(wrapper_environment, wrapper_dir):
|
||||||
|
"""Test that the compiler language mode is determined by -x/--language flags if present"""
|
||||||
|
cc = wrapper_dir / "cc"
|
||||||
|
|
||||||
|
for flag_value, lang in [("c", "CC"), ("c++", "CXX"), ("f77", "F77"), ("f95", "FC")]:
|
||||||
|
check_wrapper_var(cc, "-c", "file", "-x", flag_value, var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", f"-x{flag_value}", var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", f"--language={flag_value}", var="comp", expected=lang)
|
||||||
|
check_wrapper_var(cc, "-c", "file", "--language", flag_value, var="comp", expected=lang)
|
||||||
|
|
||||||
|
|
||||||
def test_ld_deps_partial(wrapper_environment, wrapper_dir):
|
def test_ld_deps_partial(wrapper_environment, wrapper_dir):
|
||||||
|
@ -178,9 +178,10 @@ execute() {
|
|||||||
unset IFS
|
unset IFS
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
dump-env-*)
|
dump-var-*)
|
||||||
var=${SPACK_TEST_COMMAND#dump-env-}
|
var=${SPACK_TEST_COMMAND#dump-var-}
|
||||||
eval "printf '%s\n' \"\$0: \$var: \$$var\""
|
eval "printf '%s\n' \"\$0: \$var: \$$var\""
|
||||||
|
exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
die "Unknown test command: '$SPACK_TEST_COMMAND'"
|
die "Unknown test command: '$SPACK_TEST_COMMAND'"
|
||||||
@ -296,9 +297,36 @@ fi
|
|||||||
# Note. SPACK_ALWAYS_XFLAGS are applied for all compiler invocations,
|
# Note. SPACK_ALWAYS_XFLAGS are applied for all compiler invocations,
|
||||||
# including version checks (SPACK_XFLAGS variants are not applied
|
# including version checks (SPACK_XFLAGS variants are not applied
|
||||||
# for version checks).
|
# for version checks).
|
||||||
command="${0##*/}"
|
command_from_argv0="${0##*/}"
|
||||||
|
command="$command_from_argv0"
|
||||||
comp="CC"
|
comp="CC"
|
||||||
vcheck_flags=""
|
vcheck_flags=""
|
||||||
|
|
||||||
|
_command_from_flags() {
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
arg="$1"
|
||||||
|
shift
|
||||||
|
case "$arg" in
|
||||||
|
-x|--language)
|
||||||
|
_lang="$1"
|
||||||
|
shift ;;
|
||||||
|
-x*)
|
||||||
|
_lang="${arg#-x}" ;;
|
||||||
|
--language=*)
|
||||||
|
_lang="${arg#--language=}" ;;
|
||||||
|
*) continue ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$_lang" in
|
||||||
|
c) command=cc ;;
|
||||||
|
c++|f77|f95) command="$_lang" ;;
|
||||||
|
*) command="$command_from_argv0" ;; # drop unknown languages
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_command_from_flags "$@"
|
||||||
|
|
||||||
case "$command" in
|
case "$command" in
|
||||||
cpp)
|
cpp)
|
||||||
mode=cpp
|
mode=cpp
|
||||||
|
@ -43,7 +43,7 @@ class CompilerWrapper(Package):
|
|||||||
if sys.platform != "win32":
|
if sys.platform != "win32":
|
||||||
version(
|
version(
|
||||||
"1.0",
|
"1.0",
|
||||||
sha256="c65a9d2b2d4eef67ab5cb0684d706bb9f005bb2be94f53d82683d7055bdb837c",
|
sha256="db44e5898aa9b8605e3cfe53a51649b4df504066f0f13562432f584fc88a5038",
|
||||||
expand=False,
|
expand=False,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user