aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-11 15:44:48 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 18:05:32 +0100
commit7cdfc3462fbbb27727ddd83d356cf79af8854740 (patch)
tree8099e7b67ee5dfcf13bcb816a85e87efc0e19c44 /ld/testsuite
parentb1b33524ad3c439badba3ce4fa51c0d5a317c4a5 (diff)
downloadgdb-7cdfc3462fbbb27727ddd83d356cf79af8854740.zip
gdb-7cdfc3462fbbb27727ddd83d356cf79af8854740.tar.gz
gdb-7cdfc3462fbbb27727ddd83d356cf79af8854740.tar.bz2
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.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-ctf/ctf.exp10
-rw-r--r--ld/testsuite/lib/ld-lib.exp52
2 files changed, 62 insertions, 0 deletions
diff --git a/ld/testsuite/ld-ctf/ctf.exp b/ld/testsuite/ld-ctf/ctf.exp
index 9a248f9..5d177af 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 69519af..d1ffab7 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
+}