public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler
@ 2021-01-05 19:52 Nick Alcock
  2021-01-05 19:52 ` [PATCH 2/2] libctf, testsuite: adjust for real return type of ctf_member_count Nick Alcock
  2021-02-03  9:14 ` [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Jan Beulich
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Alcock @ 2021-01-05 19:52 UTC (permalink / raw)
  To: binutils

We never actually check to see if the compiler supports CTF,
or even if a suitable compiler exists.

libctf/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* Makefile.am (BASEDIR): New.
	(BFDDIR): Likewise.
	(check-DEJAGNU): Add development.exp to prerequisites.
	(development.exp): New.
	(CONFIG_STATUS_DEPENDENCIES): New.
	(EXTRA_DEJAGNU_SITE_CONFIG): Likewise.
	(DISTCLEANFILES): Likewise.
	* Makefile.in: Regenerated.
	* testsuite/lib/ctf-lib.exp (check_ctf_available): Return boolean.
	* testsuite/libctf-lookup/lookup.exp: Call check_ctf_available.
	* testsuite/libctf-regression/regression.exp: Likewise.
---
 libctf/Makefile.am                                | 15 ++++++++++++++-
 libctf/Makefile.in                                | 14 +++++++++++++-
 libctf/testsuite/lib/ctf-lib.exp                  |  7 ++++++-
 libctf/testsuite/libctf-lookup/lookup.exp         |  5 +++++
 libctf/testsuite/libctf-regression/regression.exp |  5 +++++
 5 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index 3fe1994d96e..f45433483c0 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -27,6 +27,8 @@ AUTOMAKE_OPTIONS = dejagnu foreign no-texinfo.tex
 ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 
+BASEDIR = $(srcdir)/..
+BFDDIR = $(BASEDIR)/bfd
 INCDIR = $(srcdir)/../include
 AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@
 AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC)
@@ -75,7 +77,7 @@ CC_FOR_TARGET = ` \
     fi; \
   fi`
 
-check-DEJAGNU: site.exp
+check-DEJAGNU: site.exp development.exp
 	srcroot=`cd $(srcdir) && pwd`; export srcroot; \
 	r=`pwd`; export r; \
 	LC_ALL=C; export LC_ALL; \
@@ -87,3 +89,14 @@ check-DEJAGNU: site.exp
 		CC_FOR_HOST="$(CC)" LIBS="$(LIBS)" $(RUNTESTFLAGS); \
 	else echo "WARNING: could not find \`runtest'" 1>&2; :;\
 	fi
+
+development.exp: $(BFDDIR)/development.sh
+	$(EGREP) "(development|experimental)=" $(BFDDIR)/development.sh  \
+	  | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+
+# development.sh is used to determine -Werror default.
+CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
+
+EXTRA_DEJAGNU_SITE_CONFIG = development.exp
+
+DISTCLEANFILES = site.exp development.exp
diff --git a/libctf/Makefile.in b/libctf/Makefile.in
index c86ac7b2b68..d31d017c1f5 100644
--- a/libctf/Makefile.in
+++ b/libctf/Makefile.in
@@ -448,6 +448,8 @@ AUTOMAKE_OPTIONS = dejagnu foreign no-texinfo.tex
 # case both are empty.
 ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
+BASEDIR = $(srcdir)/..
+BFDDIR = $(BASEDIR)/bfd
 INCDIR = $(srcdir)/../include
 AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@
 AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC)
@@ -486,6 +488,11 @@ CC_FOR_TARGET = ` \
     fi; \
   fi`
 
+
+# development.sh is used to determine -Werror default.
+CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
+EXTRA_DEJAGNU_SITE_CONFIG = development.exp
+DISTCLEANFILES = site.exp development.exp
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -1216,6 +1223,7 @@ clean-generic:
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -1319,7 +1327,7 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
 .PRECIOUS: Makefile
 
 
-check-DEJAGNU: site.exp
+check-DEJAGNU: site.exp development.exp
 	srcroot=`cd $(srcdir) && pwd`; export srcroot; \
 	r=`pwd`; export r; \
 	LC_ALL=C; export LC_ALL; \
@@ -1332,6 +1340,10 @@ check-DEJAGNU: site.exp
 	else echo "WARNING: could not find \`runtest'" 1>&2; :;\
 	fi
 
+development.exp: $(BFDDIR)/development.sh
+	$(EGREP) "(development|experimental)=" $(BFDDIR)/development.sh  \
+	  | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-lib.exp
index 796342b96de..fe028122195 100644
--- a/libctf/testsuite/lib/ctf-lib.exp
+++ b/libctf/testsuite/lib/ctf-lib.exp
@@ -399,7 +399,12 @@ proc check_ctf_available { } {
 	    set f [open $src "w"]
 	    puts $f "int main() { return 0; }"
 	    close $f
-	    set ctf_available_saved [compile_one_cc $src $output "-gt -c"]
+	    set comp_output [compile_one_cc $src $output "-gt -c"]
+            if { $comp_output == ""} {
+                set ctf_available_saved 1
+            } else {
+                set ctf_available_saved 0
+            }
 	    remote_file host delete $src
 	    remote_file host delete $output
 	    file delete $src
diff --git a/libctf/testsuite/libctf-lookup/lookup.exp b/libctf/testsuite/libctf-lookup/lookup.exp
index 51ad257c94f..84ff46ce4d8 100644
--- a/libctf/testsuite/libctf-lookup/lookup.exp
+++ b/libctf/testsuite/libctf-lookup/lookup.exp
@@ -23,6 +23,11 @@ if ![is_elf_format] {
     return 0
 }
 
+if {![check_ctf_available]} {
+    unsupported "no CTF format support in the compiler"
+    return 0
+}
+
 if {[info exists env(LC_ALL)]} {
     set old_lc_all $env(LC_ALL)
 }
diff --git a/libctf/testsuite/libctf-regression/regression.exp b/libctf/testsuite/libctf-regression/regression.exp
index 51ad257c94f..605d96f57b7 100644
--- a/libctf/testsuite/libctf-regression/regression.exp
+++ b/libctf/testsuite/libctf-regression/regression.exp
@@ -18,6 +18,11 @@
 # MA 02110-1301, USA.
 #
 
+if {![check_ctf_available]} {
+    unsupported "no CTF format support in the compiler"
+    return 0
+}
+
 if ![is_elf_format] {
     unsupported "CTF needs bfd changes to be emitted on non-ELF"
     return 0
-- 
2.29.2.250.g8336e49d6f.dirty


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

* [PATCH 2/2] libctf, testsuite: adjust for real return type of ctf_member_count
  2021-01-05 19:52 [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Nick Alcock
@ 2021-01-05 19:52 ` Nick Alcock
  2021-02-03  9:14 ` [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Jan Beulich
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Alcock @ 2021-01-05 19:52 UTC (permalink / raw)
  To: binutils

This returns an int, not a long int or an ssize_t (as one test was
inconsistently assuming).

libctf/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/libctf-lookup/struct-iteration.c (main):
	ctf_member_count returns an int.
---
 libctf/testsuite/libctf-lookup/struct-iteration.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libctf/testsuite/libctf-lookup/struct-iteration.c b/libctf/testsuite/libctf-lookup/struct-iteration.c
index 03750604ecf..080edfadca4 100644
--- a/libctf/testsuite/libctf-lookup/struct-iteration.c
+++ b/libctf/testsuite/libctf-lookup/struct-iteration.c
@@ -26,7 +26,7 @@ main (int argc, char *argv[])
   const char *name;
   ctf_id_t membtype;
   ssize_t offset;
-  ssize_t icount = 0;
+  int icount = 0;
   int err;
 
   if (argc != 2)
@@ -69,8 +69,8 @@ main (int argc, char *argv[])
     goto nerr;
 
   if (icount != ctf_member_count (fp, type))
-    printf ("member counts differ: %li by direct iteration, "
-	    "%li by ctf_member_count\n", icount, ctf_member_count (fp, type));
+    printf ("member counts differ: %i by direct iteration, "
+	    "%i by ctf_member_count\n", icount, ctf_member_count (fp, type));
 
   ctf_dict_close (fp);
   ctf_close (ctf);
-- 
2.29.2.250.g8336e49d6f.dirty


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

* Re: [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler
  2021-01-05 19:52 [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Nick Alcock
  2021-01-05 19:52 ` [PATCH 2/2] libctf, testsuite: adjust for real return type of ctf_member_count Nick Alcock
@ 2021-02-03  9:14 ` Jan Beulich
  2021-02-03 13:19   ` Nick Alcock
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2021-02-03  9:14 UTC (permalink / raw)
  To: Nick Alcock; +Cc: binutils

On 05.01.2021 20:52, Nick Alcock via Binutils wrote:
> We never actually check to see if the compiler supports CTF,
> or even if a suitable compiler exists.
> 
> libctf/ChangeLog
> 2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
> 
> 	* Makefile.am (BASEDIR): New.
> 	(BFDDIR): Likewise.
> 	(check-DEJAGNU): Add development.exp to prerequisites.
> 	(development.exp): New.
> 	(CONFIG_STATUS_DEPENDENCIES): New.
> 	(EXTRA_DEJAGNU_SITE_CONFIG): Likewise.
> 	(DISTCLEANFILES): Likewise.
> 	* Makefile.in: Regenerated.
> 	* testsuite/lib/ctf-lib.exp (check_ctf_available): Return boolean.
> 	* testsuite/libctf-lookup/lookup.exp: Call check_ctf_available.
> 	* testsuite/libctf-regression/regression.exp: Likewise.

Is there any reason the same check didn't get added here to
testsuite/libctf-writable/writable.exp? If it was there, on an
older host I expect I wouldn't have run into

ERROR: (DejaGnu) proc "try {
	set run_output [exec "sh" "-c" "$command" "2>@1"]
	set status 0
    } trap CHILDSTATUS {results options} {
	set status [lindex [dict get $options -errorcode] 2]
	set run_output $results
    }" does not exist.
The error code is CHILDSTATUS 22593 1
The info on the error is:
child process exited abnormally
    while executing
"close file7"
    invoked from within
"catch "close $id" res"

because the Tcl there is 8.5, but "try" is available only
from 8.6. I think this dependency would also be nice to be
checked.

Jan

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

* Re: [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler
  2021-02-03  9:14 ` [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Jan Beulich
@ 2021-02-03 13:19   ` Nick Alcock
  2021-02-03 13:22     ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Alcock @ 2021-02-03 13:19 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On 3 Feb 2021, Jan Beulich stated:

> On 05.01.2021 20:52, Nick Alcock via Binutils wrote:
>> We never actually check to see if the compiler supports CTF,
>> or even if a suitable compiler exists.
>> 
>> libctf/ChangeLog
>> 2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
>> 
>> 	* Makefile.am (BASEDIR): New.
>> 	(BFDDIR): Likewise.
>> 	(check-DEJAGNU): Add development.exp to prerequisites.
>> 	(development.exp): New.
>> 	(CONFIG_STATUS_DEPENDENCIES): New.
>> 	(EXTRA_DEJAGNU_SITE_CONFIG): Likewise.
>> 	(DISTCLEANFILES): Likewise.
>> 	* Makefile.in: Regenerated.
>> 	* testsuite/lib/ctf-lib.exp (check_ctf_available): Return boolean.
>> 	* testsuite/libctf-lookup/lookup.exp: Call check_ctf_available.
>> 	* testsuite/libctf-regression/regression.exp: Likewise.
>
> Is there any reason the same check didn't get added here to
> testsuite/libctf-writable/writable.exp?

Yes. The libctf-writable stuff exists to test *writable* dictionaries:
these tests create CTF on the fly using ctf_create and then populate it
using ctf_add_*(), rather than reading in .ctf sections in binaries
created by the linker (with CTF ultimately generated by the compiler).
So no compiler support is needed to run these (and they will happily run
on non-ELF platforms for which I haven't got the linker emitting .ctf
yet). The writable tsts still use run_lookup_test, but because none of
the tests have any source: declared in their .lk files, we end up not
calling GCC with -gt at all.

(Side note: the compiler flag in question will probably be -gctf when
the compiler gets upstream: I'll be submitting changes to switch to
that, and to adjust the test results for the new GCC 11-based compiler
just submitted upstream, fairly soon. There are no synchronization
concerns because if I'm a bit late the only side effect is that the
testsuite isn't run if people install the newer compiler.)

> because the Tcl there is 8.5, but "try" is available only
> from 8.6. I think this dependency would also be nice to be
> checked.

Ah yeah, that's a quite different bug :) will fix soon. I guess I'll
have to conditionalize out the entirety of check-DEJAGNU in
libctf/Makefile.am if Tcl is too old. I could rewrite things to not use
'try' but honestly if you have a Tcl that old I guess a few tests
getting skipped is not too much of a problem.

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

* Re: [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler
  2021-02-03 13:19   ` Nick Alcock
@ 2021-02-03 13:22     ` Jan Beulich
  2021-02-03 14:50       ` Nick Alcock
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2021-02-03 13:22 UTC (permalink / raw)
  To: Nick Alcock; +Cc: binutils

On 03.02.2021 14:19, Nick Alcock wrote:
> On 3 Feb 2021, Jan Beulich stated:
>> On 05.01.2021 20:52, Nick Alcock via Binutils wrote:
>>> We never actually check to see if the compiler supports CTF,
>>> or even if a suitable compiler exists.
>>>
>>> libctf/ChangeLog
>>> 2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
>>>
>>> 	* Makefile.am (BASEDIR): New.
>>> 	(BFDDIR): Likewise.
>>> 	(check-DEJAGNU): Add development.exp to prerequisites.
>>> 	(development.exp): New.
>>> 	(CONFIG_STATUS_DEPENDENCIES): New.
>>> 	(EXTRA_DEJAGNU_SITE_CONFIG): Likewise.
>>> 	(DISTCLEANFILES): Likewise.
>>> 	* Makefile.in: Regenerated.
>>> 	* testsuite/lib/ctf-lib.exp (check_ctf_available): Return boolean.
>>> 	* testsuite/libctf-lookup/lookup.exp: Call check_ctf_available.
>>> 	* testsuite/libctf-regression/regression.exp: Likewise.
>>
>> Is there any reason the same check didn't get added here to
>> testsuite/libctf-writable/writable.exp?
> 
> Yes. The libctf-writable stuff exists to test *writable* dictionaries:
> these tests create CTF on the fly using ctf_create and then populate it
> using ctf_add_*(), rather than reading in .ctf sections in binaries
> created by the linker (with CTF ultimately generated by the compiler).
> So no compiler support is needed to run these (and they will happily run
> on non-ELF platforms for which I haven't got the linker emitting .ctf
> yet). The writable tsts still use run_lookup_test, but because none of
> the tests have any source: declared in their .lk files, we end up not
> calling GCC with -gt at all.

Ah yes, I meanwhile guessed along these lines, so thanks for
confirming.

>> because the Tcl there is 8.5, but "try" is available only
>> from 8.6. I think this dependency would also be nice to be
>> checked.
> 
> Ah yeah, that's a quite different bug :) will fix soon. I guess I'll
> have to conditionalize out the entirety of check-DEJAGNU in
> libctf/Makefile.am if Tcl is too old. I could rewrite things to not use
> 'try' but honestly if you have a Tcl that old I guess a few tests
> getting skipped is not too much of a problem.

What I've done locally for now is:

--- 2.36/libctf/testsuite/libctf-lookup/lookup.exp
+++ 2.36/libctf/testsuite/libctf-lookup/lookup.exp
@@ -23,6 +23,11 @@ if ![is_elf_format] {
     return 0
 }
 
+if {![llength [info commands try]]} {
+    unsupported "Tcl / Tcllib too old / missing (no 'try')"
+    return 0
+}
+
 if {![check_ctf_available]} {
     unsupported "no CTF format support in the compiler"
     return 0
--- 2.36/libctf/testsuite/libctf-regression/regression.exp
+++ 2.36/libctf/testsuite/libctf-regression/regression.exp
@@ -18,6 +18,11 @@
 # MA 02110-1301, USA.
 #
 
+if {![llength [info commands try]]} {
+    unsupported "Tcl / Tcllib too old / missing (no 'try')"
+    return 0
+}
+
 if {![check_ctf_available]} {
     unsupported "no CTF format support in the compiler"
     return 0
--- 2.36/libctf/testsuite/libctf-writable/writable.exp
+++ 2.36/libctf/testsuite/libctf-writable/writable.exp
@@ -18,6 +18,11 @@
 # MA 02110-1301, USA.
 #
 
+if {![llength [info commands try]]} {
+    unsupported "Tcl / Tcllib too old / missing (no 'try')"
+    return 0
+}
+
 if {[info exists env(LC_ALL)]} {
     set old_lc_all $env(LC_ALL)
 }

Jan

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

* Re: [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler
  2021-02-03 13:22     ` Jan Beulich
@ 2021-02-03 14:50       ` Nick Alcock
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Alcock @ 2021-02-03 14:50 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On 3 Feb 2021, Jan Beulich spake thusly:
> On 03.02.2021 14:19, Nick Alcock wrote:
>> Ah yeah, that's a quite different bug :) will fix soon. I guess I'll
>> have to conditionalize out the entirety of check-DEJAGNU in
>> libctf/Makefile.am if Tcl is too old. I could rewrite things to not use
>> 'try' but honestly if you have a Tcl that old I guess a few tests
>> getting skipped is not too much of a problem.
>
> What I've done locally for now is:
[...]
> +if {![llength [info commands try]]} {

Ooh that's quite nice. I'll rip out the configure-time check for Tcl
8.6+ I've got in place in favour of this approach (again at configure
time).

-- 
NULL && (void)

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

end of thread, other threads:[~2021-02-03 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 19:52 [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Nick Alcock
2021-01-05 19:52 ` [PATCH 2/2] libctf, testsuite: adjust for real return type of ctf_member_count Nick Alcock
2021-02-03  9:14 ` [PATCH 1/2] libctf, testsuite: don't run without a suitable compiler Jan Beulich
2021-02-03 13:19   ` Nick Alcock
2021-02-03 13:22     ` Jan Beulich
2021-02-03 14:50       ` Nick Alcock

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).