public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] tests: Check gcc accepts -gz=none before usage
Date: Thu, 25 Mar 2021 00:29:46 +0100	[thread overview]
Message-ID: <20210324232946.22431-1-mark@klomp.org> (raw)

commit 4f138 "tests: fix for toolchains producing compressed debug
sections" used -gz=none unconditionally to compile the test
binaries. But not all gcc versions support -gz.

Add a configure check for -gz=none. Set GZ_NONE_FLAG in
atlocal.in. Use it instead of -gz=none in debugedit.at.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 configure.ac       | 13 +++++++++++++
 tests/atlocal.in   |  1 +
 tests/debugedit.at |  8 ++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index b4bd749..1669b5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,19 @@ CFLAGS="$save_CFLAGS"
 GDWARF_5_FLAG=$ac_cv_gdwarf_5
 AC_SUBST([GDWARF_5_FLAG])
 
+AC_CACHE_CHECK([whether gcc supports -gz=none], ac_cv_gz_none, [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="-gz=none"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE()], ac_cv_gz_none=yes, ac_cv_gz_none=no)
+CFLAGS="$save_CFLAGS"
+])
+if test "$ac_cv_gz_none" = "yes"; then
+  GZ_NONE_FLAG="-gz=none"
+else
+  GZ_NONE_FLAG=""
+fi
+AC_SUBST([GZ_NONE_FLAG])
+
 # And generate the output files.
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 1324898..8ca240d 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -3,3 +3,4 @@
 
 PATH=@abs_builddir@:@abs_top_builddir@:$top_srcdir:$srcdir:$PATH
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
+GZ_NONE_FLAG=@GZ_NONE_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 9e6606a..27d3e21 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 -gz=none -Isubdir_headers $1 -c subdir_foo/foo.c
+gcc -g3 $GZ_NONE_FLAG -Isubdir_headers $1 -c subdir_foo/foo.c
 cd subdir_bar
-gcc -g3 -gz=none -I../subdir_headers $1 -c bar.c
+gcc -g3 $GZ_NONE_FLAG -I../subdir_headers $1 -c bar.c
 cd ..
-gcc -g3 -gz=none -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
+gcc -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.
@@ -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 -gz=none -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
+gcc -g3 $GZ_NONE_FLAG -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
 ]])
 
 # ===
-- 
2.20.1


                 reply	other threads:[~2021-03-24 23:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210324232946.22431-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=debugedit@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).