From: Lancelot SIX <Lancelot.Six@amd.com>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/hip: Prepare for DWARF-assembler-based HIP testcases
Date: Wed, 8 Jul 2026 18:53:44 +0100 [thread overview]
Message-ID: <bb054446-574d-4dc6-bff3-cfe8119ead48@amd.com> (raw)
In-Reply-To: <20260707111527.1211730-1-pedro@palves.net>
On 07/07/2026 12:15, Pedro Alves wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Compiling a testcase with debug info (by passing passing "debug" as
> gdb_compile option) has the effect of passing -g to the compiler. -g
> in turn enables an LLVM option that is essential for debugging:
> '-mllvm -amdgpu-spill-cfi-saved-regs'.
>
> That option affects code generation, and some features of the DWARF
> assembler machinery rely on code generated by the compiler without -g
> to be the exact same as the code generated with -g.
>
> This patch addresses that by always compiling with the LLVM option
> that -g would enable.
Hi Pedro,
That looks good to me.
This change lives in lib/gdb.exp, but really only applies when building
hip testcases. If you are happy for this to fall under the amdgpu
umbrella, then
Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Otherwise, you can change this to a Reviewed-by.
Best,
Lancelot.
>
> Change-Id: I64a938edf97c85d0ea9fc34b37071daa560de7e7
> ---
> gdb/testsuite/lib/gdb.exp | 32 ++++++++++++++++++++++++++++----
> 1 file changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index a19e8ba6729..a40c87c6727 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -6745,11 +6745,35 @@ proc gdb_compile {source dest type options} {
> lappend new_options "early_flags=-fno-stack-protector"
> }
>
> - # hipcc defaults to -O2, so add -O0 to early flags for the hip language.
> - # If "optimize" is also requested, another -O flag (e.g. -O2) will be added
> - # to the flags, overriding this -O0.
> if {[lsearch -exact $options hip] != -1} {
> - lappend new_options "early_flags=-O0"
> + # The -g option enables an LLVM option that is essential for
> + # debugging (-mllvm -amdgpu-spill-cfi-saved-regs), but that
> + # unfortunately also affects code generation. We don't want
> + # to hardcode -g here though, because some tests want to test
> + # debugging without debug info, and yet others want to compile
> + # their binary without debug info or with -gline-info-only,
> + # and then use the DWARF assembler to generate their own debug
> + # info. Some features of the DWARF assembler rely on nodebug
> + # and debug binaries having the exact same generated code, so,
> + # explicitly compile with the LLVM option that -g would
> + # enable, and leave adding -g to the testcase, via the "debug"
> + # option, as normal.
> + #
> + # Disable -Wunused-command-line-argument to avoid warnings
> + # like:
> + #
> + # clang: warning: argument unused during compilation: \
> + # '-mllvm=-amdgpu-spill-cfi-saved-regs' [-Wunused-command-line-argument]
> + #
> + # These happen when we're compiling an executable _and_ all
> + # the input files are .o files, like: hipcc foo.o -o foo ...
> + #
> + # HIPCC defaults to -O2, so add -O0 to early flags for the HIP
> + # language. If "optimize" is also requested, another -O flag
> + # (e.g. -O2) will be added to the flags, overriding this -O0.
> + lappend new_options "early_flags=-O0\
> + -mllvm=-amdgpu-spill-cfi-saved-regs\
> + -Wno-unused-command-line-argument"
> }
>
> # Because we link with libraries using their basename, we may need
>
> base-commit: 57d9dfcf39cd3c2897bb76c2dbd7074f065685df
> --
> 2.54.0
>
next prev parent reply other threads:[~2026-07-08 17:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 11:15 Pedro Alves
2026-07-08 17:53 ` Lancelot SIX [this message]
2026-07-09 14:02 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb054446-574d-4dc6-bff3-cfe8119ead48@amd.com \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox