public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: binutils@sourceware.org
Subject: [PATCH 58/59] ld, testsuite: only run CTF tests when ld and GCC support CTF
Date: Wed,  1 Jul 2020 00:31:45 +0100	[thread overview]
Message-ID: <20200630233146.338613-59-nick.alcock@oracle.com> (raw)
In-Reply-To: <20200630233146.338613-1-nick.alcock@oracle.com>

The CTF testsuite runs GCC to generate CTF that it knows matches the
input .c files before doing a run_dump_test over it.  So we need a GCC
capable of doing that, and we need to always avoid running those tests
if libctf was disabled because the linker will never be capable of it.

ld/
	* configure.ac (enable_libctf): Substitute it.
	* Makefile.am (enablings.exp): New.
	(EXTRA_DEJAGNU_SITE_CONFIG): Add it.
	(DISTCLEANFILES): Likewise.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* testsuite/lib/ld-lib.exp (compile_one_cc): New.
	(check_ctf_available): Likewise.
	(skip_ctf_tests): Likewise.
	* testsuite/ld-ctf/ctf.exp: Call skip_ctf_tests.
---
 ld/Makefile.am              |  7 +++--
 ld/Makefile.in              |  8 ++++--
 ld/configure                |  6 +++--
 ld/configure.ac             |  1 +
 ld/testsuite/ld-ctf/ctf.exp |  5 ++++
 ld/testsuite/lib/ld-lib.exp | 52 +++++++++++++++++++++++++++++++++++++
 6 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 02c4fc16395..bf19f98f1f9 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -978,6 +978,9 @@ check-DEJAGNU: site.exp
 development.exp: $(BFDDIR)/development.sh
 	$(EGREP) "[development|experimental]=" $(BFDDIR)/development.sh  \
 	  | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+
+enablings.exp:
+	echo "set enable_libctf ${enable_libctf}" >> $@
 #
 #
 # Build a dummy plugin using libtool.
@@ -1024,7 +1027,7 @@ MAINTAINERCLEANFILES = configdoc.texi ld.1
 CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host $(srcdir)/configure.tgt \
 	$(BFDDIR)/development.sh
 
-EXTRA_DEJAGNU_SITE_CONFIG = development.exp
+EXTRA_DEJAGNU_SITE_CONFIG = development.exp enablings.exp
 
 MOSTLYCLEANFILES = $(STAGESTUFF) ld1$(EXEEXT) ld2$(EXEEXT) ld3$(EXEEXT) \
 	ldemul-list.h crtbegin.@OBJEXT@ crtend.@OBJEXT@ ld.log ld.sum
@@ -1071,7 +1074,7 @@ diststuff: info $(EXTRA_DIST)
 # ld.1 to support parallel build.
 info-recursive: ld.1
 
-DISTCLEANFILES = site.exp development.exp site.bak stringify.sed
+DISTCLEANFILES = site.exp development.exp enablings.exp site.bak stringify.sed
 distclean-local:
 	rm -rf ldscripts
 
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 2fe12e14f63..27350415b30 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -492,6 +492,7 @@ elf_list_options = @elf_list_options@
 elf_plt_unwind_list_options = @elf_plt_unwind_list_options@
 elf_shlib_list_options = @elf_shlib_list_options@
 enable_initfini_array = @enable_initfini_array@
+enable_libctf = @enable_libctf@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
@@ -1019,7 +1020,7 @@ MAINTAINERCLEANFILES = configdoc.texi ld.1 ld.info
 CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host $(srcdir)/configure.tgt \
 	$(BFDDIR)/development.sh
 
-EXTRA_DEJAGNU_SITE_CONFIG = development.exp
+EXTRA_DEJAGNU_SITE_CONFIG = development.exp enablings.exp
 MOSTLYCLEANFILES = $(STAGESTUFF) ld1$(EXEEXT) ld2$(EXEEXT) ld3$(EXEEXT) \
 	ldemul-list.h crtbegin.@OBJEXT@ crtend.@OBJEXT@ ld.log ld.sum
 
@@ -1030,7 +1031,7 @@ CLEANFILES = dep.sed DEP DEPA DEP1 DEP2 spu_ovl.s spu_ovl.@OBJEXT@ spu_icache.s
 EXTRA_DIST = ldgram.c ldgram.h ldlex.c emultempl/spu_ovl.@OBJEXT@_c \
 	     emultempl/spu_icache.@OBJEXT@_c deffilep.c deffilep.h $(man_MANS)
 
-DISTCLEANFILES = site.exp development.exp site.bak stringify.sed
+DISTCLEANFILES = site.exp development.exp enablings.exp site.bak stringify.sed
 all: $(BUILT_SOURCES) config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -2555,6 +2556,9 @@ development.exp: $(BFDDIR)/development.sh
 	$(EGREP) "[development|experimental]=" $(BFDDIR)/development.sh  \
 	  | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
 
+enablings.exp:
+	echo "set enable_libctf ${enable_libctf}" >> $@
+
 # DOCUMENTATION TARGETS
 # Manual configuration file; not usually attached to normal configuration,
 # because almost all configs use "gen" version of manual.
diff --git a/ld/configure b/ld/configure
index 11c69bec7b9..9ff13c3c72b 100755
--- a/ld/configure
+++ b/ld/configure
@@ -678,6 +678,7 @@ WARN_WRITE_STRINGS
 NO_WERROR
 WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
+enable_libctf
 ENABLE_LIBCTF_FALSE
 ENABLE_LIBCTF_TRUE
 installed_linker
@@ -12037,7 +12038,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12040 "configure"
+#line 12041 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12143,7 +12144,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12146 "configure"
+#line 12147 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15958,6 +15959,7 @@ fi
 
 
 
+
 # Set the 'development' global.
 . $srcdir/../bfd/development.sh
 
diff --git a/ld/configure.ac b/ld/configure.ac
index 5a4938afdb0..5ef25e3eb88 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -226,6 +226,7 @@ if test "${enable_libctf}" = yes; then
     AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
 fi
 AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
+AC_SUBST(enable_libctf)
 
 AM_BINUTILS_WARNINGS
 
diff --git a/ld/testsuite/ld-ctf/ctf.exp b/ld/testsuite/ld-ctf/ctf.exp
index 9a248f90ec4..3e44de7aaab 100644
--- a/ld/testsuite/ld-ctf/ctf.exp
+++ b/ld/testsuite/ld-ctf/ctf.exp
@@ -18,6 +18,11 @@
 # MA 02110-1301, USA.
 #
 
+if [skip_ctf_tests] {
+    unsupported "no CTF format support in the compiler, or CTF disabled"
+    return 0
+}
+
 set ctf_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
 
 foreach ctf_test $ctf_test_list {
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 8d851a94b71..8d476ca48f3 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1569,3 +1569,55 @@ proc check_gnu2_tls_available { } {
     }
     return $gnu2_tls_available_saved
 }
+
+# Compile a C source file, with the specified additional_flags.
+proc compile_one_cc { src output additional_flags } {
+    global CC
+    global CFLAGS
+
+    set flags ""
+    if [board_info [target_info name] exists cflags] {
+	append flags " [board_info [target_info name] cflags]"
+    }
+    if [board_info [target_info name] exists ldflags] {
+	append flags " [board_info [target_info name] ldflags]"
+    }
+
+    if [is_remote host] {
+	set src [remote_download host $src]
+    }
+    return [run_host_cmd_yesno "$CC" "$flags $CFLAGS $additional_flags $src -o $output"]
+}
+
+# Returns true if the target compiler supports -gt
+proc check_ctf_available { } {
+    global ctf_available_saved
+
+    if {![info exists ctf_available_saved]} {
+	set basename "tmpdir/ctf_available[pid]"
+	set src ${basename}.c
+	set output ${basename}.o
+	set f [open $src "w"]
+	puts $f "int main() { return 0; }"
+	close $f
+	set ctf_available_saved [compile_one_cc $src $output "-gt -c"]
+	remote_file host delete $src
+	remote_file host delete $output
+	file delete $src
+    }
+    return $ctf_available_saved
+}
+
+proc skip_ctf_tests { } {
+    global enable_libctf
+
+    if {$enable_libctf eq "no"} {
+	return 1
+    }
+
+    if [check_ctf_available] {
+	return 0
+    }
+
+    return 1
+}
-- 
2.27.0.247.g3dff7de930


  parent reply	other threads:[~2020-06-30 23:32 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 23:30 [PATCH 00/59] Deduplicating CTF linker Nick Alcock
2020-06-30 23:30 ` [PATCH 01/59] include, libctf: typo fixes Nick Alcock
2020-06-30 23:30 ` [PATCH 02/59] libctf: restructure error handling to reduce relocations Nick Alcock
2020-07-22  9:31   ` [PATCH 02/59] fixup! " Nick Alcock
2020-06-30 23:30 ` [PATCH 03/59] libctf, create: support addition of references to the unimplemented type Nick Alcock
2020-06-30 23:30 ` [PATCH 04/59] libctf, create: do not corrupt function types' arglists at insertion time Nick Alcock
2020-06-30 23:30 ` [PATCH 05/59] libctf, create: add explicit casts for variables' and slices' types Nick Alcock
2020-06-30 23:30 ` [PATCH 06/59] libctf, types: allow ctf_type_reference of dynamic slices Nick Alcock
2020-06-30 23:30 ` [PATCH 07/59] libctf, open: drop unnecessary historical wart around forwards Nick Alcock
2020-06-30 23:30 ` [PATCH 08/59] libctf, create: member names of "" and NULL should be the same Nick Alcock
2020-06-30 23:30 ` [PATCH 09/59] libctf, create: fix addition of anonymous struct/union members Nick Alcock
2020-06-30 23:30 ` [PATCH 10/59] libctf, create: empty dicts are dirty to start with Nick Alcock
2020-06-30 23:30 ` [PATCH 11/59] libctf, types: support slices of anything terminating in an int Nick Alcock
2020-06-30 23:30 ` [PATCH 12/59] libctf, types: ints, floats and typedefs with no name are invalid Nick Alcock
2020-06-30 23:31 ` [PATCH 13/59] libctf, archive: stop ctf_arc_bufopen triggering crazy unmaps Nick Alcock
2020-06-30 23:31 ` [PATCH 14/59] libctf: having debugging enabled is unlikely Nick Alcock
2020-06-30 23:31 ` [PATCH 15/59] libctf: add ctf_type_name_raw Nick Alcock
2020-06-30 23:31 ` [PATCH 16/59] libctf: add ctf_type_kind_forwarded Nick Alcock
2020-06-30 23:31 ` [PATCH 17/59] libctf: add ctf_member_count Nick Alcock
2020-06-30 23:31 ` [PATCH 18/59] libctf: add ctf_archive_count Nick Alcock
2020-06-30 23:31 ` [PATCH 19/59] libctf: fix __extension__ with non-GNU C compilers Nick Alcock
2020-06-30 23:31 ` [PATCH 20/59] libctf: add new dynhash functions Nick Alcock
2020-06-30 23:31 ` [PATCH 21/59] libctf, hash: improve insertion of existing keys into dynhashes Nick Alcock
2020-06-30 23:31 ` [PATCH 22/59] libctf, hash: save per-item space when no key/item freeing function Nick Alcock
2020-06-30 23:31 ` [PATCH 23/59] libctf, hash: introduce the ctf_dynset Nick Alcock
2020-06-30 23:31 ` [PATCH 24/59] libctf: move existing inlines into ctf-inlines.h Nick Alcock
2020-06-30 23:31 ` [PATCH 25/59] libctf: add ctf_forwardable_kind Nick Alcock
2020-06-30 23:31 ` [PATCH 26/59] libctf: add ctf_ref Nick Alcock
2020-06-30 23:31 ` [PATCH 27/59] libctf, next: introduce new class of easier-to-use iterators Nick Alcock
2020-07-22  9:29   ` [PATCH 27/59] fixup! " Nick Alcock
2020-06-30 23:31 ` [PATCH 28/59] libctf, next, hash: add dynhash and dynset _next iteration Nick Alcock
2020-06-30 23:31 ` [PATCH 29/59] libctf: pass the thunk down properly when wrapping qsort_r Nick Alcock
2020-06-30 23:31 ` [PATCH 30/59] libctf: error out on corrupt CTF with invalid header flags Nick Alcock
2020-06-30 23:31 ` [PATCH 31/59] libctf, types: ensure the emission of ECTF_NOPARENT Nick Alcock
2020-06-30 23:31 ` [PATCH 32/59] libctf, ld, binutils: add textual error/warning reporting for libctf Nick Alcock
2020-06-30 23:31 ` [PATCH 33/59] libctf, types: enhance ctf_type_aname to print function arg types Nick Alcock
2020-06-30 23:31 ` [PATCH 34/59] libctf, decl: avoid leaks of the formatted string on error Nick Alcock
2020-06-30 23:31 ` [PATCH 35/59] libctf, dump: migrate towards dumping errors rather than truncation Nick Alcock
2020-06-30 23:31 ` [PATCH 36/59] libctf, dump: fix slice dumping Nick Alcock
2020-06-30 23:31 ` [PATCH 37/59] libctf, open: fix opening CTF in binaries with no symtab Nick Alcock
2020-06-30 23:31 ` [PATCH 38/59] libctf, archive: fix bad error message Nick Alcock
2020-06-30 23:31 ` [PATCH 39/59] libctf: check for vasprintf Nick Alcock
2020-06-30 23:31 ` [PATCH 40/59] libctf: rename the type_mapping_key to type_key Nick Alcock
2020-07-22  9:35   ` [PATCH 40/59] fixup! " Nick Alcock
2020-06-30 23:31 ` [PATCH 41/59] libctf: sort out potential refcount loops Nick Alcock
2020-06-30 23:31 ` [PATCH 42/59] libctf: drop error-prone ctf_strerror Nick Alcock
2020-06-30 23:31 ` [PATCH 43/59] libctf, link: add lazy linking: clean up input members: err/warn cleanup Nick Alcock
2020-06-30 23:31 ` [PATCH 44/59] libctf, link: fix ctf_link_write fd leak Nick Alcock
2020-06-30 23:31 ` [PATCH 45/59] libctf, link: redo cu-mapping handling Nick Alcock
2020-06-30 23:31 ` [PATCH 46/59] ctf, link: fix spurious conflicts of variables in the variable section Nick Alcock
2020-07-01 10:40   ` Nick Alcock
2020-06-30 23:31 ` [PATCH 47/59] libctf, link: add the ability to filter out variables from the link Nick Alcock
2020-06-30 23:31 ` [PATCH 48/59] libctf: add SHA-1 support for libctf Nick Alcock
2020-06-30 23:31 ` [PATCH 49/59] libctf, dedup: add new configure option --enable-libctf-hash-debugging Nick Alcock
2020-07-22  9:30   ` [PATCH 49/59] fixup! " Nick Alcock
2020-06-30 23:31 ` [PATCH 50/59] libctf, dedup: add deduplicator Nick Alcock
2020-07-22  9:33   ` [PATCH 50/59] squash! " Nick Alcock
2020-07-22  9:33   ` [PATCH 50/59] fixup! " Nick Alcock
2020-07-22  9:34   ` Nick Alcock
2020-06-30 23:31 ` [PATCH 51/59] libctf, link: add CTF_LINK_OMIT_VARIABLES_SECTION Nick Alcock
2020-06-30 23:31 ` [PATCH 52/59] libctf, link: tie in the deduplicating linker Nick Alcock
2020-07-22  9:36   ` [PATCH 52/59] fixup! " Nick Alcock
2020-06-30 23:31 ` [PATCH 53/59] binutils: objdump: ctf: drop incorrect linefeeds Nick Alcock
2020-06-30 23:31 ` [PATCH 54/59] ld: Reformat CTF errors into warnings Nick Alcock
2020-06-30 23:31 ` [PATCH 55/59] ld: new options --ctf-variables and --ctf-share-types Nick Alcock
2020-06-30 23:31 ` [PATCH 56/59] binutils, testsuite: allow compilation before doing run_dump_test Nick Alcock
2020-06-30 23:31 ` [PATCH 57/59] ld: new CTF testsuite Nick Alcock
2020-06-30 23:31 ` Nick Alcock [this message]
2020-07-22  9:32   ` [PATCH 58/59] fixup! ld, testsuite: only run CTF tests when ld and GCC support CTF Nick Alcock
2020-06-30 23:31 ` [PATCH 59/59] ld: do not produce one empty output .ctf section for every input .ctf Nick Alcock
2020-07-14 21:31 ` [PATCH 00/59] Deduplicating CTF linker Nick Alcock
2020-07-20  5:49   ` Alan Modra
2020-07-20 21:06     ` Nick Alcock
2020-07-22  9:39 ` [PATCH 0/4] fallout of various portability testing Nick Alcock
2020-07-22  9:39   ` [PATCH 1/4] ld, testsuite: do not run CTF tests at all on non-ELF for now Nick Alcock
2020-07-22  9:39   ` [PATCH 2/4] libctf, binutils: fix big-endian libctf archive opening Nick Alcock
2020-07-22  9:39   ` [PATCH 3/4] libctf: fix isspace casts Nick Alcock
2020-07-22  9:39   ` [PATCH 4/4] libctf: fixes for systems on which sizeof (void *) > sizeof (long) Nick Alcock
2020-07-22 14:06   ` [PATCH 0/4] fallout of various portability testing Nick Alcock
2020-07-22 17:08 ` [PATCH 00/59] Deduplicating CTF linker Nick Alcock

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=20200630233146.338613-59-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=binutils@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).