From 25856ec80c87ead8d192aae2c7190292736d74e0 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Thu, 11 Jun 2026 15:47:15 -0700 Subject: [PATCH 01/31] init changes from spack-packages/4411 --- cc.sh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/cc.sh b/cc.sh index d0a6f90..e243828 100755 --- a/cc.sh +++ b/cc.sh @@ -298,9 +298,37 @@ mode="" vdep="" lang_flags="" debug_flags="" -command="${0##*/}" comp="CC" vcheck_flags="" + +command_from_argv0="${0##*/}" +command="$command_from_argv0" + +_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|hip) command="$_lang" ;; + *) command="$command_from_argv0" ;; # drop unknown languages + esac +} + +_command_from_flags "$@" + case "$command" in cpp) mode=cpp @@ -339,6 +367,14 @@ case "$command" in debug_flags="-g" vcheck_flags="${SPACK_ALWAYS_FFLAGS}" ;; + hip) + command="$SPACK_HIPCXX" + language="HIP" + comp="HIPCXX" + lang_flags=HIP + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_HIPCXXFLAGS}" + ;; ld|ld.gold|ld.lld) mode=ld if [ -z "$SPACK_CC_RPATH_ARG" ]; then From 080bdfba890edc1b4411f0fd4b9d33b87037d87f Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Thu, 11 Jun 2026 16:02:54 -0700 Subject: [PATCH 02/31] dispatch hipcc to SPACK_HIPCXX --- cc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc.sh b/cc.sh index e243828..532c271 100755 --- a/cc.sh +++ b/cc.sh @@ -367,7 +367,7 @@ case "$command" in debug_flags="-g" vcheck_flags="${SPACK_ALWAYS_FFLAGS}" ;; - hip) + hip|hipcc) command="$SPACK_HIPCXX" language="HIP" comp="HIPCXX" From 2b8ef4ef537cb2dece32f88d571b128220bd824a Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Fri, 12 Jun 2026 15:43:25 -0700 Subject: [PATCH 03/31] names that cmake won't reject --- cc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc.sh b/cc.sh index 532c271..2e5476a 100755 --- a/cc.sh +++ b/cc.sh @@ -367,7 +367,7 @@ case "$command" in debug_flags="-g" vcheck_flags="${SPACK_ALWAYS_FFLAGS}" ;; - hip|hipcc) + hip|spackhip|amdhip) command="$SPACK_HIPCXX" language="HIP" comp="HIPCXX" From d6cc6b2d3d45e966684c702ee28ecd2ff400b4c2 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Thu, 9 Jul 2026 16:49:03 -0700 Subject: [PATCH 04/31] amdhip identifier not used; language was swapped with vdep --- cc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc.sh b/cc.sh index 2e5476a..4f04ebe 100755 --- a/cc.sh +++ b/cc.sh @@ -367,9 +367,9 @@ case "$command" in debug_flags="-g" vcheck_flags="${SPACK_ALWAYS_FFLAGS}" ;; - hip|spackhip|amdhip) + hip|spackhip) command="$SPACK_HIPCXX" - language="HIP" + vdep="spack-hip" comp="HIPCXX" lang_flags=HIP debug_flags="-g" From ed41d0cf5eb27c2a5caf9c4862ab95bf93decaec Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 3 Aug 2026 15:44:39 -0700 Subject: [PATCH 05/31] handle hipflags (requires update in spack core to be useful, but does not break without that change) --- cc.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cc.sh b/cc.sh index 4f04ebe..ecef381 100755 --- a/cc.sh +++ b/cc.sh @@ -827,6 +827,10 @@ case "$mode" in extend spack_flags_list SPACK_CXXFLAGS preextend flags_list SPACK_TARGET_ARGS_CXX ;; + HIP) + extend spack_flags_list SPACK_ALWAYS_HIPFLAGS + extend spack_flags_list SPACK_HIPFLAGS + ;; F) preextend flags_list SPACK_TARGET_ARGS_FORTRAN ;; From a6860545148427501b670a8b7dac0d53f26702db Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 13:29:33 -0700 Subject: [PATCH 06/31] fix vdep --- cc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc.sh b/cc.sh index ecef381..4935047 100755 --- a/cc.sh +++ b/cc.sh @@ -369,7 +369,7 @@ case "$command" in ;; hip|spackhip) command="$SPACK_HIPCXX" - vdep="spack-hip" + vdep="hip-lang" comp="HIPCXX" lang_flags=HIP debug_flags="-g" From 6f5e2e4095beb25b54f1862cea116be86ea6624a Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 13:50:44 -0700 Subject: [PATCH 07/31] -x doesnt mean language for ld --- cc.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cc.sh b/cc.sh index 4935047..411ac75 100755 --- a/cc.sh +++ b/cc.sh @@ -305,6 +305,11 @@ command_from_argv0="${0##*/}" command="$command_from_argv0" _command_from_flags() { + # -x means "language" *except for* ld, so check if we are running + # ld and if so, we don't need to be looking for -x + case "$command_from_argv0" in + ld|ld.gold|ld.lld) return ;; + esac while [ $# -ne 0 ]; do arg="$1" shift From da7be1a85d25e691281a186cd18fdc46815154b8 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 18:28:59 -0700 Subject: [PATCH 08/31] test processing of -x and SPACK_HIPCXX dispatch based on -x and argv0 inference --- test/run.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/test/run.sh b/test/run.sh index 4e64a83..b1d3d89 100755 --- a/test/run.sh +++ b/test/run.sh @@ -25,7 +25,7 @@ fi WRAPPER_DIR=$(mktemp -d) -for name in cc c++ cpp fc ld; do +for name in cc c++ cpp fc ld spackhip; do ln -s "$CC_SH" "$WRAPPER_DIR/$name" done @@ -181,6 +181,7 @@ SPACK_SYSTEM_DIRS_VALUE='"/"|"//"|"/bin"|"/bin/"|"/bin64"|"/bin64/"|"/include"|" EXTRA_VARS=' SPACK_CPPFLAGS SPACK_CFLAGS SPACK_CXXFLAGS SPACK_FFLAGS SPACK_LDFLAGS SPACK_LDLIBS SPACK_ALWAYS_CPPFLAGS SPACK_ALWAYS_CFLAGS SPACK_ALWAYS_CXXFLAGS SPACK_ALWAYS_FFLAGS +SPACK_HIPFLAGS SPACK_ALWAYS_HIPFLAGS SPACK_ALWAYS_HIPCXXFLAGS SPACK_INCLUDE_DIRS SPACK_LINK_DIRS SPACK_RPATH_DIRS SPACK_STORE_INCLUDE_DIRS SPACK_STORE_LINK_DIRS SPACK_STORE_RPATH_DIRS SPACK_COMPILER_EXTRA_RPATHS SPACK_COMPILER_IMPLICIT_RPATHS @@ -195,6 +196,7 @@ wrapper_environment() { SPACK_CXX=$REAL_CC SPACK_FC=$REAL_CC SPACK_F77=$REAL_CC + SPACK_HIPCXX=$REAL_CC SPACK_PREFIX=/spack-test-prefix # shellcheck disable=SC2209 # literal string "test", not the command SPACK_COMPILER_WRAPPER_PATH=test @@ -207,6 +209,7 @@ wrapper_environment() { SPACK_CXX_RPATH_ARG='-Wl,-rpath,' SPACK_F77_RPATH_ARG='-Wl,-rpath,' SPACK_FC_RPATH_ARG='-Wl,-rpath,' + SPACK_HIPCXX_RPATH_ARG='-Wl,-rpath,' SPACK_TARGET_ARGS_CC='-march=znver2 -mtune=znver2' SPACK_TARGET_ARGS_CXX='-march=znver2 -mtune=znver2' SPACK_TARGET_ARGS_FORTRAN='-march=znver4 -mtune=znver4' @@ -214,18 +217,21 @@ wrapper_environment() { SPACK_CXX_LINKER_ARG='-Wl,' SPACK_FC_LINKER_ARG='-Wl,' SPACK_F77_LINKER_ARG='-Wl,' + SPACK_HIPCXX_LINKER_ARG='-Wl,' SPACK_DTAGS_TO_ADD='--disable-new-dtags' SPACK_DTAGS_TO_STRIP='--enable-new-dtags' SPACK_COMPILER_FLAGS_KEEP='' SPACK_COMPILER_FLAGS_REPLACE='-Werror*|' # shellcheck disable=SC2090 - export SPACK_CC SPACK_CXX SPACK_FC SPACK_F77 SPACK_PREFIX \ + export SPACK_CC SPACK_CXX SPACK_FC SPACK_F77 SPACK_HIPCXX SPACK_PREFIX \ SPACK_COMPILER_WRAPPER_PATH SPACK_DEBUG_LOG_DIR SPACK_DEBUG_LOG_ID \ SPACK_SHORT_SPEC SPACK_SYSTEM_DIRS SPACK_MANAGED_DIRS \ SPACK_CC_RPATH_ARG SPACK_CXX_RPATH_ARG SPACK_F77_RPATH_ARG SPACK_FC_RPATH_ARG \ + SPACK_HIPCXX_RPATH_ARG \ SPACK_TARGET_ARGS_CC SPACK_TARGET_ARGS_CXX SPACK_TARGET_ARGS_FORTRAN \ SPACK_CC_LINKER_ARG SPACK_CXX_LINKER_ARG SPACK_FC_LINKER_ARG SPACK_F77_LINKER_ARG \ + SPACK_HIPCXX_LINKER_ARG \ SPACK_DTAGS_TO_ADD SPACK_DTAGS_TO_STRIP \ SPACK_COMPILER_FLAGS_KEEP SPACK_COMPILER_FLAGS_REPLACE @@ -1309,6 +1315,65 @@ test_add_debug_flags_validation() { unset SPACK_ADD_DEBUG_FLAGS } +# --------------------------------------------------------------------------- +# HIP tests +# --------------------------------------------------------------------------- + +test_x_hip_language_detection() { + wrapper_environment + + # -x hip on a cc wrapper: mode follows the -c/-E/nothing rules as normal + expect_mode x_hip_ccld cc '-x +hip' ccld + expect_mode x_hip_cc cc '-x +hip +-c' cc + expect_mode x_hip_vcheck cc '-x +hip +--version' vcheck + + # SPACK_HIPFLAGS are injected; SPACK_CFLAGS are not + SPACK_HIPFLAGS='-hip-flag'; export SPACK_HIPFLAGS + SPACK_CFLAGS='-c-flag'; export SPACK_CFLAGS + _out=$(dump_args cc '-x +hip +foo.c') + expect_contains x_hip_hipflags_present "$_out" '-hip-flag' + expect_not_contains x_hip_cflags_absent "$_out" '-c-flag' + unset SPACK_HIPFLAGS SPACK_CFLAGS +} + +test_x_ignored_for_ld() { + wrapper_environment + + # -x has no language meaning for ld; it should be passed through as a plain arg + expect_mode x_hip_ld_mode ld '-x +hip +foo.o' ld + + _out=$(dump_args ld '-x +hip +foo.o') + expect_contains x_hip_ld_x_present "$_out" '-x' + expect_contains x_hip_ld_hip_present "$_out" 'hip' + # command must be ld, not SPACK_HIPCXX + _first=$(printf '%s\n' "$_out" | head -1) + if [ "$_first" != 'ld' ]; then + fail "x_ignored_for_ld: expected first arg 'ld', got '$_first'" + fi +} + +test_spackhip_argv0_modes() { + wrapper_environment + + # spackhip with no special flags => ccld + expect_mode spackhip_ccld spackhip '' ccld + # -c => compile only + expect_mode spackhip_cc spackhip '-c' cc + # version flags => vcheck + expect_mode spackhip_vcheck spackhip '--version' vcheck +} + # --------------------------------------------------------------------------- # Runner # --------------------------------------------------------------------------- @@ -1359,6 +1424,9 @@ test_spack_managed_dirs_are_prioritized test_frandom_seed_not_added_without_env test_frandom_seed_filters_args test_add_debug_flags_validation +test_x_hip_language_detection +test_x_ignored_for_ld +test_spackhip_argv0_modes ' all_tests="$wrapper_tests $list_ops_tests" From ce78199c511f7269529892f7a71bb6e5382b7a38 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 18:38:46 -0700 Subject: [PATCH 09/31] expand SPACK_xFLAGS test for hipflags --- test/run.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index b1d3d89..bf22336 100755 --- a/test/run.sh +++ b/test/run.sh @@ -251,9 +251,11 @@ wrapper_flags() { SPACK_CFLAGS='-Wall' SPACK_CXXFLAGS='-Werror' SPACK_FFLAGS='-w' + SPACK_HIPFLAGS='-fgpu-rdc' SPACK_LDFLAGS='-Wl,--gc-sections -L foo' SPACK_LDLIBS='-lfoo' - export SPACK_CPPFLAGS SPACK_CFLAGS SPACK_CXXFLAGS SPACK_FFLAGS SPACK_LDFLAGS SPACK_LDLIBS + export SPACK_CPPFLAGS SPACK_CFLAGS SPACK_CXXFLAGS SPACK_FFLAGS SPACK_HIPFLAGS \ + SPACK_LDFLAGS SPACK_LDLIBS } # ---------------- @@ -376,6 +378,7 @@ EOF SPACK_CFLAGS_LINES='-Wall' SPACK_FFLAGS_LINES='-w' +SPACK_HIPFLAGS_LINES='-fgpu-rdc' SPACK_LDLIBS_LINES='-lfoo' LHEADERPAD='-Wl,-headerpad_max_install_names' @@ -805,6 +808,13 @@ test_expected_args_with_flags() { "-Wl,--gc-sections" "$SPACK_LDLIBS_LINES") expect_args fc_flags fc "$TEST_ARGS" "$_exp" + # hip_flags (no target args; CPPFLAGS + HIPFLAGS applied; CFLAGS/CXXFLAGS absent) + _exp=$(concat "$REAL_CC" "$TEST_INCLUDE_PATHS" "-Lfoo" \ + "$TEST_LIBRARY_PATHS" "$DISABLE_NEW_DTAGS_WL" "$TEST_WL_RPATHS" \ + "$TEST_ARGS_NO_PATHS" "$SPACK_CPPFLAGS_LINES" "$SPACK_HIPFLAGS_LINES" \ + '-Wl,--gc-sections' "$SPACK_LDLIBS_LINES") + expect_args hip_flags spackhip "$TEST_ARGS" "$_exp" + # always_cflags SPACK_ALWAYS_CFLAGS='-always1 -always2'; export SPACK_ALWAYS_CFLAGS _args='-v From ba2491d42a14adad621b0abe0077e484dfe1d3ab Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 18:47:14 -0700 Subject: [PATCH 10/31] fold mode determination from flags for spackhip into existing test_modes --- test/run.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/test/run.sh b/test/run.sh index bf22336..210a745 100755 --- a/test/run.sh +++ b/test/run.sh @@ -470,6 +470,10 @@ baz.o -o foo -Wl,-rpath,foo' ld + + expect_mode spackhip_ccld spackhip '' ccld + expect_mode spackhip_cc spackhip '-c' cc + expect_mode spackhip_vcheck spackhip '--version' vcheck } test_expected_args() { @@ -1373,17 +1377,6 @@ foo.o') fi } -test_spackhip_argv0_modes() { - wrapper_environment - - # spackhip with no special flags => ccld - expect_mode spackhip_ccld spackhip '' ccld - # -c => compile only - expect_mode spackhip_cc spackhip '-c' cc - # version flags => vcheck - expect_mode spackhip_vcheck spackhip '--version' vcheck -} - # --------------------------------------------------------------------------- # Runner # --------------------------------------------------------------------------- @@ -1436,7 +1429,6 @@ test_frandom_seed_filters_args test_add_debug_flags_validation test_x_hip_language_detection test_x_ignored_for_ld -test_spackhip_argv0_modes ' all_tests="$wrapper_tests $list_ops_tests" From 2c165b1e8d86d990cd63e73d0859660cb67a8464 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 18:54:43 -0700 Subject: [PATCH 11/31] test routing of -x/spackhip to SPACK_HIPCXX --- test/run.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/run.sh b/test/run.sh index 210a745..6285579 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1333,6 +1333,24 @@ test_add_debug_flags_validation() { # HIP tests # --------------------------------------------------------------------------- +test_hip_command_routing() { + wrapper_environment + SPACK_HIPCXX=/bin/myhipcxx; export SPACK_HIPCXX + + # spackhip argv0 -> SPACK_HIPCXX, not SPACK_CC + _first=$(dump_args spackhip '' | head -1) + if [ "$_first" != '/bin/myhipcxx' ]; then + fail "spackhip_command: expected /bin/myhipcxx, got '$_first'" + fi + + # -x hip on cc wrapper -> SPACK_HIPCXX, not SPACK_CC + _first=$(dump_args cc '-x +hip' | head -1) + if [ "$_first" != '/bin/myhipcxx' ]; then + fail "x_hip_command: expected /bin/myhipcxx, got '$_first'" + fi +} + test_x_hip_language_detection() { wrapper_environment @@ -1427,6 +1445,7 @@ test_spack_managed_dirs_are_prioritized test_frandom_seed_not_added_without_env test_frandom_seed_filters_args test_add_debug_flags_validation +test_hip_command_routing test_x_hip_language_detection test_x_ignored_for_ld ' From a0f82a85f747b7c2ec73c25d7809bdf891b38b47 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 19:11:13 -0700 Subject: [PATCH 12/31] update no-dash-x processing for ld test --- test/run.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/run.sh b/test/run.sh index 6285579..a0f1ff8 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1378,17 +1378,14 @@ foo.c') test_x_ignored_for_ld() { wrapper_environment - # -x has no language meaning for ld; it should be passed through as a plain arg - expect_mode x_hip_ld_mode ld '-x -hip -foo.o' ld - + # For ld, -x means --discard-locals (a boolean flag with no value); a real ld + # invocation would not have -x hip. We use -x hip here specifically to verify + # that the wrapper does not treat -x as a language specifier when invoked as ld. _out=$(dump_args ld '-x hip foo.o') - expect_contains x_hip_ld_x_present "$_out" '-x' - expect_contains x_hip_ld_hip_present "$_out" 'hip' - # command must be ld, not SPACK_HIPCXX + expect_contains x_ld_x_present "$_out" '-x' + expect_contains x_ld_hip_present "$_out" 'hip' _first=$(printf '%s\n' "$_out" | head -1) if [ "$_first" != 'ld' ]; then fail "x_ignored_for_ld: expected first arg 'ld', got '$_first'" From efb910d03d9842c204f3b0a9eb5fedacea784bf5 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 19:16:46 -0700 Subject: [PATCH 13/31] rm redundant check --- test/run.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/run.sh b/test/run.sh index a0f1ff8..fa343f9 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1354,16 +1354,6 @@ hip' | head -1) test_x_hip_language_detection() { wrapper_environment - # -x hip on a cc wrapper: mode follows the -c/-E/nothing rules as normal - expect_mode x_hip_ccld cc '-x -hip' ccld - expect_mode x_hip_cc cc '-x -hip --c' cc - expect_mode x_hip_vcheck cc '-x -hip ---version' vcheck - # SPACK_HIPFLAGS are injected; SPACK_CFLAGS are not SPACK_HIPFLAGS='-hip-flag'; export SPACK_HIPFLAGS SPACK_CFLAGS='-c-flag'; export SPACK_CFLAGS From dfd1d740b35be5c83fd2b2711312c0bce8a0c6a5 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 19:23:51 -0700 Subject: [PATCH 14/31] another redundant test --- test/run.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/run.sh b/test/run.sh index fa343f9..820338a 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1351,19 +1351,6 @@ hip' | head -1) fi } -test_x_hip_language_detection() { - wrapper_environment - - # SPACK_HIPFLAGS are injected; SPACK_CFLAGS are not - SPACK_HIPFLAGS='-hip-flag'; export SPACK_HIPFLAGS - SPACK_CFLAGS='-c-flag'; export SPACK_CFLAGS - _out=$(dump_args cc '-x -hip -foo.c') - expect_contains x_hip_hipflags_present "$_out" '-hip-flag' - expect_not_contains x_hip_cflags_absent "$_out" '-c-flag' - unset SPACK_HIPFLAGS SPACK_CFLAGS -} test_x_ignored_for_ld() { wrapper_environment From 44e2dec74f23b0aed77d2559123892f21493fae1 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 19:25:18 -0700 Subject: [PATCH 15/31] bad test reference --- test/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index 820338a..c1b53d7 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1420,7 +1420,6 @@ test_frandom_seed_not_added_without_env test_frandom_seed_filters_args test_add_debug_flags_validation test_hip_command_routing -test_x_hip_language_detection test_x_ignored_for_ld ' From d8eafe4f47a2a850d0a71c0ab7d37f08c0443d31 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Mon, 17 Aug 2026 19:27:38 -0700 Subject: [PATCH 16/31] style --- test/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index c1b53d7..3fb677e 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1351,7 +1351,6 @@ hip' | head -1) fi } - test_x_ignored_for_ld() { wrapper_environment From af20c05289ecb279211cfc3240d604d38c052434 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 11:59:55 -0700 Subject: [PATCH 17/31] apply suggested commit from review (fix bug where -x messed with cpp; generate compiler error vs. dash error for malformed commands that leave language off of -x) Co-authored-by: Harmen Stoppels --- cc.sh | 114 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/cc.sh b/cc.sh index 411ac75..1dade0a 100755 --- a/cc.sh +++ b/cc.sh @@ -301,20 +301,19 @@ debug_flags="" comp="CC" vcheck_flags="" -command_from_argv0="${0##*/}" -command="$command_from_argv0" +command="${0##*/}" +# -x/--language overrides the language implied by argv0. Note that this is +# only applied for compiler drivers: for ld, -x means --discard-all, and for +# cpp, changing the language must not turn preprocessing into compilation. _command_from_flags() { - # -x means "language" *except for* ld, so check if we are running - # ld and if so, we don't need to be looking for -x - case "$command_from_argv0" in - ld|ld.gold|ld.lld) return ;; - esac + _lang="" while [ $# -ne 0 ]; do arg="$1" shift case "$arg" in -x|--language) + [ $# -ne 0 ] || break _lang="$1" shift ;; -x*) @@ -328,58 +327,11 @@ _command_from_flags() { case "$_lang" in c) command=cc ;; c++|f77|f95|hip) command="$_lang" ;; - *) command="$command_from_argv0" ;; # drop unknown languages + # anything else: keep the language implied by argv0 esac } -_command_from_flags "$@" - case "$command" in - cpp) - mode=cpp - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_CPPFLAGS}" - ;; - cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang|cl.exe|craycc) - command="$SPACK_CC" - vdep=c - comp="CC" - lang_flags=C - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_CFLAGS}" - ;; - c++|CC|g++|clang++|armclang++|icpc|icpx|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++|crayCC) - command="$SPACK_CXX" - vdep=cxx - comp="CXX" - lang_flags=CXX - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_CXXFLAGS}" - ;; - ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang|crayftn) - command="$SPACK_FC" - vdep=fortran - comp="FC" - lang_flags=F - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_FFLAGS}" - ;; - f77|xlf|xlf_r|pgf77) - command="$SPACK_F77" - vdep=fortran - comp="F77" - lang_flags=F - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_FFLAGS}" - ;; - hip|spackhip) - command="$SPACK_HIPCXX" - vdep="hip-lang" - comp="HIPCXX" - lang_flags=HIP - debug_flags="-g" - vcheck_flags="${SPACK_ALWAYS_HIPCXXFLAGS}" - ;; ld|ld.gold|ld.lld) mode=ld if [ -z "$SPACK_CC_RPATH_ARG" ]; then @@ -392,8 +344,58 @@ case "$command" in fi fi ;; + cpp) + mode=cpp + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_CPPFLAGS}" + ;; *) - die "Unknown compiler: $command" + _command_from_flags "$@" + case "$command" in + cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang|cl.exe|craycc) + command="$SPACK_CC" + vdep=c + comp="CC" + lang_flags=C + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_CFLAGS}" + ;; + c++|CC|g++|clang++|armclang++|icpc|icpx|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++|crayCC) + command="$SPACK_CXX" + vdep=cxx + comp="CXX" + lang_flags=CXX + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_CXXFLAGS}" + ;; + ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang|crayftn) + command="$SPACK_FC" + vdep=fortran + comp="FC" + lang_flags=F + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_FFLAGS}" + ;; + f77|xlf|xlf_r|pgf77) + command="$SPACK_F77" + vdep=fortran + comp="F77" + lang_flags=F + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_FFLAGS}" + ;; + hip|spackhip) + command="$SPACK_HIPCXX" + vdep="hip-lang" + comp="HIPCXX" + lang_flags=HIP + debug_flags="-g" + vcheck_flags="${SPACK_ALWAYS_HIPFLAGS}" + ;; + *) + die "Unknown compiler: $command" + ;; + esac ;; esac From 9746daccd7d5026cf849a5c3a17ff81f778273f0 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 13:43:59 -0700 Subject: [PATCH 18/31] Add recommended tests verbatim to start Co-authored-by: Harmen Stoppels --- test/run.sh | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index 3fb677e..c4d6986 100755 --- a/test/run.sh +++ b/test/run.sh @@ -25,7 +25,7 @@ fi WRAPPER_DIR=$(mktemp -d) -for name in cc c++ cpp fc ld spackhip; do +for name in cc c++ cpp fc ld ld.gold ld.lld spackhip; do ln -s "$CC_SH" "$WRAPPER_DIR/$name" done @@ -1368,6 +1368,150 @@ foo.o') fi } +# --------------------------------------------------------------------------- +# -x / --language handling +# --------------------------------------------------------------------------- + +# expect_command LABEL WRAPPER ARGS_STRING EXPECTED_ARGV0 +expect_command() { + _label="$1"; _wrapper="$2"; _args="$3"; _expected="$4" + _actual=$(dump_args "$_wrapper" "$_args" | head -1) + if [ "$_actual" != "$_expected" ]; then + fail "$_label: expected '$_expected', got '$_actual'" + fi +} + +test_x_language_spellings() { + wrapper_environment + SPACK_CXX=/bin/mycxx; SPACK_FC=/bin/myfc + SPACK_F77=/bin/myf77; SPACK_HIPCXX=/bin/myhipcxx + export SPACK_CXX SPACK_FC SPACK_F77 SPACK_HIPCXX + + # every spelling gcc and clang accept for the language selector + expect_command x_joined cc '-xc++ +foo.cc' /bin/mycxx + expect_command x_separate cc '-x +c++ +foo.cc' /bin/mycxx + expect_command x_long_eq cc '--language=c++ +foo.cc' /bin/mycxx + expect_command x_long_sep cc '--language +c++ +foo.cc' /bin/mycxx + + # every language in the map, from a wrapper of a different language + expect_command x_to_c c++ '-x +c +foo.c' "$REAL_CC" + expect_command x_to_f77 cc '-x +f77 +foo.f' /bin/myf77 + expect_command x_to_f95 cc '-x +f95 +foo.f90' /bin/myfc + expect_command x_to_hip cc '-xhip +foo.hip' /bin/myhipcxx + + # last -x wins + expect_command x_last_wins cc '-x +c++ +foo.cc +-x +c +bar.c' "$REAL_CC" +} + +test_x_non_language_values() { + wrapper_environment + + # -x* also matches flags that are not language selectors (Intel arch + # flags); unknown languages must fall back to the argv0 compiler. + expect_command x_intel_host cc '-xHost +foo.c' "$REAL_CC" + expect_command x_intel_avx cc '-xCORE-AVX2 +foo.c' "$REAL_CC" + expect_command x_none cc '-x +none +foo.c' "$REAL_CC" + expect_command x_asm_with_cpp cc '-x +assembler-with-cpp +foo.S' "$REAL_CC" +} + +test_x_without_value() { + wrapper_environment + SPACK_TEST_COMMAND=dump-args; export SPACK_TEST_COMMAND + + # a trailing -x/--language has no value to consume: the wrapper must not + # shift past the end of the argument list + for _flag in -x --language; do + _out=$("$WRAPPER_DIR/cc" -c foo.c "$_flag" 2>&1) + _rc=$? + if [ "$_rc" -ne 0 ]; then + fail "x_without_value: '$_flag' as last arg exited $_rc: $_out" + fi + done + unset SPACK_TEST_COMMAND +} + +test_x_is_not_a_language_for_cpp() { + wrapper_environment + + # cpp accepts -x, but selecting a language must not turn preprocessing + # into a compile+link of $SPACK_CC + expect_mode cpp_x_mode cpp '-x +c +foo.F90' cpp + expect_command cpp_x_cmd cpp '-x +c +foo.F90' cpp +} + +test_x_is_not_a_language_for_ld() { + wrapper_environment + + # for every linker we wrap, -x is --discard-all and takes no value + for _ld in ld ld.gold ld.lld; do + _out=$(dump_args "$_ld" '-x +hip +foo.o') + expect_contains "${_ld}_x_present" "$_out" '-x' + expect_contains "${_ld}_hip_present" "$_out" 'hip' + expect_command "${_ld}_command" "$_ld" '-x +hip +foo.o' "$_ld" + done +} + +test_hip_always_flags() { + wrapper_environment + SPACK_ALWAYS_HIPFLAGS='-always1 -always2'; export SPACK_ALWAYS_HIPFLAGS + + # applied on the compile line ... + _out=$(dump_args spackhip '-c +foo.hip') + expect_contains hip_always_compile_1 "$_out" '-always1' + expect_contains hip_always_compile_2 "$_out" '-always2' + + # ... and on version checks, like every other language + _args='-v +--cmd-line-v-opt' + _exp=$(concat "$REAL_CC" "-always1" "-always2" "-v" "--cmd-line-v-opt") + expect_args hip_always_vcheck spackhip "$_args" "$_exp" + + unset SPACK_ALWAYS_HIPFLAGS +} + +test_x_hip_vcheck() { + wrapper_environment + SPACK_HIPCXX=/bin/myhipcxx; export SPACK_HIPCXX + + expect_mode x_hip_vcheck_mode cc '-xhip +--version' vcheck + expect_command x_hip_vcheck_cmd cc '-xhip +--version' /bin/myhipcxx +} + # --------------------------------------------------------------------------- # Runner # --------------------------------------------------------------------------- @@ -1420,6 +1564,13 @@ test_frandom_seed_filters_args test_add_debug_flags_validation test_hip_command_routing test_x_ignored_for_ld +test_x_language_spellings +test_x_non_language_values +test_x_without_value +test_x_is_not_a_language_for_cpp +test_x_is_not_a_language_for_ld +test_hip_always_flags +test_x_hip_vcheck ' all_tests="$wrapper_tests $list_ops_tests" From 163437cf04e3a58d090a9f035fe2e377e04c1bb7 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 13:50:44 -0700 Subject: [PATCH 19/31] test_x_ignored_for_ld is covered by test_x_is_not_a_language_for_ld, and the latter tests more cases, so remove test_x_ignored_for_ld --- test/run.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/run.sh b/test/run.sh index c4d6986..6df8035 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1351,23 +1351,6 @@ hip' | head -1) fi } -test_x_ignored_for_ld() { - wrapper_environment - - # For ld, -x means --discard-locals (a boolean flag with no value); a real ld - # invocation would not have -x hip. We use -x hip here specifically to verify - # that the wrapper does not treat -x as a language specifier when invoked as ld. - _out=$(dump_args ld '-x -hip -foo.o') - expect_contains x_ld_x_present "$_out" '-x' - expect_contains x_ld_hip_present "$_out" 'hip' - _first=$(printf '%s\n' "$_out" | head -1) - if [ "$_first" != 'ld' ]; then - fail "x_ignored_for_ld: expected first arg 'ld', got '$_first'" - fi -} - # --------------------------------------------------------------------------- # -x / --language handling # --------------------------------------------------------------------------- @@ -1563,7 +1546,6 @@ test_frandom_seed_not_added_without_env test_frandom_seed_filters_args test_add_debug_flags_validation test_hip_command_routing -test_x_ignored_for_ld test_x_language_spellings test_x_non_language_values test_x_without_value From df7cf47daea548fab0422b125388ca01662219f3 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 14:08:09 -0700 Subject: [PATCH 20/31] rm -x case in test_hip_command_routing covered by test_x_language_spellings --- test/run.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/run.sh b/test/run.sh index 6df8035..4e7cd80 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1342,13 +1342,6 @@ test_hip_command_routing() { if [ "$_first" != '/bin/myhipcxx' ]; then fail "spackhip_command: expected /bin/myhipcxx, got '$_first'" fi - - # -x hip on cc wrapper -> SPACK_HIPCXX, not SPACK_CC - _first=$(dump_args cc '-x -hip' | head -1) - if [ "$_first" != '/bin/myhipcxx' ]; then - fail "x_hip_command: expected /bin/myhipcxx, got '$_first'" - fi } # --------------------------------------------------------------------------- From d8af366bf145438316fd4b350c7e689f3034c1b9 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 15:03:26 -0700 Subject: [PATCH 21/31] add comments about additional cases being covered --- test/run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/run.sh b/test/run.sh index 4e7cd80..d71659b 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1482,8 +1482,10 @@ test_x_hip_vcheck() { wrapper_environment SPACK_HIPCXX=/bin/myhipcxx; export SPACK_HIPCXX + # Make sure -xhip does not change the mode from vcheck expect_mode x_hip_vcheck_mode cc '-xhip --version' vcheck + # Make sure --version still chooses SPACK_HIPCXX when setting -xhip expect_command x_hip_vcheck_cmd cc '-xhip --version' /bin/myhipcxx } From da0d5eeb015c5dec8c517e1a75900fcbeffefe28 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 15:05:05 -0700 Subject: [PATCH 22/31] add test comment --- test/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index d71659b..5265e60 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1357,7 +1357,8 @@ expect_command() { fi } -test_x_language_spellings() { +test_x_language_dispatch() { + # Make sure -xlanguage dispatches to the appropriate underlying compiler wrapper_environment SPACK_CXX=/bin/mycxx; SPACK_FC=/bin/myfc SPACK_F77=/bin/myf77; SPACK_HIPCXX=/bin/myhipcxx From ba4e07d1ea733a0b35de8b1553c67f9de6d86c9f Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 15:22:14 -0700 Subject: [PATCH 23/31] move helper definition --- test/run.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/run.sh b/test/run.sh index 5265e60..2118767 100755 --- a/test/run.sh +++ b/test/run.sh @@ -129,6 +129,15 @@ expect_mode() { fi } +# expect_command LABEL WRAPPER ARGS_STRING EXPECTED_ARGV0 +expect_command() { + _label="$1"; _wrapper="$2"; _args="$3"; _expected="$4" + _actual=$(dump_args "$_wrapper" "$_args" | head -1) + if [ "$_actual" != "$_expected" ]; then + fail "$_label: expected '$_expected', got '$_actual'" + fi +} + # expect_contains LABEL ACTUAL NEEDLE -- line-wise membership expect_contains() { _label="$1"; _actual="$2"; _needle="$3" @@ -1348,15 +1357,6 @@ test_hip_command_routing() { # -x / --language handling # --------------------------------------------------------------------------- -# expect_command LABEL WRAPPER ARGS_STRING EXPECTED_ARGV0 -expect_command() { - _label="$1"; _wrapper="$2"; _args="$3"; _expected="$4" - _actual=$(dump_args "$_wrapper" "$_args" | head -1) - if [ "$_actual" != "$_expected" ]; then - fail "$_label: expected '$_expected', got '$_actual'" - fi -} - test_x_language_dispatch() { # Make sure -xlanguage dispatches to the appropriate underlying compiler wrapper_environment From ecd8480b88fbc370cc2f1d27aae336b08e34389b Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 17:27:06 -0700 Subject: [PATCH 24/31] rename test --- test/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run.sh b/test/run.sh index 2118767..f51e0d2 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1431,7 +1431,7 @@ test_x_without_value() { unset SPACK_TEST_COMMAND } -test_x_is_not_a_language_for_cpp() { +test_cpp_stays_cpp_with_x() { wrapper_environment # cpp accepts -x, but selecting a language must not turn preprocessing @@ -1545,7 +1545,7 @@ test_hip_command_routing test_x_language_spellings test_x_non_language_values test_x_without_value -test_x_is_not_a_language_for_cpp +test_cpp_stays_cpp_with_x test_x_is_not_a_language_for_ld test_hip_always_flags test_x_hip_vcheck From 3e2f803b9e65c952192710f46e52a658e74fc26d Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Tue, 1 Sep 2026 17:30:31 -0700 Subject: [PATCH 25/31] rm reference to SPACK_ALWAYS_HIPCXXFLAGS --- test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index f51e0d2..e11fb63 100755 --- a/test/run.sh +++ b/test/run.sh @@ -190,7 +190,7 @@ SPACK_SYSTEM_DIRS_VALUE='"/"|"//"|"/bin"|"/bin/"|"/bin64"|"/bin64/"|"/include"|" EXTRA_VARS=' SPACK_CPPFLAGS SPACK_CFLAGS SPACK_CXXFLAGS SPACK_FFLAGS SPACK_LDFLAGS SPACK_LDLIBS SPACK_ALWAYS_CPPFLAGS SPACK_ALWAYS_CFLAGS SPACK_ALWAYS_CXXFLAGS SPACK_ALWAYS_FFLAGS -SPACK_HIPFLAGS SPACK_ALWAYS_HIPFLAGS SPACK_ALWAYS_HIPCXXFLAGS +SPACK_HIPFLAGS SPACK_ALWAYS_HIPFLAGS SPACK_INCLUDE_DIRS SPACK_LINK_DIRS SPACK_RPATH_DIRS SPACK_STORE_INCLUDE_DIRS SPACK_STORE_LINK_DIRS SPACK_STORE_RPATH_DIRS SPACK_COMPILER_EXTRA_RPATHS SPACK_COMPILER_IMPLICIT_RPATHS From 4a1802185646c003576f989fdda035623fa30c8a Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 11:00:01 -0700 Subject: [PATCH 26/31] fix test reference error; add check for catching bad test references --- test/run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/run.sh b/test/run.sh index e11fb63..ff72275 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1542,7 +1542,7 @@ test_frandom_seed_not_added_without_env test_frandom_seed_filters_args test_add_debug_flags_validation test_hip_command_routing -test_x_language_spellings +test_x_language_dispatch test_x_non_language_values test_x_without_value test_cpp_stays_cpp_with_x @@ -1561,7 +1561,9 @@ fi for t in $tests_to_run; do start_test "$t" - if is_list_ops_test "$t"; then + if ! command -v "$t" >/dev/null 2>&1; then + fail "test function '$t' is not defined" + elif is_list_ops_test "$t"; then set +u; "$t"; set -u else "$t" From 6bf779c4e680510ee5fc6af9d976bd648bbb31c8 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 11:03:36 -0700 Subject: [PATCH 27/31] refactor test to use expect_command (was redoing work handled by that) --- test/run.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/run.sh b/test/run.sh index ff72275..5be9807 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1347,10 +1347,7 @@ test_hip_command_routing() { SPACK_HIPCXX=/bin/myhipcxx; export SPACK_HIPCXX # spackhip argv0 -> SPACK_HIPCXX, not SPACK_CC - _first=$(dump_args spackhip '' | head -1) - if [ "$_first" != '/bin/myhipcxx' ]; then - fail "spackhip_command: expected /bin/myhipcxx, got '$_first'" - fi + expect_command spackhip_command spackhip '' /bin/myhipcxx } # --------------------------------------------------------------------------- From 42d25248a4321e03b2cde42b37f66c05dceb8333 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 12:53:50 -0700 Subject: [PATCH 28/31] replace another custom test with expect_command --- test/run.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/test/run.sh b/test/run.sh index 5be9807..2afea60 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1414,18 +1414,15 @@ foo.S' "$REAL_CC" test_x_without_value() { wrapper_environment - SPACK_TEST_COMMAND=dump-args; export SPACK_TEST_COMMAND # a trailing -x/--language has no value to consume: the wrapper must not - # shift past the end of the argument list - for _flag in -x --language; do - _out=$("$WRAPPER_DIR/cc" -c foo.c "$_flag" 2>&1) - _rc=$? - if [ "$_rc" -ne 0 ]; then - fail "x_without_value: '$_flag' as last arg exited $_rc: $_out" - fi - done - unset SPACK_TEST_COMMAND + # shift past the end of the argument list, and falls back to argv0 + expect_command x_trailing cc '-c +foo.c +-x' "$REAL_CC" + expect_command language_trailing cc '-c +foo.c +--language' "$REAL_CC" } test_cpp_stays_cpp_with_x() { From e7aff18d6722e1e9eac437228930683622ca1f75 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 13:25:39 -0700 Subject: [PATCH 29/31] consolidate individual expect_contains/expect_command checks into single expect_args check --- test/run.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/run.sh b/test/run.sh index 2afea60..4af449d 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1441,16 +1441,12 @@ foo.F90' cpp test_x_is_not_a_language_for_ld() { wrapper_environment - # for every linker we wrap, -x is --discard-all and takes no value + # for every linker we wrap, -x is --discard-all and takes no value: it should + # not change the mode/command dispatched for _ld in ld ld.gold ld.lld; do - _out=$(dump_args "$_ld" '-x + expect_args "${_ld}_x" "$_ld" '-x hip -foo.o') - expect_contains "${_ld}_x_present" "$_out" '-x' - expect_contains "${_ld}_hip_present" "$_out" 'hip' - expect_command "${_ld}_command" "$_ld" '-x -hip -foo.o' "$_ld" +foo.o' "$(concat "$_ld" "$DISABLE_NEW_DTAGS" -x hip foo.o)" done } From f433c68db8d6a5a5fec30d8b07c1624438b5f17f Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 13:27:44 -0700 Subject: [PATCH 30/31] more-stringent arg order checking w/ expect_args --- test/run.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/run.sh b/test/run.sh index 4af449d..bb9c2ac 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1455,10 +1455,8 @@ test_hip_always_flags() { SPACK_ALWAYS_HIPFLAGS='-always1 -always2'; export SPACK_ALWAYS_HIPFLAGS # applied on the compile line ... - _out=$(dump_args spackhip '-c -foo.hip') - expect_contains hip_always_compile_1 "$_out" '-always1' - expect_contains hip_always_compile_2 "$_out" '-always2' + expect_args hip_always_compile spackhip '-c +foo.hip' "$(concat "$REAL_CC" -c foo.hip -always1 -always2)" # ... and on version checks, like every other language _args='-v From 1c07624d7f352939ad33c0ea3e37188b6f1388e5 Mon Sep 17 00:00:00 2001 From: Peter Josef Scheibel Date: Wed, 9 Sep 2026 13:47:24 -0700 Subject: [PATCH 31/31] replace explicit continue w/ comment (appears to match other logic better) --- cc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc.sh b/cc.sh index 1dade0a..5e28812 100755 --- a/cc.sh +++ b/cc.sh @@ -320,7 +320,7 @@ _command_from_flags() { _lang="${arg#-x}" ;; --language=*) _lang="${arg#--language=}" ;; - *) continue ;; + # we're only looking for lang args here: ignore everything else esac done