* [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi
@ 2024-04-23 14:05 Rainer Orth
2024-04-23 14:18 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2024-04-23 14:05 UTC (permalink / raw)
To: gcc-patches; +Cc: Ian Lance Taylor
[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]
I noticed that libbacktrace make check FAILs on Solaris with the native
ld already when building the tests:
libtool: link: /var/gcc/regression/master/11.4-gcc/build/./gcc/xgcc -B/var/gcc/r
egression/master/11.4-gcc/build/./gcc/ -B/vol/gcc/sparc-sun-solaris2.11/bin/ -B/
vol/gcc/sparc-sun-solaris2.11/lib/ -isystem /vol/gcc/sparc-sun-solaris2.11/inclu
de -isystem /vol/gcc/sparc-sun-solaris2.11/sys-include -fchecking=1 -funwind-tab
les -frandom-seed=ctesta_alloc -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmi
ssing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -
Werror -g -g -O2 -Wl,--compress-debug-sections=zlib-gabi -o ctesta_alloc ctesta_
alloc-btest.o ctesta_alloc-testlib.o ./.libs/libbacktrace_alloc.a
ld: fatal: unrecognized '--compress-debug-sections' cmp-type: zlib-gabi
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1379: ctesta_alloc] Error 1
Solaris ld only supports --compress-debug-sections=zlib, while GNU ld
allows zlib-gabi as an alias for zlib. gold is the same, it seems,
while lld doesn't support zlib-gabi at all.
Therefore the patch uses zlib instead.
Tested on i386-pc-solaris2.11 with ld and gld and x86_64-pc-linux-gnu
with gld.
With this patch, libbacktrace make check PASSes on Solaris.
Unfortunately, this is quite easy to miss since the make check output
isn't in DejaGnu summary format, thus not picked up by make
mail-report.log. I mean to adapt the libgo support to produce that
output format for libbacktrace to fix this.
Ok for trunk?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2024-04-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libbacktrace:
* Makefile.am (ctestg_LDFLAGS): Use
-Wl,--compress-debug-sections=zlib instead of zlib-gabi.
(ctesta_LDFLAGS): Likewise.
* Makefile.in: Regenerate.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-libbacktrace-no-zlib-gabi.patch --]
[-- Type: text/x-patch, Size: 2407 bytes --]
# HG changeset patch
# Parent 3f974c85f19c90c967e272a1ca6523b897cc175f
libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -497,12 +497,12 @@ if HAVE_COMPRESSED_DEBUG
ctestg_SOURCES = btest.c testlib.c
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags)
+ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib $(libbacktrace_testing_ldflags)
ctestg_LDADD = libbacktrace.la
ctesta_SOURCES = btest.c testlib.c
ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags)
+ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib $(libbacktrace_testing_ldflags)
ctesta_LDADD = libbacktrace.la
BUILDTESTS += ctestg ctesta
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -1177,11 +1177,11 @@ libbacktrace_testing_ldflags = -no-insta
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_LDADD = libbacktrace_alloc.la
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_SOURCES = btest.c testlib.c
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib $(libbacktrace_testing_ldflags)
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDADD = libbacktrace.la
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_SOURCES = btest.c testlib.c
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib $(libbacktrace_testing_ldflags)
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDADD = libbacktrace.la
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_SOURCES = btest.c testlib.c
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi
2024-04-23 14:05 [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi Rainer Orth
@ 2024-04-23 14:18 ` Jakub Jelinek
2024-04-23 14:24 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2024-04-23 14:18 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches, Ian Lance Taylor
On Tue, Apr 23, 2024 at 04:05:07PM +0200, Rainer Orth wrote:
> I noticed that libbacktrace make check FAILs on Solaris with the native
> ld already when building the tests:
>
> libtool: link: /var/gcc/regression/master/11.4-gcc/build/./gcc/xgcc -B/var/gcc/r
> egression/master/11.4-gcc/build/./gcc/ -B/vol/gcc/sparc-sun-solaris2.11/bin/ -B/
> vol/gcc/sparc-sun-solaris2.11/lib/ -isystem /vol/gcc/sparc-sun-solaris2.11/inclu
> de -isystem /vol/gcc/sparc-sun-solaris2.11/sys-include -fchecking=1 -funwind-tab
> les -frandom-seed=ctesta_alloc -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmi
> ssing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -
> Werror -g -g -O2 -Wl,--compress-debug-sections=zlib-gabi -o ctesta_alloc ctesta_
> alloc-btest.o ctesta_alloc-testlib.o ./.libs/libbacktrace_alloc.a
> ld: fatal: unrecognized '--compress-debug-sections' cmp-type: zlib-gabi
> collect2: error: ld returned 1 exit status
> make[1]: *** [Makefile:1379: ctesta_alloc] Error 1
>
> Solaris ld only supports --compress-debug-sections=zlib, while GNU ld
> allows zlib-gabi as an alias for zlib. gold is the same, it seems,
> while lld doesn't support zlib-gabi at all.
>
> Therefore the patch uses zlib instead.
Then you have two tests (ctestg and ctesta) doing exactly the same thing,
that can't be right.
I guess it might be fine to use zlib when it is an alias to zlib-gabi,
but zlib-gnu shouldn't be replaced.
I must say I don't really understand the patch though, because configury
checks
AC_CACHE_CHECK([whether --compress-debug-sections is supported],
[libgo_cv_ld_compress],
[LDFLAGS_hold=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
[libgo_cv_ld_compress=yes],
[libgo_cv_ld_compress=no])
LDFLAGS=$LDFLAGS_hold])
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
So, if Solaris doesn't support --compress-debug-sections=zlib-gnu, it
shouldn't be tested. Or does it support zlib-gnu and zlib?
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi
2024-04-23 14:18 ` Jakub Jelinek
@ 2024-04-23 14:24 ` Jakub Jelinek
2024-04-23 17:04 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2024-04-23 14:24 UTC (permalink / raw)
To: Rainer Orth, gcc-patches, Ian Lance Taylor
On Tue, Apr 23, 2024 at 04:18:49PM +0200, Jakub Jelinek wrote:
> Then you have two tests (ctestg and ctesta) doing exactly the same thing,
> that can't be right.
> I guess it might be fine to use zlib when it is an alias to zlib-gabi,
> but zlib-gnu shouldn't be replaced.
>
> I must say I don't really understand the patch though, because configury
> checks
> AC_CACHE_CHECK([whether --compress-debug-sections is supported],
> [libgo_cv_ld_compress],
> [LDFLAGS_hold=$LDFLAGS
> LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
> AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
> [libgo_cv_ld_compress=yes],
> [libgo_cv_ld_compress=no])
> LDFLAGS=$LDFLAGS_hold])
> AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
>
> So, if Solaris doesn't support --compress-debug-sections=zlib-gnu, it
> shouldn't be tested. Or does it support zlib-gnu and zlib?
What we could do is drop the HAVE_COMPRESSED_DEBUG stuff altogether, and
instead similarly how we have HAVE_COMPRESSED_DEBUG_ZSTD have
HAVE_COMPRESSED_DEBUG_{ZLIB,ZLIB_GABI,ZLIB_GNU} and for each of those
if linker supports them test with that corresponding flag.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi
2024-04-23 14:24 ` Jakub Jelinek
@ 2024-04-23 17:04 ` Ian Lance Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2024-04-23 17:04 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Rainer Orth, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
On Tue, Apr 23, 2024 at 7:24 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> What we could do is drop the HAVE_COMPRESSED_DEBUG stuff altogether, and
> instead similarly how we have HAVE_COMPRESSED_DEBUG_ZSTD have
> HAVE_COMPRESSED_DEBUG_{ZLIB,ZLIB_GABI,ZLIB_GNU} and for each of those
> if linker supports them test with that corresponding flag.
I think that's right. Committed this patch after testing on
x86_64-pc-linux-gnu. While I was at it I added an _alloc version of
ctestzstd.
Ian
* configure.ac: Test --compress-debug-sections=zlib-gnu and
--compress-debug-sections=zlib-gabi separately, setting new
automake conditionals.
* Makefile.am (ctestg, ctestg_alloc): Only build if
HAVE_COMPRESSED_DEBUG_ZLIB_GNU.
(ctesta, ctesta_alloc): Only build if
HAVE_COMPRESSED_DEBUG_ZLIB_GABI.
(ctestzstd_alloc): New test if HAVE_COMPRESSED_DEBUG_ZSTD.
* configure, Makefile.in: Regenerate.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3991 bytes --]
3943de6986271466652cb619dbc60881060b180c
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 5677ecd8865..bed42c29329 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -493,19 +493,37 @@ endif HAVE_OBJCOPY_DEBUGLINK
$<
$(OBJCOPY) --strip-all $< $@
-if HAVE_COMPRESSED_DEBUG
+if HAVE_COMPRESSED_DEBUG_ZLIB_GNU
ctestg_SOURCES = btest.c testlib.c
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags)
ctestg_LDADD = libbacktrace.la
+ctestg_alloc_SOURCES = $(ctestg_SOURCES)
+ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
+ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctestg_alloc_LDADD = libbacktrace_alloc.la
+
+BUILDTESTS += ctestg ctestg_alloc
+
+endif
+
+if HAVE_COMPRESSED_DEBUG_ZLIB_GABI
+
ctesta_SOURCES = btest.c testlib.c
ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags)
ctesta_LDADD = libbacktrace.la
-BUILDTESTS += ctestg ctesta
+ctesta_alloc_SOURCES = $(ctesta_SOURCES)
+ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
+ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctesta_alloc_LDADD = libbacktrace_alloc.la
+
+BUILDTESTS += ctesta ctesta_alloc
+
+endif
if HAVE_COMPRESSED_DEBUG_ZSTD
@@ -514,21 +532,12 @@ ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd $(libbacktrace_testing_ldflags)
ctestzstd_LDADD = libbacktrace.la
-BUILDTESTS += ctestzstd
-
-endif
-
-ctestg_alloc_SOURCES = $(ctestg_SOURCES)
-ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
-ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
-ctestg_alloc_LDADD = libbacktrace_alloc.la
-
-ctesta_alloc_SOURCES = $(ctesta_SOURCES)
-ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
-ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
-ctesta_alloc_LDADD = libbacktrace_alloc.la
+ctestzstd_alloc_SOURCES = $(ctestzstd_SOURCES)
+ctestzstd_alloc_CFLAGS = $(ctestzstd_CFLAGS)
+ctestzstd_alloc_LDFLAGS = $(ctestzstd_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctestzstd_alloc_LDADD = libbacktrace_alloc.la
-BUILDTESTS += ctestg_alloc ctesta_alloc
+BUILDTESTS += ctestzstd ctestzstd_alloc
endif
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 0f61f2b28ab..3e0075a2b79 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -502,16 +502,27 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
LDFLAGS=$LDFLAGS_hold])
AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
-dnl Test whether the linker supports the --compress-debug-sections option.
-AC_CACHE_CHECK([whether --compress-debug-sections is supported],
-[libgo_cv_ld_compress],
+dnl Test whether the linker supports the --compress-debug-sections=zlib-gnu
+dnl option.
+AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gnu is supported],
+[libgo_cv_ld_compress_zlib_gnu],
[LDFLAGS_hold=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
-[libgo_cv_ld_compress=yes],
-[libgo_cv_ld_compress=no])
+[libgo_cv_ld_compress_zlib_gnu=yes],
+[libgo_cv_ld_compress_zlib_gnu=no])
LDFLAGS=$LDFLAGS_hold])
-AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
+AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GNU, test "$libgo_cv_ld_compress_zlib_gnu" = yes)
+
+AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gabi is supported],
+[libgo_cv_ld_compress_zlib_gabi],
+[LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gabi"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
+[libgo_cv_ld_compress_zlib_gabi=yes],
+[libgo_cv_ld_compress_zlib_gabi=no])
+LDFLAGS=$LDFLAGS_hold])
+AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GABI, test "$libgo_cv_ld_compress_zlib_gabi" = yes)
AC_CHECK_LIB([zstd], [ZSTD_compress],
[AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-23 17:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 14:05 [PATCH] libbacktrace: Avoid GNU ld --compress-debug-sections=zlib-gabi Rainer Orth
2024-04-23 14:18 ` Jakub Jelinek
2024-04-23 14:24 ` Jakub Jelinek
2024-04-23 17:04 ` Ian Lance Taylor
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).