gdb.rocm: replace hipcc with amdclang++ as the HIP compiler#62
gdb.rocm: replace hipcc with amdclang++ as the HIP compiler#62spatrang wants to merge 7 commits intoamd-stagingfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes the ROCm/HIP testsuite migration from hipcc to amdclang++ by updating compiler discovery, build flag handling, naming, and test/doc references to align with the current ROCm toolchain.
Changes:
- Switch HIP compiler discovery to
amdclang++(withHIP_COMPILER_FOR_TARGEToverride andHIPCC_FOR_TARGETfallback) and keep backward-compatible aliases. - Update HIP compilation/linking flags to correctly apply
-x hiponly when compiling sources and--hip-linkonly when producing executables. - Rename testsuite gating helpers (
allow_hipcc_tests→allow_hip_tests) and update testcases and documentation accordingly (with compatibility aliases retained).
Reviewed changes
Copilot reviewed 79 out of 79 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gdb/testsuite/lib/rocm.exp | Renames HIP gating proc to allow_hip_tests and keeps allow_hipcc_tests as a compatibility alias. |
| gdb/testsuite/lib/gdb.exp | Updates HIP compile/link flag handling for amdclang++ (-x hip / --hip-link) and related comments. |
| gdb/testsuite/lib/future.exp | Switches HIP compiler discovery to amdclang++, adds HIP_COMPILER_FOR_TARGET, and introduces new/compat proc names. |
| gdb/testsuite/gdb.rocm/watchpoint-basic.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/watchpoint-at-end-of-shader.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/watch-gpu-global-from-host.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/update-thread-list.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/until-tests.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/unaligned-memory-access.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/step-schedlock-spurious-waves.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/step-over-kernel-exit.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/static-global.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/simple.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/simple-outside-debugger.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/show-info.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/shared-memory.exp | Updates require gate to allow_hip_tests (and keeps python requirement). |
| gdb/testsuite/gdb.rocm/scheduler-locking.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/runtime-core.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/resume-exception.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/register-watchpoint.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/program-execution.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory-warning-watchpoint.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory-fork.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/precise-memory-exec.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/ocp_mx.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/nonstop-mode.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/nonstop-displaced.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/names.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/multi-inferior-run-spurious-waves.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/multi-inferior-fork.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/mi-lanes.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/mi-attach.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/mi-aspace.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/load-core-remote-system.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/line-breakpoint-in-kernel.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/lane-pc-vega20.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/lane-info.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/lane-execution.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/instruction-stepping-commands.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/info-sharedlibrary.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/info-dispatches.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/illegal-insn-sigill.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/hip-builtin-variables.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/hip-builtin-completions.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/generic-address.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/gcore-after-attach.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/finish.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/exec-bit-extract.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/displaced-stepping.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/disassemble.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/devicecode-breakpoint.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/device-interrupt.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/device-barrier.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/device-attach.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/detach-while-breakpoints-inserted.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/deref-scoped-pointer.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/deep-stack.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/debugtrap.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/corefile.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/core-no-read-special-files.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/convenience_variables.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/continue-over-kernel-exit.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/breakpoint-after-exit.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/break-kernel-no-debug-info.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/branch-fault.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/bit-extract.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/aspace-watchpoint.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/aspace-user-input.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/alu-exceptions.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.rocm/addr-bp-gpu-no-deb-info.exp | Updates require gate to allow_hip_tests. |
| gdb/testsuite/gdb.perf/rocm-break-cond-false.exp | Updates require gate to allow_hip_tests for the perf testcase. |
| gdb/testsuite/boards/hip.exp | Updates HIP board config to use find_hip_compiler, renames allow proc, and adjusts amdclang++ detection. |
| gdb/doc/gdb.texinfo | Updates documentation example command line to amdclang++ -x hip --hip-link .... |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
19d5312 to
3635e5f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 81 out of 81 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lumachad
left a comment
There was a problem hiding this comment.
Thanks! Looks mostly good to me. Made some comments about small adjustments.
lancesix
left a comment
There was a problem hiding this comment.
I only skimmed thought the patch at this point. Note that some of what you are touching comes from upstream, and we might want to land the changes there as well. I'd probably advise for having this changed upstream first, then we can import it into amd-staging.
|
I agree with upstreaming. We should keep the PR open for reviews and validation. Once we're happy with it, we can take it upstream, wait for approval and pick this up again, then close the PR. |
|
Another point is making sure this works on the Windows HIP SDK too. The compiler tool name and paths may be different there IIRC. The boards/hip.exp changes need to be tested with |
3635e5f to
f938e5f
Compare
f938e5f to
12dad2a
Compare
- Remove HIPCC_FOR_TARGET support entirely since hipcc is incompatible with the new -x hip / --hip-link flags added for amdclang++. - Stop skipping -fdiagnostics-color for HIP compilation since amdclang++ supports it, keeping escape sequences out of gdb.log. - Remove outdated comments that described hipcc-specific behavior no longer applicable to amdclang++. - Update unbuffered mode .o reordering comment to reflect that the workaround relies on the conditional -x hip logic in gdb_compile, not on file ordering.
Please make sure you test this. I tried it now with: $ make check RUNTESTFLAGS="--target_board=hip" TESTS="gdb.base/break.exp" and that fails with: Without your patch, it compiles OK. (It then fails for other unrelated reasons.) |
Fixed. The --target_board=hip path broke because amdclang++ (unlike hipcc) doesn't automatically discover the HIP headers -- it needs --rocm-path to locate them. Added --rocm-path=$rocm_path to the board's compilation flags, along with the -x hip / --hip-link split (compile vs link). Tested with make check RUNTESTFLAGS="--target_board=hip" TESTS="gdb.base/break.exp" -- compilation succeeds, zero hip_runtime.h errors. |
Unlike hipcc, amdclang++ doesn't auto-discover HIP headers, so the board failed to compile hip-test-wrapper.cc (hip/hip_runtime.h
@palves Loop over $source and recursively call gdb_compile to produce a .o for each source file (with -x hip, since they're sources) |
…nputs When gdb_compile links a HIP executable with unbuffered-mode support, it used to mix source files (.cpp/.c) and set_unbuffered_mode.o in a single amdclang++ invocation. With -x hip in early_flags, amdclang++ tried to parse the .o as HIP source and failed with expected
I'm confused. When running the normal gdb.rocm/ tests, I don't see "--rocm-path" passed to amdclang++. Why is it needed here, and not there? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 81 out of 81 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Bringing this up here. @amd-shahab was asking questions on finding llvm-dwarfdump on a CI system. I think we should take the opportunity to make the tools search order correct in these changes (or a separate patch if desired). See my previous comment here: #62 (comment). I think we should honor PATH first. Then if ROCM_PATH is set, we go look for tools there. Then if everything fails, we search some hardcoded /opt/rocm path. |
- Generalize the -x hip / .o mixing fix: pre-compile each source to its own .o at the top of gdb_compile, then recurse with an all-.o source list. Fixes "expected unqualified-id" errors when amdclang++ sees -x hip applied to .o inputs. - Pass --rocm-path explicitly in HIP flags (both lib/gdb.exp and boards/hip.exp) so amdclang++ can locate HIP headers/libs regardless of how it is invoked. - Drop -fdiagnostics-color skip for HIP; amdclang++ supports it. - Remove HIPCC_FOR_TARGET support; hipcc is incompatible with the new -x hip / --hip-link flags. - Fix stale comments and a spurious empty line.
ed95b99 to
dff4717
Compare
I agree we should look into this, though I'd prefer if any changes to the search path order was done in a separate patch. We have a little mess here, with search orders different for different tools. E.g., "${rocm_path}/llvm/bin/clang-offload-bundler" in rocm.exp (which now misses the leading lib/), Shahab's patch that searches PATH first, the searches for all the different tools lib/future.exp which search PATH last. |
Agreed. We need a separate change to clean this all up to use a single approach throughout. |
Use indexed temp filename for pre-compiled HIP .o to avoid basename collisions, and unify the set_unbuffered_mode handler to use the ldflags= path for HIP too.
Per PR review: /opt/rocm fallback is orthogonal to the migration and can override PATH; find_hipcc aliasing to amdclang++ would hide breakage since it isn't a drop-in for hipcc.
Motivation
The GDB testsuite was using hipcc for compiler discovery, naming conventions, and documentation examples, even though the underlying binary had already shifted to amdclang++. This PR completes the migration by replacing all hipcc references with amdclang++ throughout the testsuite infrastructure, documentation, and test files.
Technical Details
Compiler discovery and flags (lib/future.exp, lib/gdb.exp):
Compiler search now looks for amdclang++ in $ROCM_PATH/llvm/bin/ instead of hipcc in $ROCM_PATH/bin/.
Added HIP_COMPILER_FOR_TARGET as the primary env var override (HIPCC_FOR_TARGET still accepted as fallback).
Added conditional -x hip / --hip-link flags: -x hip is only passed when compiling source files (not when linking .o files, which would cause parse errors), and --hip-link is only passed when producing executables.
Naming renames (lib/rocm.exp, boards/hip.exp):
allow_hipcc_tests → allow_hip_tests
gdb_find_hipcc / find_hipcc → gdb_find_hip_compiler / find_hip_compiler
All old names preserved as backwards-compat aliases.
Documentation (gdb/doc/gdb.texinfo):
Example compilation command updated from hipcc -O0 -g ... to amdclang++ -x hip --hip-link -O0 -g ....
Test files (74 .exp files in gdb.rocm/ and gdb.perf/):