Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;

@haampie haampie Aug 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks ld ... -x on dash where you can't shift an empty argument list

$ man ld
...

       -x
       --discard-all
           Delete all local symbols.

Maybe run it only when wrapping a compiler?

-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
Expand Down Expand Up @@ -339,6 +367,14 @@ case "$command" in
debug_flags="-g"
vcheck_flags="${SPACK_ALWAYS_FFLAGS}"
;;
hip|spackhip)
command="$SPACK_HIPCXX"
vdep="spack-hip"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vdep="spack-hip"
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
Expand Down Expand Up @@ -791,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
;;
Expand Down