[testsuite] Disable gdc execution tests without libphobos

Message ID yddd0qtfb53.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • [testsuite] Disable gdc execution tests without libphobos
Related show

Commit Message

Rainer Orth Nov. 25, 2018, 3:08 p.m.
On targets with gdc enabled (most with --enable-languages=all or with an
explicit --enable-languges=d), but libphobos not built (many), all gdc.*
execution tests FAIL because already libgphobos.spec is missing.

This is easy to avoid, however, as the following patch does.  It adds D
support to check_compile and a new effective-target keyword d_runtime.
Except for two cases, the execution of D tests can be inhibited by
demoting link and run tests to compile in gdc-dg-test, so the patch is
pretty unintrusive.

Two instances needed special handling:

* gdc.dg/runnable.d won't even compile because it requires gcc/config.d,
  which is only created at libphobos configure time.

* The gdc.dg/lto tests don't ultimately use dg-test/gdc-dg-test, so need
  to be disabled explicitly if !d_runtime.

Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11 (which don't currently build libphobos by default)
and x86_64-pc-linux-gnu (which does).

Since this is a pure testsuite patch, I don't need approval, but it
would be good if Iain could have a look nonetheless.

Thanks.
        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-11-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/testsuite:
	* lib/target-supports.exp (check_compile): Handle D.
	(check_effective_target_d_runtime): New proc.
	* lib/gdc-dg.exp (gdc-dg-test): Demote link and run tests to
	compile unless d_runtime.
	* gdc.dg/runnable.d: Skip unless d_runtime.
	* gdc.dg/lto/lto.exp: Require d_runtime to run tests.

	gcc:
	* doc/sourcebuild.texi (Effective-Target Keywords, Environment
	attributes): Document d_runtime.

Comments

Iain Buclaw Nov. 25, 2018, 3:20 p.m. | #1
On Sun, 25 Nov 2018 at 16:08, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>

> On targets with gdc enabled (most with --enable-languages=all or with an

> explicit --enable-languges=d), but libphobos not built (many), all gdc.*

> execution tests FAIL because already libgphobos.spec is missing.

>

> This is easy to avoid, however, as the following patch does.  It adds D

> support to check_compile and a new effective-target keyword d_runtime.

> Except for two cases, the execution of D tests can be inhibited by

> demoting link and run tests to compile in gdc-dg-test, so the patch is

> pretty unintrusive.

>

> Two instances needed special handling:

>

> * gdc.dg/runnable.d won't even compile because it requires gcc/config.d,

>   which is only created at libphobos configure time.

>

> * The gdc.dg/lto tests don't ultimately use dg-test/gdc-dg-test, so need

>   to be disabled explicitly if !d_runtime.

>

> Bootstrapped without regressions on i386-pc-solaris2.11,

> sparc-sun-solaris2.11 (which don't currently build libphobos by default)

> and x86_64-pc-linux-gnu (which does).

>

> Since this is a pure testsuite patch, I don't need approval, but it

> would be good if Iain could have a look nonetheless.

>


Seems reasonable.  Thanks.

-- 
Iain

Patch

# HG changeset patch
# Parent  8713fc589a6f9bd72ae5683bec78f7f8a1083079
Disable gdc execution tests without libphobos

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2106,6 +2106,9 @@  Target provides a full C99 runtime.
 Target @code{string.h} and @code{wchar.h} headers provide C++ required
 overloads for @code{strchr} etc. functions.
 
+@item d_runtime
+Target provides the D runtime.
+
 @item dummy_wcsftime
 Target uses a dummy @code{wcsftime} function that always returns zero.
 
diff --git a/gcc/testsuite/gdc.dg/lto/lto.exp b/gcc/testsuite/gdc.dg/lto/lto.exp
--- a/gcc/testsuite/gdc.dg/lto/lto.exp
+++ b/gcc/testsuite/gdc.dg/lto/lto.exp
@@ -36,6 +36,11 @@  if { ![check_effective_target_lto] } {
     return
 }
 
+# Likewise if the D runtime library is missing.
+if { ![check_effective_target_d_runtime] } {
+    return
+}
+
 lto_init no-mathlib
 
 # Define an identifier for use with this suite to avoid name conflicts
diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
--- a/gcc/testsuite/gdc.dg/runnable.d
+++ b/gcc/testsuite/gdc.dg/runnable.d
@@ -1,5 +1,6 @@ 
 // { dg-additional-sources "imports/runnable.d" }
 // { dg-do run { target hw } }
+// { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
 
 module runnable;
 
diff --git a/gcc/testsuite/lib/gdc-dg.exp b/gcc/testsuite/lib/gdc-dg.exp
--- a/gcc/testsuite/lib/gdc-dg.exp
+++ b/gcc/testsuite/lib/gdc-dg.exp
@@ -19,6 +19,19 @@  load_lib gcc-dg.exp
 # Define gdc callbacks for dg.exp.
 
 proc gdc-dg-test { prog do_what extra_tool_flags } {
+    upvar dg-do-what dg-do-what
+
+    # Demote link and run tests to compile-only if D runtime is missing.
+    if ![check_effective_target_d_runtime] {
+	switch $do_what {
+	    link -
+	    run {
+		set do_what compile
+		set dg-do-what compile
+	    }
+	}
+    }
+
     set result \
         [gcc-dg-test-1 gdc_target_compile $prog $do_what $extra_tool_flags]
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -31,6 +31,7 @@ 
 # Assume by default that CONTENTS is C code.  
 # Otherwise, code should contain:
 # "// C++" for c++,
+# "// D" for D,
 # "! Fortran" for Fortran code,
 # "/* ObjC", for ObjC
 # "// ObjC++" for ObjC++
@@ -58,6 +59,7 @@  proc check_compile {basename type conten
     switch -glob -- $contents {
 	"*! Fortran*" { set src ${basename}[pid].f90 }
 	"*// C++*" { set src ${basename}[pid].cc }
+	"*// D*" { set src ${basename}[pid].d }
 	"*// ObjC++*" { set src ${basename}[pid].mm }
 	"*/* ObjC*" { set src ${basename}[pid].m }
 	"*// Go*" { set src ${basename}[pid].go }
@@ -7158,6 +7160,19 @@  proc check_effective_target_c99_runtime 
     }]
 }
 
+# Return 1 if the target provides the D runtime.
+
+proc check_effective_target_d_runtime { } {
+    return [check_no_compiler_messages d_runtime executable {
+	// D
+	module mod;
+
+	extern(C) int main() {
+	    return 0;
+	}
+    }]
+}
+
 # Return 1 if  target wchar_t is at least 4 bytes.
 
 proc check_effective_target_4byte_wchar_t { } {