* [PATCH] tests: fix for toolchains producing compressed debug sections
@ 2021-03-22 20:00 Dmitry V. Levin
2021-03-23 14:20 ` Mark Wielaard
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry V. Levin @ 2021-03-22 20:00 UTC (permalink / raw)
To: debugedit; +Cc: Vitaly Chikunov
When toolchain produces compressed debug sections by default,
quite a few debugedit tests fail because of unexpected
"debugedit: ./foo.o: DWARF version 0 unhandled" error diagnostic messages:
3: debugedit .debug_str objects DWARF4 FAILED (debugedit.at:97)
4: debugedit .debug_str/line_str objects DWARF5 FAILED (debugedit.at:129)
9: debugedit .debug_info objects FAILED (debugedit.at:291)
12: debugedit .debug_types objects FAILED (debugedit.at:370)
15: debugedit .debug_line objects DWARF4 FAILED (debugedit.at:460)
16: debugedit .debug_line objects DWARF5 FAILED (debugedit.at:484)
21: debugedit .debug_macro objects FAILED (debugedit.at:598)
Fix this by instructing gcc not to produce compressed debug sections
in object files prepared for debugedit tests.
* tests/debugedit.at: Add "-gz=none" to "gcc -g3" invocations.
Co-authored-by: Vitaly Chikunov <vt@altlinux.org>
---
tests/debugedit.at | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index fb55574..2d1870b 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -37,11 +37,11 @@ cp "${abs_srcdir}"/data/SOURCES/foobar.h subdir_headers
cp "${abs_srcdir}"/data/SOURCES/baz.c .
# First three object files (foo.o subdir_bar/bar.o and baz.o)
-gcc -g3 -Isubdir_headers $1 -c subdir_foo/foo.c
+gcc -g3 -gz=none -Isubdir_headers $1 -c subdir_foo/foo.c
cd subdir_bar
-gcc -g3 -I../subdir_headers $1 -c bar.c
+gcc -g3 -gz=none -I../subdir_headers $1 -c bar.c
cd ..
-gcc -g3 -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
+gcc -g3 -gz=none -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
# Then a partially linked object file (somewhat like a kernel module).
# This will still have relocations between the debug sections.
@@ -49,7 +49,7 @@ ld -r -o foobarbaz.part.o foo.o subdir_bar/bar.o baz.o
# Create an executable. Relocations between debug sections will
# have been resolved.
-gcc -g3 -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
+gcc -g3 -gz=none -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
]])
# ===
--
ldv
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-22 20:00 [PATCH] tests: fix for toolchains producing compressed debug sections Dmitry V. Levin
@ 2021-03-23 14:20 ` Mark Wielaard
2021-03-23 14:28 ` Dmitry V. Levin
0 siblings, 1 reply; 8+ messages in thread
From: Mark Wielaard @ 2021-03-23 14:20 UTC (permalink / raw)
To: Dmitry V. Levin, debugedit; +Cc: Vitaly Chikunov
Hi Dmitry,
On Mon, 2021-03-22 at 20:00 +0000, Dmitry V. Levin wrote:
> When toolchain produces compressed debug sections by default,
> quite a few debugedit tests fail because of unexpected
> "debugedit: ./foo.o: DWARF version 0 unhandled" error diagnostic messages:
> 3: debugedit .debug_str objects DWARF4 FAILED (debugedit.at:97)
> 4: debugedit .debug_str/line_str objects DWARF5 FAILED (debugedit.at:129)
> 9: debugedit .debug_info objects FAILED (debugedit.at:291)
> 12: debugedit .debug_types objects FAILED (debugedit.at:370)
> 15: debugedit .debug_line objects DWARF4 FAILED (debugedit.at:460)
> 16: debugedit .debug_line objects DWARF5 FAILED (debugedit.at:484)
> 21: debugedit .debug_macro objects FAILED (debugedit.at:598)
>
> Fix this by instructing gcc not to produce compressed debug sections
> in object files prepared for debugedit tests.
>
> * tests/debugedit.at: Add "-gz=none" to "gcc -g3" invocations.
Yes, that is a good workaround for now.
But we should at least give a good error message.
And ideally just handle compressed debug ELF sections (But then the
question is how? Do we always simply decompress, do we require an
explicit command line option? Do we simply recompress when done?)
I filed https://sourceware.org/bugzilla/show_bug.cgi?id=27636
> Co-authored-by: Vitaly Chikunov <vt@altlinux.org>
And Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>, I assume?
Thanks,
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-23 14:20 ` Mark Wielaard
@ 2021-03-23 14:28 ` Dmitry V. Levin
2021-03-23 15:05 ` Mark Wielaard
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry V. Levin @ 2021-03-23 14:28 UTC (permalink / raw)
To: Mark Wielaard; +Cc: debugedit, Vitaly Chikunov
On Tue, Mar 23, 2021 at 03:20:12PM +0100, Mark Wielaard wrote:
> On Mon, 2021-03-22 at 20:00 +0000, Dmitry V. Levin wrote:
> > When toolchain produces compressed debug sections by default,
> > quite a few debugedit tests fail because of unexpected
> > "debugedit: ./foo.o: DWARF version 0 unhandled" error diagnostic messages:
> > 3: debugedit .debug_str objects DWARF4 FAILED (debugedit.at:97)
> > 4: debugedit .debug_str/line_str objects DWARF5 FAILED (debugedit.at:129)
> > 9: debugedit .debug_info objects FAILED (debugedit.at:291)
> > 12: debugedit .debug_types objects FAILED (debugedit.at:370)
> > 15: debugedit .debug_line objects DWARF4 FAILED (debugedit.at:460)
> > 16: debugedit .debug_line objects DWARF5 FAILED (debugedit.at:484)
> > 21: debugedit .debug_macro objects FAILED (debugedit.at:598)
> >
> > Fix this by instructing gcc not to produce compressed debug sections
> > in object files prepared for debugedit tests.
> >
> > * tests/debugedit.at: Add "-gz=none" to "gcc -g3" invocations.
>
> Yes, that is a good workaround for now.
> But we should at least give a good error message.
> And ideally just handle compressed debug ELF sections (But then the
> question is how? Do we always simply decompress, do we require an
> explicit command line option? Do we simply recompress when done?)
>
> I filed https://sourceware.org/bugzilla/show_bug.cgi?id=27636
>
> > Co-authored-by: Vitaly Chikunov <vt@altlinux.org>
>
> And Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>, I assume?
Yes, Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
--
ldv
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-23 14:28 ` Dmitry V. Levin
@ 2021-03-23 15:05 ` Mark Wielaard
2021-03-24 23:45 ` Dmitry V. Levin
0 siblings, 1 reply; 8+ messages in thread
From: Mark Wielaard @ 2021-03-23 15:05 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: Vitaly Chikunov, debugedit
Hi Dmitry,
On Tue, 2021-03-23 at 17:28 +0300, Dmitry V. Levin wrote:
> Yes, Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Thanks, pushed.
But note that it broke the buildbot:
https://builder.wildebeest.org/buildbot/#/builders/53/builds/2
Actually it was already broken, because that buildbot builder has an
gcc so old that it doesn't know about -gdwarf-5.
But it also doesn't seem to know about -gz=none.
So we'll need configure checks for that and not use -gz=none and skip
the -gdwarf-5 tests when gcc isn't able to use those options.
Cheers,
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-23 15:05 ` Mark Wielaard
@ 2021-03-24 23:45 ` Dmitry V. Levin
2021-03-25 23:12 ` Mark Wielaard
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry V. Levin @ 2021-03-24 23:45 UTC (permalink / raw)
To: Mark Wielaard; +Cc: Vitaly Chikunov, debugedit
Hi Mark,
On Tue, Mar 23, 2021 at 04:05:59PM +0100, Mark Wielaard wrote:
> Hi Dmitry,
>
> On Tue, 2021-03-23 at 17:28 +0300, Dmitry V. Levin wrote:
> > Yes, Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
>
> Thanks, pushed.
>
> But note that it broke the buildbot:
> https://builder.wildebeest.org/buildbot/#/builders/53/builds/2
>
> Actually it was already broken, because that buildbot builder has an
> gcc so old that it doesn't know about -gdwarf-5.
>
> But it also doesn't seem to know about -gz=none.
>
> So we'll need configure checks for that and not use -gz=none and skip
> the -gdwarf-5 tests when gcc isn't able to use those options.
>
> Cheers,
I've prepared the following fix, but it seems to be too late now.
I'll post it here anyway just in case.
From 53dfef243aa1de8331db777fe031129d5098f516 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Tue, 23 Mar 2021 20:00:00 +0000
Subject: [PATCH] tests: skip debugedit tests that require unsupported gcc
options
* tests/debugedit.at (RPM_DEBUGEDIT_SETUP): Do not use -gz=none if
gcc does not support it. Skip the test if gcc does not support
the parameters passed to RPM_DEBUGEDIT_SETUP.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
tests/debugedit.at | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 2d1870b..2e72c89 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -23,7 +23,7 @@ AT_TESTED([debugedit])
# Helper to create some test binaries.
# Optional parameter can specify additional gcc parameters.
-m4_define([RPM_DEBUGEDIT_SETUP],[[
+m4_define([RPM_DEBUGEDIT_SETUP],[
# Create some test binaries. Create and build them in different subdirs
# to make sure they produce different relative/absolute paths.
@@ -36,12 +36,21 @@ mkdir subdir_headers
cp "${abs_srcdir}"/data/SOURCES/foobar.h subdir_headers
cp "${abs_srcdir}"/data/SOURCES/baz.c .
+for cc_debug_opts in "-g3 -gz=none $1" "-g3 $1"; do
+ if gcc $cc_debug_opts $1 -c -xc /dev/null -o /dev/null; then
+ break
+ else
+ cc_debug_opts=''
+ fi
+done
+AT_SKIP_IF([test -z "$cc_debug_opts"])
+
# First three object files (foo.o subdir_bar/bar.o and baz.o)
-gcc -g3 -gz=none -Isubdir_headers $1 -c subdir_foo/foo.c
+gcc ${cc_debug_opts} -Isubdir_headers -c subdir_foo/foo.c
cd subdir_bar
-gcc -g3 -gz=none -I../subdir_headers $1 -c bar.c
+gcc ${cc_debug_opts} -I../subdir_headers -c bar.c
cd ..
-gcc -g3 -gz=none -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
+gcc ${cc_debug_opts} -I$(pwd)/subdir_headers -c $(pwd)/baz.c
# Then a partially linked object file (somewhat like a kernel module).
# This will still have relocations between the debug sections.
@@ -49,8 +58,8 @@ ld -r -o foobarbaz.part.o foo.o subdir_bar/bar.o baz.o
# Create an executable. Relocations between debug sections will
# have been resolved.
-gcc -g3 -gz=none -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
-]])
+gcc ${cc_debug_opts} -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
+])
# ===
# Check debugedit --help doesn't crash and burn.
--
ldv
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-24 23:45 ` Dmitry V. Levin
@ 2021-03-25 23:12 ` Mark Wielaard
2021-03-28 0:46 ` Dmitry V. Levin
0 siblings, 1 reply; 8+ messages in thread
From: Mark Wielaard @ 2021-03-25 23:12 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: Vitaly Chikunov, debugedit
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
Hi Dmitry,
On Thu, Mar 25, 2021 at 02:45:48AM +0300, Dmitry V. Levin wrote:
> On Tue, Mar 23, 2021 at 04:05:59PM +0100, Mark Wielaard wrote:
> > So we'll need configure checks for that and not use -gz=none and skip
> > the -gdwarf-5 tests when gcc isn't able to use those options.
> >
> I've prepared the following fix, but it seems to be too late now.
> I'll post it here anyway just in case.
Sorry, I didn't know you were already working on this. Your version
does everything in debugedit.at which is nicely contained. But I think
doing it as configure checks might help if we need them somewhere
else. But you version tests the actual gcc command used in the
test. We probably need to use CC instead in the tests, so it equals
the build/target compiler.
What do you think of the attached patch?
Thanks,
Mark
[-- Attachment #2: 0001-tests-Use-CC-CFLAGS-LD-and-LDFLAGS-to-create-testcas.patch --]
[-- Type: text/x-diff, Size: 2706 bytes --]
From 686ab7788728264ff245020a63e168bced1d6161 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 26 Mar 2021 00:00:42 +0100
Subject: [PATCH] tests: Use CC, CFLAGS, LD and LDFLAGS to create testcases
Currently gcc is hardcoded in the tests. Use the configured tools to
make testing for a specfic target or alternative build tools easier.
* configure.ac: Add AC_CHECK_TOOL for LD.
* tests/atlocal.in: Set CC, CFLAGS, LD and LDFLAGS.
* tests/debugedit.at (RPM_DEBUGEDIT_SETUP): Use CC, CFLAGS, LD
and LDFLAGS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
configure.ac | 1 +
tests/atlocal.in | 6 ++++++
tests/debugedit.at | 10 +++++-----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1669b5d..c5adadf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_PROG_AWK
AC_PROG_CC_C99
AC_PROG_LN_S
+AC_CHECK_TOOL([LD], [ld])
# Only really an issue on 32bit platforms. Makes sure we'll get large off_t.
AC_SYS_LARGEFILE
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 8ca240d..a45edac 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -2,5 +2,11 @@
# Configurable variable values for test suite.
PATH=@abs_builddir@:@abs_top_builddir@:$top_srcdir:$srcdir:$PATH
+
+CC="@CC@"
+CFLAGS="@CFLAGS@"
+LD="@LD@"
+LDFLAGS="@LDFLAGS@"
+
GDWARF_5_FLAG=@GDWARF_5_FLAG@
GZ_NONE_FLAG=@GZ_NONE_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 27d3e21..38b3aa4 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -37,19 +37,19 @@ cp "${abs_srcdir}"/data/SOURCES/foobar.h subdir_headers
cp "${abs_srcdir}"/data/SOURCES/baz.c .
# First three object files (foo.o subdir_bar/bar.o and baz.o)
-gcc -g3 $GZ_NONE_FLAG -Isubdir_headers $1 -c subdir_foo/foo.c
+$CC $CFLAGS -g3 $GZ_NONE_FLAG -Isubdir_headers $1 -c subdir_foo/foo.c
cd subdir_bar
-gcc -g3 $GZ_NONE_FLAG -I../subdir_headers $1 -c bar.c
+$CC $CFLAGS -g3 $GZ_NONE_FLAG -I../subdir_headers $1 -c bar.c
cd ..
-gcc -g3 $GZ_NONE_FLAG -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
+$CC $CFLAGS -g3 $GZ_NONE_FLAG -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
# Then a partially linked object file (somewhat like a kernel module).
# This will still have relocations between the debug sections.
-ld -r -o foobarbaz.part.o foo.o subdir_bar/bar.o baz.o
+$LD $LDFLAGS -r -o foobarbaz.part.o foo.o subdir_bar/bar.o baz.o
# Create an executable. Relocations between debug sections will
# have been resolved.
-gcc -g3 $GZ_NONE_FLAG -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
+$CC $CFLAGS -g3 $GZ_NONE_FLAG -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
]])
# ===
--
2.20.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-25 23:12 ` Mark Wielaard
@ 2021-03-28 0:46 ` Dmitry V. Levin
2021-03-28 14:01 ` Mark Wielaard
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry V. Levin @ 2021-03-28 0:46 UTC (permalink / raw)
To: Mark Wielaard; +Cc: Vitaly Chikunov, debugedit
Hi Mark,
On Fri, Mar 26, 2021 at 12:12:59AM +0100, Mark Wielaard wrote:
> Hi Dmitry,
>
> On Thu, Mar 25, 2021 at 02:45:48AM +0300, Dmitry V. Levin wrote:
> > On Tue, Mar 23, 2021 at 04:05:59PM +0100, Mark Wielaard wrote:
> > > So we'll need configure checks for that and not use -gz=none and skip
> > > the -gdwarf-5 tests when gcc isn't able to use those options.
> > >
> > I've prepared the following fix, but it seems to be too late now.
> > I'll post it here anyway just in case.
>
> Sorry, I didn't know you were already working on this. Your version
> does everything in debugedit.at which is nicely contained. But I think
> doing it as configure checks might help if we need them somewhere
> else. But you version tests the actual gcc command used in the
> test. We probably need to use CC instead in the tests, so it equals
> the build/target compiler.
>
> What do you think of the attached patch?
It looks good, thanks. Those who want to use different CC/CFLAGS or
LD/LDFLAGS would be able to edit tests/atlocal.in themselves.
--
ldv
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tests: fix for toolchains producing compressed debug sections
2021-03-28 0:46 ` Dmitry V. Levin
@ 2021-03-28 14:01 ` Mark Wielaard
0 siblings, 0 replies; 8+ messages in thread
From: Mark Wielaard @ 2021-03-28 14:01 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: Vitaly Chikunov, debugedit
Hi Dmitry,
On Sun, Mar 28, 2021 at 03:46:09AM +0300, Dmitry V. Levin wrote:
> On Fri, Mar 26, 2021 at 12:12:59AM +0100, Mark Wielaard wrote:
> > Sorry, I didn't know you were already working on this. Your version
> > does everything in debugedit.at which is nicely contained. But I think
> > doing it as configure checks might help if we need them somewhere
> > else. But you version tests the actual gcc command used in the
> > test. We probably need to use CC instead in the tests, so it equals
> > the build/target compiler.
> >
> > What do you think of the attached patch?
>
> It looks good, thanks.
Thanks, pushed.
> Those who want to use different CC/CFLAGS or
> LD/LDFLAGS would be able to edit tests/atlocal.in themselves.
If people regularly need to do that, then we can also adopt
TEST_CC/CFLAGS TEST_LD/LDFLAGS (which default to CC/LD/etc.) Please
yell and scream if that would be helpful to your test environment.
Cheers,
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-03-28 14:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 20:00 [PATCH] tests: fix for toolchains producing compressed debug sections Dmitry V. Levin
2021-03-23 14:20 ` Mark Wielaard
2021-03-23 14:28 ` Dmitry V. Levin
2021-03-23 15:05 ` Mark Wielaard
2021-03-24 23:45 ` Dmitry V. Levin
2021-03-25 23:12 ` Mark Wielaard
2021-03-28 0:46 ` Dmitry V. Levin
2021-03-28 14:01 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).