Compare commits

..

2 Commits

Author SHA1 Message Date
Harmen Stoppels
4c2dae308a Fix typo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-06 13:08:51 +02:00
Harmen Stoppels
bb735478fe compiler-wrapper: respect -x and --language
To compile hip code, the clang++ is invoked with -x hip, so we should
derive the language from the -x flag.
2025-05-06 13:08:51 +02:00
4 changed files with 57 additions and 27 deletions

View File

@@ -216,16 +216,13 @@ def check_args_contents(cc, args, must_contain, must_not_contain):
assert a not in cc_modified_args
def check_env_var(executable, var, expected):
"""Check environment variables updated by the passed compiler wrapper
This assumes that cc will print debug output when it's environment
contains SPACK_TEST_COMMAND=dump-env-<variable-to-debug>
"""
executable = Executable(str(executable))
with set_env(SPACK_TEST_COMMAND="dump-env-" + var):
output = executable(*test_args, output=str).strip()
assert executable.path + ": " + var + ": " + expected == output
def check_wrapper_var(exe, *args, var, expected):
"""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."""
executable = Executable(str(exe))
with set_env(SPACK_TEST_COMMAND=f"dump-var-{var}"):
output = executable(*args, output=str).strip()
assert f"{executable.path}: {var}: {expected}" == output
def dump_mode(cc, args):
@@ -749,11 +746,22 @@ def test_system_path_cleanup(wrapper_environment, wrapper_dir):
"""
cc = wrapper_dir / "cc"
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):
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):
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):

View File

@@ -178,9 +178,10 @@ execute() {
unset IFS
exit
;;
dump-env-*)
var=${SPACK_TEST_COMMAND#dump-env-}
dump-var-*)
var=${SPACK_TEST_COMMAND#dump-var-}
eval "printf '%s\n' \"\$0: \$var: \$$var\""
exit
;;
*)
die "Unknown test command: '$SPACK_TEST_COMMAND'"
@@ -296,9 +297,36 @@ fi
# Note. SPACK_ALWAYS_XFLAGS are applied for all compiler invocations,
# including version checks (SPACK_XFLAGS variants are not applied
# for version checks).
command="${0##*/}"
command_from_argv0="${0##*/}"
command="$command_from_argv0"
comp="CC"
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
cpp)
mode=cpp

View File

@@ -43,7 +43,7 @@ class CompilerWrapper(Package):
if sys.platform != "win32":
version(
"1.0",
sha256="c65a9d2b2d4eef67ab5cb0684d706bb9f005bb2be94f53d82683d7055bdb837c",
sha256="db44e5898aa9b8605e3cfe53a51649b4df504066f0f13562432f584fc88a5038",
expand=False,
)
else:

View File

@@ -156,13 +156,7 @@ class Vtk(CMakePackage):
depends_on("libxt", when="^[virtuals=gl] glx platform=linux")
# VTK will need Qt5OpenGL, and qt needs '-opengl' for that
depends_on("qmake", when="@9.1: +qt")
with when("^[virtuals=qmake] qt-base"):
depends_on("qt-base+opengl+widgets")
depends_on("qt-quick3d")
with when("^[virtuals=qmake] qt"):
depends_on("qt+opengl")
depends_on("qt+opengl", when="@:9.0 +qt")
depends_on("qt+opengl", when="+qt")
depends_on("boost", when="+xdmf")
depends_on("boost+mpi", when="+xdmf +mpi")
@@ -386,8 +380,8 @@ def cmake_args(self):
cmake_args.extend(["-DCMAKE_MACOSX_RPATH=ON"])
if "+qt" in spec:
qt_ver = spec["qmake"].version.up_to(1)
qt_bin = spec["qmake"].prefix.bin
qt_ver = spec["qt"].version.up_to(1)
qt_bin = spec["qt"].prefix.bin
qmake_exe = os.path.join(qt_bin, "qmake")
# https://github.com/martijnkoopman/Qt-VTK-viewer/blob/master/doc/Build-VTK.md
@@ -412,7 +406,7 @@ def cmake_args(self):
# NOTE: The following definitions are required in order to allow
# VTK to build with qt~webkit versions (see the documentation for
# more info: http://www.vtk.org/Wiki/VTK/Tutorials/QtSetup).
if "~webkit" in spec["qmake"]:
if "~webkit" in spec["qt"]:
if spec.satisfies("@:8"):
cmake_args.extend(
[