public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] tests: use ${CC} instead of 'gcc' in tests
@ 2021-01-31 15:49 Sergei Trofimovich
  2021-01-31 17:38 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Sergei Trofimovich @ 2021-01-31 15:49 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Sergei Trofimovich

To better support cross-compilation Gentoo provides a way
to configure system without 'gcc' binary and only provide
tool-prefixed tools, like 'x86_64-pc-linux-gnu-gcc'.
The packages are built as ./configure --host=x86_64-pc-linux-gnu.

In https://bugs.gentoo.org/718872 Agostino Sarubbo found
a few test failures that use hardcoded 'gcc' instead of
expected ${CC}. The change propagates detected ${CC} at
configure time to test scripts.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 tests/ChangeLog            | 10 ++++++++++
 tests/Makefile.am          |  6 ++++--
 tests/run-disasm-x86-64.sh |  2 +-
 tests/run-disasm-x86.sh    |  2 +-
 tests/run-strip-g.sh       |  2 +-
 tests/run-strip-nothing.sh |  2 +-
 tests/run-test-includes.sh | 14 +++++++-------
 7 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 3e5b630a..c6e9f618 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,13 @@
+2021-01-31  Sergei Trofimovich  <slyfox@gentoo.org>
+
+	* Makefile.am (TESTS_ENVIRONMENT): export CC variable
+	to tests for use instead of 'gcc'.
+	* run-disasm-x86-64.sh: use ${CC} instead of 'gcc'.
+	* run-disasm-x86.sh: Likewise.
+	* run-strip-g.sh: Likewise.
+	* run-strip-nothing.sh: Likewise.
+	* run-test-includes.sh: Likewise.
+
 2021-01-06  Timm Bäder  <tbaeder@redhat.com>
 
 	* zstrptr.c (main): Lift print_strings function up to ...
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 502becff..c145720c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -527,7 +527,8 @@ installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
 			      export libdir; export bindir; \
 			      export LC_ALL; export LANG; export VALGRIND_CMD; \
 			      unset DEBUGINFOD_URLS; \
-			      NM=$(NM); export NM;
+			      NM=$(NM); export NM; \
+			      CC=$(CC); export CC;
 installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
 			 installed $(tests_rpath) \
 			 '$(program_transform_name)'
@@ -538,7 +539,8 @@ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; VALGRIND_CMD=$(valgrind_cmd); \
 		    export abs_top_builddir; \
 		    export LC_ALL; export LANG; export VALGRIND_CMD; \
 		    unset DEBUGINFOD_URLS; \
-		    NM=$(NM); export NM;
+		    NM=$(NM); export NM; \
+		    CC=$(CC); export CC;
 LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
 	       $(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm:$(abs_top_builddir)/debuginfod
 
diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
index a6be62bb..07b612b0 100755
--- a/tests/run-disasm-x86-64.sh
+++ b/tests/run-disasm-x86-64.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64)
     tempfiles testfile45.o
     testfiles testfile45.S testfile45.expect
-    gcc -m64 -c -o testfile45.o testfile45.S
+    ${CC} -m64 -c -o testfile45.o testfile45.S
     testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < testfile45.expect
     ;;
 esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
index 28a3df74..7ac73ad7 100755
--- a/tests/run-disasm-x86.sh
+++ b/tests/run-disasm-x86.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64 | i?86 )
     tempfiles testfile44.o
     testfiles testfile44.S testfile44.expect
-    gcc -m32 -c -o testfile44.o testfile44.S
+    ${CC} -m32 -c -o testfile44.o testfile44.S
     testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < testfile44.expect
     ;;
 esac
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
index 13038195..15921215 100755
--- a/tests/run-strip-g.sh
+++ b/tests/run-strip-g.sh
@@ -25,7 +25,7 @@
 tempfiles a.out strip.out debug.out readelf.out
 
 echo Create debug a.out.
-echo "int main() { return 1; }" | gcc -g -xc -
+echo "int main() { return 1; }" | ${CC} -g -xc -
 
 echo strip -g to file with debug file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
index 914fdfbf..710c200d 100755
--- a/tests/run-strip-nothing.sh
+++ b/tests/run-strip-nothing.sh
@@ -23,7 +23,7 @@
 tempfiles a.out strip.out debug.out
 
 # Create no-debug a.out.
-echo "int main() { return 1; }" | gcc -s -xc -
+echo "int main() { return 1; }" | ${CC} -s -xc -
 
 # strip to file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out ||
diff --git a/tests/run-test-includes.sh b/tests/run-test-includes.sh
index b0ccdd9b..b107c6b9 100755
--- a/tests/run-test-includes.sh
+++ b/tests/run-test-includes.sh
@@ -3,24 +3,24 @@
 . $srcdir/test-subr.sh
 
 echo '#include "libelf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
 echo '#include "gelf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
 
 echo '#include "dwarf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf \
         -I ${abs_srcdir}/../libdw -xc -
 echo '#include "libdw.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf \
         -I ${abs_srcdir}/../libdw -xc -
 
 echo '#include "libdwfl.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf \
     -I ${abs_srcdir}/../libdw -I ${abs_srcdir}/../libdwfl -xc -
 echo '#include "libdwelf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf \
     -I ${abs_srcdir}/../libdw -I ${abs_srcdir}/../libdwelf -xc -
 
 echo '#include "libasm.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf \
     -I ${abs_srcdir}/../libasm -xc -
-- 
2.30.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tests: use ${CC} instead of 'gcc' in tests
  2021-01-31 15:49 [PATCH] tests: use ${CC} instead of 'gcc' in tests Sergei Trofimovich
@ 2021-01-31 17:38 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2021-01-31 17:38 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: elfutils-devel

On Sun, Jan 31, 2021 at 03:49:13PM +0000, Sergei Trofimovich via Elfutils-devel wrote:
> To better support cross-compilation Gentoo provides a way
> to configure system without 'gcc' binary and only provide
> tool-prefixed tools, like 'x86_64-pc-linux-gnu-gcc'.
> The packages are built as ./configure --host=x86_64-pc-linux-gnu.
> 
> In https://bugs.gentoo.org/718872 Agostino Sarubbo found
> a few test failures that use hardcoded 'gcc' instead of
> expected ${CC}. The change propagates detected ${CC} at
> configure time to test scripts.

Looks good. As long as CC accepts the same arguments as gcc this
should work just fine. And I think all requirements are checked
against CC in configure. Pushed.

BTW. Note that tests/run-debuginfod-find.sh still contains "bare" gcc
calls.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-31 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31 15:49 [PATCH] tests: use ${CC} instead of 'gcc' in tests Sergei Trofimovich
2021-01-31 17:38 ` 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).