From: Nick Alcock Date: Thu, 11 Jun 2020 14:44:48 +0000 (+0100) Subject: ld, testsuite: only run CTF tests when ld and GCC support CTF X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7cdfc3462fbbb27727ddd83d356cf79af8854740;p=binutils-gdb.git ld, testsuite: only run CTF tests when ld and GCC support CTF 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. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 0d305333504..bd0c6ccd688 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,16 @@ +2020-07-22 Nick Alcock + + * 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. + 2020-07-22 Egeyar Bagcioglu * testsuite/ld-ctf/ctf.exp: New file. diff --git a/ld/Makefile.am b/ld/Makefile.am index 38ff2d9bc0a..168f65dfe77 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -974,6 +974,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. @@ -1020,7 +1023,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 @@ -1067,7 +1070,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 aaf322ddf38..0c4dff3615d 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@ @@ -1017,7 +1018,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 @@ -1028,7 +1029,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 @@ -2549,6 +2550,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 8e6dcb76d07..b63bc88bdfc 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..5d177afef0d 100644 --- a/ld/testsuite/ld-ctf/ctf.exp +++ b/ld/testsuite/ld-ctf/ctf.exp @@ -18,9 +18,19 @@ # 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 { + if [string equal -length [string length "diag-"] "diag-" [file tail $ctf_test]] { + if ![is_elf_format] { + continue + } + } verbose [file rootname $ctf_test] run_dump_test [file rootname $ctf_test] { { cc "-gt -fPIC" } } } diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 69519af25d0..d1ffab7dc46 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 +}