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.
This commit is contained in:
Nick Alcock 2020-06-11 15:44:48 +01:00
parent b1b33524ad
commit 7cdfc3462f
7 changed files with 91 additions and 6 deletions

View File

@ -1,3 +1,16 @@
2020-07-22 Nick Alcock <nick.alcock@oracle.com>
* 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 <egeyar.bagcioglu@oracle.com>
* testsuite/ld-ctf/ctf.exp: New file.

View File

@ -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

View File

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

6
ld/configure vendored
View File

@ -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

View File

@ -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

View File

@ -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" } }
}

View File

@ -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
}