Skip to content

Commit e2599b0

Browse files
[rocprofiler-systems] [TheRock] Handle ccache and
resource_info.py in launch-compiler script and fix a return bug (#2989) * Handle ccache and resource_info.py in launch-compiler script * Fix get_offload_extractor return bug Tested with workflows on TheRock [rocm-systems] ROCm/rocm-systems#2989 (commit 74614c3)
1 parent e64034f commit e2599b0

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

scripts/rocprof-sys-launch-compiler

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,32 @@ if [ "$(basename ${1})" = "cmake" ] && [ "${2}" = "-E" ] && [ "${3}" = "__run_co
102102
fi
103103
fi
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+
106111
CCACHE_PREFIX=""
107112
ACTUAL_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

119132
if [[ "${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

tests/pytest/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ def pytest_report_header(config) -> list[str]:
275275

276276
# Offload extractor
277277
offload_msg = None
278-
offload_extractor = get_offload_extractor(rocprof_config.rocm_path)
279-
if offload_extractor:
280-
tool_path, is_llvm_too_old = offload_extractor
278+
tool_path, is_llvm_too_old = get_offload_extractor(rocprof_config.rocm_path)
279+
if tool_path:
281280
if tool_path.name == "llvm-objdump":
282281
offload_msg = f"{tool_path}"
283282
elif tool_path.name == "roc-obj-ls":

0 commit comments

Comments
 (0)