Skip to content

gdb.rocm: replace hipcc with amdclang++ as the HIP compiler#62

Merged
spatrang merged 1 commit into
amd-stagingfrom
users/spatrang/replace-hipcc-with-amdclang
Jun 19, 2026
Merged

gdb.rocm: replace hipcc with amdclang++ as the HIP compiler#62
spatrang merged 1 commit into
amd-stagingfrom
users/spatrang/replace-hipcc-with-amdclang

Conversation

@spatrang

@spatrang spatrang commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Motivation

The GDB testsuite uses hipcc for HIP compiler discovery, naming, and
documentation. hipcc is deprecated and will be removed at some point, so this
switches the testsuite over to amdclang++.

What changes

Compiler discovery (lib/future.exp)

  • Look for amdclang++ under $ROCM_PATH/lib/llvm/bin instead of hipcc.
  • Rename HIPCC_FOR_TARGET to HIP_COMPILER_FOR_TARGET (the environment
    override).
  • Rename gdb_find_hipcc / find_hipcc to gdb_find_hip_compiler /
    find_hip_compiler.

Compile and link flags (lib/gdb.exp, boards/hip.exp)

  • amdclang++ does not infer the input language from the file extension, so
    tag each input explicitly: -x hip before C/C++/HIP sources and -x none
    before object files/archives. A single invocation can then handle a mix of
    sources and objects (e.g. set_unbuffered_mode.o / hip-driver.o injected
    via ldflags).
  • Pass --hip-link only when producing an executable.
  • Pass --rocm-path only when ROCM_PATH is set; otherwise defer to
    amdclang++'s own HIP discovery.
  • Drop the explicit -O0 (amdclang++ already defaults to -O0).
  • amdclang++ is clang-based and accepts -fdiagnostics-color, so stop
    skipping it for HIP; this keeps color escape sequences out of gdb.log.

Testcases

  • Rename allow_hipcc_tests to allow_hip_tests in lib/rocm.exp,
    boards/hip.exp, and all gdb.rocm/ and gdb.perf/ testcases.
  • Replace hipcc's --genco with amdclang++'s --cuda-device-only in the
    two code-object tests (code-object-load-while-breakpoint-hit.exp,
    snapshot-objfile-on-load.exp).

Documentation (gdb/doc/gdb.texinfo)

  • Update the example compile command to amdclang++ -x hip --hip-link ...,
    keeping the note about the equivalent hipcc invocation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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++ (with HIP_COMPILER_FOR_TARGET override and HIPCC_FOR_TARGET fallback) and keep backward-compatible aliases.
  • Update HIP compilation/linking flags to correctly apply -x hip only when compiling sources and --hip-link only when producing executables.
  • Rename testsuite gating helpers (allow_hipcc_testsallow_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.

Comment thread gdb/testsuite/lib/future.exp Outdated
Comment thread gdb/testsuite/lib/rocm.exp Outdated
@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch from 19d5312 to 3635e5f Compare April 8, 2026 08:39
@spatrang spatrang requested a review from Copilot April 8, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread gdb/testsuite/lib/future.exp

@lumachad lumachad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Looks mostly good to me. Made some comments about small adjustments.

Comment thread gdb/doc/gdb.texinfo
Comment thread gdb/testsuite/boards/hip.exp Outdated
Comment thread gdb/testsuite/boards/hip.exp Outdated
Comment thread gdb/testsuite/boards/hip.exp Outdated
Comment thread gdb/testsuite/lib/future.exp Outdated
Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/rocm.exp Outdated

@lancesix lancesix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@lumachad

lumachad commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

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.

@palves

palves commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

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 --target_board=hip. A smoke test of running a few testcases like for example gdb.base/break.exp, instead of the full testsuite, is probably enough.

@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch 2 times, most recently from f938e5f to 12dad2a Compare April 9, 2026 12:34
@spatrang spatrang marked this pull request as ready for review April 16, 2026 12:00
@spatrang spatrang requested a review from a team as a code owner April 16, 2026 12:00
Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/future.exp Outdated
@palves

palves commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

The boards/hip.exp changes need to be tested with --target_board=hip. A smoke test of running a few testcases like for example gdb.base/break.exp, instead of the full testsuite, is probably enough.

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:

gdb compile failed, /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/lib/hip/hip-test-wrapper.cc:24:10: fatal error: 
      'hip/hip_runtime.h' file not found
   24 | #include <hip/hip_runtime.h>
      |          ^~~~~~~~~~~~~~~~~~~
1 error generated.

                === gdb Summary ===

# of untested testcases         1

Without your patch, it compiles OK. (It then fails for other unrelated reasons.)

@spatrang

Copy link
Copy Markdown
Contributor Author

The boards/hip.exp changes need to be tested with --target_board=hip. A smoke test of running a few testcases like for example gdb.base/break.exp, instead of the full testsuite, is probably enough.

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:

gdb compile failed, /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/lib/hip/hip-test-wrapper.cc:24:10: fatal error: 
      'hip/hip_runtime.h' file not found
   24 | #include <hip/hip_runtime.h>
      |          ^~~~~~~~~~~~~~~~~~~
1 error generated.

                === gdb Summary ===

# of untested testcases         1

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.

@spatrang

Copy link
Copy Markdown
Contributor Author

The boards/hip.exp changes need to be tested with --target_board=hip. A smoke test of running a few testcases like for example gdb.base/break.exp, instead of the full testsuite, is probably enough.

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:

gdb compile failed, /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/lib/hip/hip-test-wrapper.cc:24:10: fatal error: 
      'hip/hip_runtime.h' file not found
   24 | #include <hip/hip_runtime.h>
      |          ^~~~~~~~~~~~~~~~~~~
1 error generated.

                === gdb Summary ===

# of untested testcases         1

Without your patch, it compiles OK. (It then fails for other unrelated reasons.)

@palves
Implemented your suggestion -- for HIP, gdb_compile now pre-compiles each .cpp/.c source to its own .o before the final link step, mirroring the pattern boards/hip.exp already uses. In the unbuffered-mode handler, we now:

Loop over $source and recursively call gdb_compile to produce a .o for each source file (with -x hip, since they're sources)
Append set_unbuffered_mode.o to the now all-.o source list
Strip -x hip from early_flags for the final link (since we only have .o inputs)
Verified with your hack (if { 1 || ...): before the fix, set_unbuffered_mode-hip.o:1:1: error: expected unqualified-id reproduced exactly as you reported. After the fix, the final link becomes amdclang++ --hip-link -O0 ... device_enumerator.cpp.hip.o set_unbuffered_mode-hip.o ... -o device_enumerator.x (only .o inputs, no -x hip) and succeeds

Comment thread gdb/testsuite/lib/gdb.exp Outdated
@palves

palves commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

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.

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?

Comment thread gdb/testsuite/lib/gdb.exp Outdated
Comment thread gdb/testsuite/lib/gdb.exp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread gdb/testsuite/lib/future.exp
Comment thread gdb/testsuite/lib/gdb.exp Outdated
@lumachad

Copy link
Copy Markdown
Collaborator

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.

@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch from ed95b99 to dff4717 Compare April 23, 2026 08:39
Comment thread gdb/testsuite/lib/gdb.exp Outdated
@palves

palves commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

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.

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.

@spatrang spatrang assigned spatrang and palves and unassigned spatrang Jun 16, 2026
@palves

palves commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

I also removed the hipcc deprecation / equivalent-command block from gdb.texinfo

Well, I think that change went too far. I had only asked to remove the comments parts. hipcc still exists and is widely used by users, so I think that part of the manual should have stayed.

@palves

palves commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What is that "--genco" commit about? If you do fixup commits, please make sure to add some rationale in their commit logs. That was needed because of these two tests, I guess:

testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp: { debug hip additional_flags=--genco additional_flags=-DDEVICE } ] != "" } {
testsuite/gdb.rocm/snapshot-objfile-on-load.exp: { debug hip additional_flags=--genco } ] != "" } {

But why the mapping instead of just fixing the tests?

@palves palves assigned spatrang and unassigned palves Jun 16, 2026
@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch from 703913c to 69e9970 Compare June 18, 2026 12:49
@spatrang

Copy link
Copy Markdown
Contributor Author

Well, I think that change went too far. I had only asked to remove the comments parts. hipcc still exists and is widely used by users, so I think that part of the manual should have stayed.

Agreed, that was overreach on my part. I've restored the hipcc section in gdb.texinfo (the deprecation note plus the equivalent hipcc command); only the legacy-hipcc comparisons in code comments are dropped now.

What is that "--genco" commit about? If you do fixup commits, please make sure to add some rationale in their commit logs. [...] But why the mapping instead of just fixing the tests?

Good point on both counts. I've dropped the gdb_compile mapping and instead changed the two tests directly to use --cuda-device-only (the amdclang++ equivalent of hipcc's --genco):

  • gdb.rocm/code-object-load-while-breakpoint-hit.exp
  • gdb.rocm/snapshot-objfile-on-load.exp

I also folded everything back into the single commit (no more fixup commit), and the commit log now documents the --genco -> --cuda-device-only change.

@palves palves left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The patch itself LGTM now. Just a few comments on the commit log:

  • The first paragraph has a few nits to pick:

The GDB testsuite used hipcc for HIP compiler discovery, naming, and
documentation, even though the underlying compiler is amdclang++.
Complete the switch to amdclang++ throughout the testsuite.

"The GDB testsuite used hipcc" => "uses hipcc"

The "the underlying compiler is amdclang++" isn't what motivates this. The real reason is that hipcc is deprecated and is going away at some point.

And then "complete the switch" implies the switch had been started already. It hasn't, this patch starts and finishes it.

  • It doesn't mention the -fdiagnostics-color change in the "Compile and link flags" section. It should mention that amdclang++ is clang-based and accepts the flag.

  • "Add HIP_COMPILER_FOR_TARGET" is not strictly correct, it's more rename "HIPCC_FOR_TARGET to HIP_COMPILER_FOR_TARGET".

  • FYI, the PR text and the commit log are slightly out of sync, which is a bit confusing and made me wonder which one is up to date. Since with "squash and merge" the PR text doesn't make it to git (the git log history is the canonical one), then feel free to simplify the PR text to give the short intro and then say to look at the individual commit log for details. Alternatively, it's fine to have the info in both places, though I'd suggest using the gh tool to easily and automatically sync them.

@lancesix

Copy link
Copy Markdown
Collaborator

Sorry I have not had much time to look at this PR. I expect a fair amount of this can / should be upstream, right? Having this only downstream would cause some divergence we'll need to fix soon.

@palves

palves commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Sorry I have not had much time to look at this PR. I expect a fair amount of this can / should be upstream, right? Having this only downstream would cause some divergence we'll need to fix soon.

Agreed, you had already mentioned this earlier, even. :-)

One issue is that upstream does not have any of the Windows bits in the testsuite (which needed adjustment in this patch), and it has fewer tests to adjust. This is why I kept pushing for finishing up the patch downstream first.

I'd vote for landing the patch downstream first, and then also send it upstream shortly after. The upstream version will end up slightly simplified in some parts.

@lancesix

Copy link
Copy Markdown
Collaborator

Agreed, you had already mentioned this earlier, even. :-)

oups, forgot I already mentioned that 😅

I'd vote for landing the patch downstream first, and then also send it upstream shortly after. The upstream version will end up slightly simplified in some parts.

cool, works for me.

@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch from 69e9970 to 5d59915 Compare June 18, 2026 17:34
@spatrang

spatrang commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Just a few comments on the commit log

Thanks - addressed all of these in the latest force-push:

  • Reworded the opening paragraph: "uses hipcc", motivation is now that hipcc is deprecated and going away, and dropped "complete the switch" since this patch both starts and finishes it.
  • Added a note that amdclang++ is clang-based and accepts -fdiagnostics-color, so we no longer skip it for HIP (keeps color escapes out of gdb.log).
  • Reworded to "rename HIPCC_FOR_TARGET to HIP_COMPILER_FOR_TARGET" instead of "add".
  • Synced the PR description with the commit log.

@spatrang spatrang assigned palves and unassigned spatrang Jun 18, 2026

@palves palves left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, LGTM. Let's merge this (with rebase and merge).

Next step is upstreaming this. Let me/us know if you'd like to work on that.

@palves palves assigned spatrang and unassigned palves Jun 18, 2026
@lumachad

Copy link
Copy Markdown
Collaborator

Please don't merge. These tests are failing for both gcc and llvm:

2026-06-18 18:25:09,111 - INFO:        gdb.dwarf2/ada-thick-pointer.exp
2026-06-18 18:25:09,111 - INFO:        gdb.rocm/coop-group-grid-sync.exp

@lumachad

Copy link
Copy Markdown
Collaborator

For the group sync one...

ERROR: -------------------------------------------
ERROR: in testcase /__w/ROCgdb/ROCgdb/build/tests/rocgdb/gdb/testsuite/gdb.rocm/coop-group-grid-sync.exp
ERROR:  invalid command name "allow_hipcc_tests"
ERROR:  tcl error code TCL LOOKUP COMMAND allow_hipcc_tests
ERROR:  tcl error info:
invalid command name "allow_hipcc_tests"
    while executing
"::gdb_tcl_unknown allow_hipcc_tests"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::gdb_tcl_unknown $args"
    (procedure "::unknown" line 5)
    invoked from within
"allow_hipcc_tests"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 $fn"
    (procedure "require" line 11)
    invoked from within
"require allow_hipcc_tests"
    (file "/__w/ROCgdb/ROCgdb/build/tests/rocgdb/gdb/testsuite/gdb.rocm/coop-group-grid-sync.exp" line 34)
    invoked from within
"source /__w/ROCgdb/ROCgdb/build/tests/rocgdb/gdb/testsuite/gdb.rocm/coop-group-grid-sync.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /__w/ROCgdb/ROCgdb/build/tests/rocgdb/gdb/testsuite/gdb.rocm/coop-group-grid-sync.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name" msg"

@lumachad

Copy link
Copy Markdown
Collaborator

Don't think there's actually anything wrong with gdb.dwarf2/ada-thick-pointer.exp. It's just confusion from the CI script due to the group sync testcase errors trumpling over the gdb.dwarf2/ada-thick-pointer.exp testcase output.

The GDB testsuite uses hipcc for HIP compiler discovery, naming, and
documentation.  hipcc is deprecated and will be removed at some point,
so switch the testsuite over to amdclang++.

Compiler discovery (lib/future.exp):
- Look for amdclang++ under $ROCM_PATH/lib/llvm/bin instead of hipcc.
- Rename HIPCC_FOR_TARGET to HIP_COMPILER_FOR_TARGET (the environment
  override), and rename gdb_find_hipcc / find_hipcc to
  gdb_find_hip_compiler / find_hip_compiler.

Compile and link flags (lib/gdb.exp, boards/hip.exp):
- amdclang++ does not infer the input language from the file
  extension, so tag each input explicitly: "-x hip" before
  C/C++/HIP source files and "-x none" before object files,
  archives and other inputs.  This lets a single invocation handle a
  mix of sources and objects (e.g. set_unbuffered_mode.o and
  hip-driver.o injected via ldflags).
- Pass --hip-link when producing an executable.
- Pass --rocm-path only when ROCM_PATH is set in the environment;
  otherwise defer to amdclang++'s own HIP discovery.
- Drop the explicit -O0 from the HIP flags, since amdclang++ already
  defaults to -O0; an explicit "optimize" option still overrides it.
- amdclang++ is clang-based and accepts -fdiagnostics-color, so stop
  skipping that option for HIP; this keeps color escape sequences out
  of gdb.log.

Testcases:
- Rename allow_hipcc_tests to allow_hip_tests in lib/rocm.exp,
  boards/hip.exp and all gdb.rocm/ and gdb.perf/ testcases.
- Replace hipcc's --genco with amdclang++'s --cuda-device-only in
  gdb.rocm/code-object-load-while-breakpoint-hit.exp and
  gdb.rocm/snapshot-objfile-on-load.exp, which build a standalone
  device code object.

Documentation (gdb/doc/gdb.texinfo):
- Update the example compile command to
  "amdclang++ -x hip --hip-link ...", keeping the existing note about
  the equivalent hipcc invocation.
@spatrang spatrang force-pushed the users/spatrang/replace-hipcc-with-amdclang branch from 5d59915 to deab231 Compare June 19, 2026 10:15
@spatrang

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest amd-staging and force-pushed.

What changed since the last push:

  • Rebased onto current amd-staging, which pulled in the new gdb.rocm/coop-group-grid-sync.exp test (and the supports_cooperative_groups helper it needs).
  • Renamed that test's require allow_hipcc_tests to require allow_hip_tests, matching the rest of the testsuite. This was the actual cause of the red CI (invalid command name "allow_hipcc_tests"); gdb.dwarf2/ada-thick-pointer.exp was only collateral noise from that test's error trampling the log, so it clears too.

I built rocgdb from this branch and ran gdb.rocm/*.exp + gdb.dwarf2/*.exp via .github/scripts/test_rocgdb.py (GCC and LLVM) against that tree:

  • All gdb.rocm tests pass (incl. coop-group-grid-sync, hip-lang-detect, interrupt-twice, and the code-object tests).
  • The only remaining unexpected failures are in gdb.dwarf2 (debug-names-non-ascending-cu, macro-source-path, dw2-ranges). These are unrelated to this patch — it touches no gdb.dwarf2 or GDB source files — and reproduce on amd-staging independently.

@spatrang spatrang merged commit ec25f6f into amd-staging Jun 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants