* [PATCH] testsuite: Skip fission-dw-form-strx with clang
@ 2026-04-16 14:00 Bratislav Filipovic
2026-04-16 14:45 ` Guinevere Larsen
2026-04-16 15:19 ` Simon Marchi
0 siblings, 2 replies; 5+ messages in thread
From: Bratislav Filipovic @ 2026-04-16 14:00 UTC (permalink / raw)
To: gdb-patches; +Cc: Bratislav Filipovic
Clang's integrated assembler incorrectly sets the SHF_EXCLUDE flag
on .debug_*.dwo sections when assembling DWARF fission debug info.
This causes all linkers (both lld and GNU ld) to strip these
sections from the final output, breaking the test.
This is a limitation of clang's integrated assembler, not a GDB
issue. The test works correctly with GCC's assembler, which does
not set this flag.
A workaround exists (-fno-integrated-as to use GNU's external
assembler), but it is not practical to apply in the testsuite.
Therefore, restrict this test to GCC only.
---
I've investigated this thoroughly and found that clang's integrated
assembler hardcodes the SHF_EXCLUDE flag on .debug_*.dwo sections.
The only workaround I found is -fno-integrated-as, which forces clang
to use GNU's external assembler.
Does anyone have suggestions for making this test work with clang
without skipping it entirely? Or should we report this to LLVM as a bug?
gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
index b0b842fe911..fb39cab9c75 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
@@ -20,6 +20,13 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
+# This test requires GCC. Clang's integrated assembler incorrectly sets
+# the SHF_EXCLUDE flag on .debug_*.dwo sections, causing linkers to strip
+# them from the final output. This is a limitation of clang's integrated
+# assembler, not a GDB issue. The workaround (-fno-integrated-as) is not
+# practical for the testsuite.
+require {[test_compiler_info {gcc-*}]}
+
standard_testfile main.c -dw.S -dwo.S
set main_asm_file [standard_output_file $srcfile2]
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] testsuite: Skip fission-dw-form-strx with clang
2026-04-16 14:00 [PATCH] testsuite: Skip fission-dw-form-strx with clang Bratislav Filipovic
@ 2026-04-16 14:45 ` Guinevere Larsen
2026-04-16 15:19 ` Simon Marchi
1 sibling, 0 replies; 5+ messages in thread
From: Guinevere Larsen @ 2026-04-16 14:45 UTC (permalink / raw)
To: Bratislav Filipovic, gdb-patches
On 4/16/26 11:00 AM, Bratislav Filipovic wrote:
> Clang's integrated assembler incorrectly sets the SHF_EXCLUDE flag
> on .debug_*.dwo sections when assembling DWARF fission debug info.
> This causes all linkers (both lld and GNU ld) to strip these
> sections from the final output, breaking the test.
>
> This is a limitation of clang's integrated assembler, not a GDB
> issue. The test works correctly with GCC's assembler, which does
> not set this flag.
>
> A workaround exists (-fno-integrated-as to use GNU's external
> assembler), but it is not practical to apply in the testsuite.
> Therefore, restrict this test to GCC only.
> ---
>
> I've investigated this thoroughly and found that clang's integrated
> assembler hardcodes the SHF_EXCLUDE flag on .debug_*.dwo sections.
> The only workaround I found is -fno-integrated-as, which forces clang
> to use GNU's external assembler.
>
> Does anyone have suggestions for making this test work with clang
> without skipping it entirely? Or should we report this to LLVM as a bug?
My approach for these kinds of things in the past was to open a bug with
LLVM and mark the tests as XFAIL in our testsuite (at least if the rest
of the test still make sense to run)
>
> gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
> index b0b842fe911..fb39cab9c75 100644
> --- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
> +++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
> @@ -20,6 +20,13 @@ load_lib dwarf.exp
> # This test can only be run on targets which support DWARF-2 and use gas.
> require dwarf2_support
>
> +# This test requires GCC. Clang's integrated assembler incorrectly sets
> +# the SHF_EXCLUDE flag on .debug_*.dwo sections, causing linkers to strip
> +# them from the final output. This is a limitation of clang's integrated
> +# assembler, not a GDB issue. The workaround (-fno-integrated-as) is not
> +# practical for the testsuite.
> +require {[test_compiler_info {gcc-*}]}
> +
> standard_testfile main.c -dw.S -dwo.S
>
> set main_asm_file [standard_output_file $srcfile2]
--
Cheers,
Guinevere Larsen
It/she
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] testsuite: Skip fission-dw-form-strx with clang
2026-04-16 14:00 [PATCH] testsuite: Skip fission-dw-form-strx with clang Bratislav Filipovic
2026-04-16 14:45 ` Guinevere Larsen
@ 2026-04-16 15:19 ` Simon Marchi
2026-04-23 10:37 ` [PATCH] gdb.dwarf2: Fix fission-dw-form-strx.exp workflow Bratislav Filipovic
1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2026-04-16 15:19 UTC (permalink / raw)
To: Bratislav Filipovic, gdb-patches
On 4/16/26 10:00 AM, Bratislav Filipovic wrote:
> Clang's integrated assembler incorrectly sets the SHF_EXCLUDE flag
> on .debug_*.dwo sections when assembling DWARF fission debug info.
> This causes all linkers (both lld and GNU ld) to strip these
> sections from the final output, breaking the test.
>
> This is a limitation of clang's integrated assembler, not a GDB
> issue. The test works correctly with GCC's assembler, which does
> not set this flag.
>
> A workaround exists (-fno-integrated-as to use GNU's external
> assembler), but it is not practical to apply in the testsuite.
> Therefore, restrict this test to GCC only.
> ---
>
> I've investigated this thoroughly and found that clang's integrated
> assembler hardcodes the SHF_EXCLUDE flag on .debug_*.dwo sections.
> The only workaround I found is -fno-integrated-as, which forces clang
> to use GNU's external assembler.
>
> Does anyone have suggestions for making this test work with clang
> without skipping it entirely? Or should we report this to LLVM as a bug?
Can you explain what is the sequence of compiling / linking steps in
this test? Normally, I think that .dwo sections are not meant to go
through a linker. This is how gcc works:
- cc1 compiler produces a .o file containing .dwo sections
- objcopy extracts the .dwo sections to a .dwo file using --extract-dwo
- objcopy strips the .dwo sections from the .o file using --strip-dwo
- linker links the final executable from the .o files, without the .dwo
sections
I don't know how clang operates, but it seems fine for the .dwo sections
to have SHF_EXCLUDE: if they are still present at the link step, we
don't want them to end up in the final executable.
If we see that in this test the .dwo sections go through the linker and
get discarded, it might be the test that is doing things wrong.
See the commit log here for example:
https://gitlab.com/gnutools/binutils-gdb/-/commit/6a29913eeb98595b76a7c5a3b3c2c4464c7c1484
In this commit, I fixed a test (that I had written myself initially,
before understanding the .dwo flow I described above) that was running
the .dwo sections through the linker, and that was causing other
problems.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] gdb.dwarf2: Fix fission-dw-form-strx.exp workflow
2026-04-16 15:19 ` Simon Marchi
@ 2026-04-23 10:37 ` Bratislav Filipovic
2026-04-23 14:36 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Bratislav Filipovic @ 2026-04-23 10:37 UTC (permalink / raw)
To: simark; +Cc: bfilipov, gdb-patches
The test was using gdb_compile_shlib to create the .dwo file, which
runs the linker. This is incorrect for DWARF fission - .dwo files
should be created by objcopy extraction, not linking.
Per commit 6a29913eeb9, "it was a bad idea to generate a .dwo file
using the linker, since the idea behind .dwo files is that they do
not need to be linked."
GCC's assembler doesn't set the SHF_EXCLUDE flag on .debug_*.dwo
sections, so the linker preserves them in the output. Clang's
assembler sets SHF_EXCLUDE, causing the linker to exclude these
sections. Both approaches are valid, but only the GCC approach
happens to work with this test's incorrect use of the linker.
Rewrite the test to use build_executable_and_dwo_files with the
split-dwo option, matching all other fission-*.exp tests. This uses
objcopy to properly extract .dwo sections without involving the
linker.
Changes:
- Use build_executable_and_dwo_files instead of gdb_compile_shlib
- Generate both skeleton and DWO CUs in single Dwarf::assemble block
- Add debug_str_offsets section for DW_FORM_strx support
- Add is_remote host check (required for objcopy-based workflow)
- Fix DW_AT_dwo_name to match generated filename
Tested: GCC 13.3.0, Clang-23 (passes)
---
Thanks for the feedback Simon, I've rewritten the test to be more like
the one that you sent to me in your last reply. Also I used
DW_FORM_strx instead of it's DW_FORM_strx_id alias.
Regards Bratislav
.../gdb.dwarf2/fission-dw-form-strx.exp | 56 +++++++++----------
1 file changed, 27 insertions(+), 29 deletions(-)
diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
index b0b842fe911..313e4eafe76 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
@@ -17,30 +17,26 @@
load_lib dwarf.exp
+# We run objcopy locally to split out the .dwo file.
+if [is_remote host] {
+ return 0
+}
+
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
-standard_testfile main.c -dw.S -dwo.S
+standard_testfile main.c -dw.S
-set main_asm_file [standard_output_file $srcfile2]
-set dwo_asm_file [standard_output_file $srcfile3]
+set asm_file [standard_output_file $srcfile2]
-# Debug info in the main file.
-Dwarf::assemble $main_asm_file {
- cu {
- version 5
- dwo_id 0xF00D
- } {
- compile_unit {
- DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp
- } {}
- }
-}
+# Generate DWARF assembly with both skeleton and DWO sections.
+Dwarf::assemble $asm_file {
+ global srcfile testfile
-# Debug info in the DWO file.
-Dwarf::assemble $dwo_asm_file {
+ # String offsets table for DWO.
debug_str_offsets { dwo 1 } int
+ # The information that will be split out into the .dwo file.
cu {
fission 1
version 5
@@ -65,22 +61,24 @@ Dwarf::assemble $dwo_asm_file {
}
}
}
-}
-
-# Build main file.
-if { [build_executable "${testfile}.exp" $binfile \
- [list ${srcfile} ${main_asm_file}] {nodebug}] } {
- return
-}
-# Build DWO file.
-set dwo_file [standard_output_file ${testfile}.dwo]
-if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } {
- return
+ # The skeleton information that will remain in the .o file.
+ cu {
+ version 5
+ dwo_id 0xF00D
+ } {
+ compile_unit {
+ DW_AT_dwo_name ${testfile}-dw.dwo DW_FORM_strp
+ } {}
+ }
}
-if { [is_remote host] } {
- gdb_remote_download host $dwo_file
+# Build the executable and extract the .dwo file using objcopy.
+set obj [standard_output_file "${testfile}-dw.o"]
+if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
+ [list $asm_file [list nodebug split-dwo] $obj] \
+ [list $srcfile [list nodebug]]] {
+ return -1
}
clean_restart $::testfile
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gdb.dwarf2: Fix fission-dw-form-strx.exp workflow
2026-04-23 10:37 ` [PATCH] gdb.dwarf2: Fix fission-dw-form-strx.exp workflow Bratislav Filipovic
@ 2026-04-23 14:36 ` Simon Marchi
0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2026-04-23 14:36 UTC (permalink / raw)
To: Bratislav Filipovic; +Cc: gdb-patches
On 4/23/26 6:37 AM, Bratislav Filipovic wrote:
> The test was using gdb_compile_shlib to create the .dwo file, which
> runs the linker. This is incorrect for DWARF fission - .dwo files
> should be created by objcopy extraction, not linking.
>
> Per commit 6a29913eeb9, "it was a bad idea to generate a .dwo file
> using the linker, since the idea behind .dwo files is that they do
> not need to be linked."
>
> GCC's assembler doesn't set the SHF_EXCLUDE flag on .debug_*.dwo
> sections, so the linker preserves them in the output. Clang's
> assembler sets SHF_EXCLUDE, causing the linker to exclude these
> sections. Both approaches are valid, but only the GCC approach
> happens to work with this test's incorrect use of the linker.
>
> Rewrite the test to use build_executable_and_dwo_files with the
> split-dwo option, matching all other fission-*.exp tests. This uses
> objcopy to properly extract .dwo sections without involving the
> linker.
>
> Changes:
> - Use build_executable_and_dwo_files instead of gdb_compile_shlib
> - Generate both skeleton and DWO CUs in single Dwarf::assemble block
> - Add debug_str_offsets section for DW_FORM_strx support
> - Add is_remote host check (required for objcopy-based workflow)
> - Fix DW_AT_dwo_name to match generated filename
>
> Tested: GCC 13.3.0, Clang-23 (passes)
Thanks, that LGTM.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Just a nit: when sending a version 2 of a patch or patch series, pass
`-v2` to git-send-email to make it add "v2" in the subject prefix.
However, it seems that you used --in-reply-to to keep the new patch in
the same thread as the original on, that is very nice and thoughtful,
thank you.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-23 14:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-16 14:00 [PATCH] testsuite: Skip fission-dw-form-strx with clang Bratislav Filipovic
2026-04-16 14:45 ` Guinevere Larsen
2026-04-16 15:19 ` Simon Marchi
2026-04-23 10:37 ` [PATCH] gdb.dwarf2: Fix fission-dw-form-strx.exp workflow Bratislav Filipovic
2026-04-23 14:36 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox