On Thu, May 14, 2020 at 1:42 PM Jeff Law <l...@redhat.com> wrote:
>
> On Fri, 2020-05-08 at 12:12 -0700, H.J. Lu via Gcc-patches wrote:
> > Since libgccjit.so is linked into jit tests, skip jit tests for targets
> > that don't support -lgccjit.
> >
> > OK for master?
> >
> > H.J.
> > ---
> >       PR jit/94778
> >       * jit.dg/jit.exp: Skip jit tests for targets that don't support
> >       -lgccjit.
> >       * lib/target-supports.exp (check_effective_target_lgccjit): New.
> I believe the new dejagnu tests needs to be documented in sourcebuild.texi.
>
> OK with the sourcebuild.texi changes included.
>

This is the patch I am checking in.

Thanks.

-- 
H.J.
From 0162e4ffaa40a1a879abf5e59671b80790df17eb Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.to...@gmail.com>
Date: Fri, 8 May 2020 12:09:11 -0700
Subject: [PATCH] Skip jit tests for targets that don't support -lgccjit

Since libgccjit.so is linked into jit tests, skip jit tests for targets
that don't support -lgccjit.

gcc/

	PR jit/94778
	* doc/sourcebuild.texi: Document effective target lgccjit.

gcc/testsuite/

	PR jit/94778
	* jit.dg/jit.exp: Skip jit tests for targets that don't support
	-lgccjit.
	* lib/target-supports.exp (check_effective_target_lgccjit): New.
---
 gcc/doc/sourcebuild.texi              |  3 +++
 gcc/testsuite/jit.dg/jit.exp          |  5 +++++
 gcc/testsuite/lib/target-supports.exp | 15 +++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 240d6e4b08e..0f70e4baca9 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2494,6 +2494,9 @@ Target uses comdat groups.
 @item indirect_calls
 Target supports indirect calls, i.e. calls where the target is not
 constant.
+
+@item lgccjit
+Target supports -lgccjit, i.e. libgccjit.so can be linked into jit tests.
 @end table
 
 @subsubsection Local to tests in @code{gcc.target/i386}
diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index 13e8ab4dbfe..2f54681713b 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -38,6 +38,11 @@ load_lib gcc.exp
 load_lib g++.exp
 load_lib dejagnu.exp
 
+# Skip these tests for targets that don't support -lgccjit
+if { ![check_effective_target_lgccjit] } {
+    return
+}
+
 # Look for lines of the form:
 #   definitely lost: 11,316 bytes in 235 blocks
 #   indirectly lost: 352 bytes in 4 blocks
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 88f4a9cd812..3e91a81dd5a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -10234,3 +10234,18 @@ proc check_effective_target_indirect_calls { } {
   }
   return 1
 }
+
+# Return 1 if we can use the -lgccjit option, 0 otherwise.
+
+proc check_effective_target_lgccjit { } {
+  if { [info procs jit_target_compile] == "" } then {
+    global GCC_UNDER_TEST
+    if ![info exists GCC_UNDER_TEST] {
+      set GCC_UNDER_TEST "[find_gcc]"
+    }
+    proc jit_target_compile { source dest type options } [info body gcc_target_compile]
+  }
+  return [check_no_compiler_messages lgccjit executable {
+     int main() { return 0; }
+  } "-lgccjit"]
+}
-- 
2.26.2

Reply via email to