@@ -102,19 +102,32 @@ if [ "$(basename ${1})" = "cmake" ] && [ "${2}" = "-E" ] && [ "${3}" = "__run_co
102102 fi
103103fi
104104
105- # Handle ccache wrapper (the actual compiler is the next argument after ccache)
105+ # Known wrappers that may appear before the actual compiler
106+ KNOWN_WRAPPERS=(
107+ " resource_info.py" # TheRock build profiling
108+ " ccache" # Compiler cache
109+ )
110+
106111CCACHE_PREFIX=" "
107112ACTUAL_COMPILER=" ${1} "
108- if [ " $( basename ${1} ) " = " ccache" ]; then
109- if [ -z " ${2:- } " ]; then
110- echo -e " \nError: ${BASH_SOURCE[0]} detected 'ccache' as a compiler wrapper," >&2
111- echo " but no underlying compiler was specified as the next argument." >&2
112- echo " Usage: ccache <actual-compiler> [args...]" >&2
113- exit 1
113+ CURRENT_BASENAME=" $( basename " ${1} " ) "
114+
115+ for wrapper in " ${KNOWN_WRAPPERS[@]} " ; do
116+ if [[ " ${CURRENT_BASENAME} " == " ${wrapper} " ]]; then
117+ if [ -z " ${2:- } " ]; then
118+ echo -e " \nError: ${BASH_SOURCE[0]} detected '${wrapper} ' as a wrapper," >&2
119+ echo " but no underlying command was specified as the next argument." >&2
120+ exit 1
121+ fi
122+ # Preserve ccache so we can re-apply it to the rocprofiler-systems compiler
123+ if [[ " ${wrapper} " == " ccache" ]]; then
124+ CCACHE_PREFIX=" ${1} "
125+ fi
126+ shift
127+ ACTUAL_COMPILER=" ${1} "
128+ CURRENT_BASENAME=" $( basename " ${1} " ) "
114129 fi
115- CCACHE_PREFIX=" ${1} "
116- ACTUAL_COMPILER=" ${2} "
117- fi
130+ done
118131
119132if [[ " ${CXX_COMPILER} " != " ${ACTUAL_COMPILER} " ]]; then
120133 debug-message $@
@@ -127,12 +140,7 @@ else
127140 exit 1
128141 fi
129142
130- # discard ccache if present
131- if [ -n " ${CCACHE_PREFIX} " ]; then
132- shift
133- fi
134-
135- # discard the compiler from the command
143+ # discard the compiler from the command (wrappers were already shifted in the loop above)
136144 shift
137145
138146 if [ -n " $( basename ${ROCPROFSYS_COMPILER} | egrep ' amdclang|amdllvm' ) " ]; then
0 commit comments