Commit b57e1621 by Iain Buclaw

testsuite: Disable gdc standard runtime tests if phobos is not built.

The current check_effective_target_d_runtime procedure returns false if
the target is built without any core runtime library for D being
available (--disable-libphobos).  This additional procedure is for
targets where the core runtime library exists, but without the higher
level standard library.

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* gdc.dg/link.d: Use d_runtime_has_std_library effective target.
	* gdc.dg/runnable.d: Move phobos tests to...
	* gdc.dg/runnable2.d: ...here.  New test.
	* lib/target-supports.exp
	(check_effective_target_d_runtime_has_std_library): New.

libphobos/ChangeLog:

	* testsuite/libphobos.phobos/phobos.exp: Skip if effective target is
	not d_runtime_has_std_library.
	* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
parent f83adb68
2020-04-18 Iain Buclaw <ibuclaw@gdcproject.org>
* doc/sourcebuild.texi (Effective-Target Keywords, Environment
attributes): Document d_runtime_has_std_library.
2020-04-17 Jeff Law <law@redhat.com> 2020-04-17 Jeff Law <law@redhat.com>
PR rtl-optimization/90275 PR rtl-optimization/90275
......
...@@ -2207,6 +2207,9 @@ overloads for @code{strchr} etc. functions. ...@@ -2207,6 +2207,9 @@ overloads for @code{strchr} etc. functions.
@item d_runtime @item d_runtime
Target provides the D runtime. Target provides the D runtime.
@item d_runtime_has_std_library
Target provides the D standard library (Phobos).
@item dummy_wcsftime @item dummy_wcsftime
Target uses a dummy @code{wcsftime} function that always returns zero. Target uses a dummy @code{wcsftime} function that always returns zero.
......
2020-04-18 Iain Buclaw <ibuclaw@gdcproject.org>
* gdc.dg/link.d: Use d_runtime_has_std_library effective target.
* gdc.dg/runnable.d: Move phobos tests to...
* gdc.dg/runnable2.d: ...here. New test.
* lib/target-supports.exp
(check_effective_target_d_runtime_has_std_library): New.
2020-04-18 Patrick Palka <ppalka@redhat.com> 2020-04-18 Patrick Palka <ppalka@redhat.com>
PR c++/94632 PR c++/94632
......
// { dg-do link { target d_runtime } } // { dg-do link { target d_runtime_has_std_library } }
/******************************************/ /******************************************/
......
...@@ -10,20 +10,6 @@ import gcc.attribute; ...@@ -10,20 +10,6 @@ import gcc.attribute;
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=2
struct S
{
string toString() { return "foo"; }
}
void test2()
{
import std.string : format;
assert(format("%s", S()) == "foo");
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=4 // https://bugzilla.gdcproject.org/show_bug.cgi?id=4
void test4() void test4()
...@@ -34,35 +20,6 @@ void test4() ...@@ -34,35 +20,6 @@ void test4()
} }
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=15
class B
{
class A { }
A a;
}
class C
{
void visit(B b)
{
import std.algorithm : map;
auto as = [b.a];
as.map!(d => d);
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=16
void test16()
{
import std.parallelism : taskPool;
taskPool.reduce!"a+b"([0, 1, 2, 3]);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=17 // https://bugzilla.gdcproject.org/show_bug.cgi?id=17
/** /**
...@@ -100,59 +57,6 @@ void test17() ...@@ -100,59 +57,6 @@ void test17()
} }
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=18
class C18
{
struct Link
{
int x;
int y;
}
void sort_links()
{
import std.algorithm : sort;
import std.array : empty;
import std.exception : enforce;
enforce(!_link.empty);
bool lt(Link a, Link b)
{
if(a.x > b.x)
return false;
if(a.x < b.x)
return true;
if(a.y >= b.y)
return false;
else
return true;
}
sort!(lt)(_link);
}
this()
{
_link ~= Link(8, 3);
_link ~= Link(4, 7);
_link ~= Link(4, 6);
_link ~= Link(3, 7);
_link ~= Link(2, 7);
_link ~= Link(2, 2);
_link ~= Link(4, 1);
}
Link[] _link;
}
void test18()
{
C18 foo = new C18;
foo.sort_links();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=19 // https://bugzilla.gdcproject.org/show_bug.cgi?id=19
void test19() void test19()
...@@ -178,22 +82,6 @@ void test24() ...@@ -178,22 +82,6 @@ void test24()
} }
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=29
void test29()
{
import std.string : format;
import std.conv : text;
string s;
for (auto i = 0; i < 100000; i++)
{
s = format("%d", i);
s = text(i);
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=31 // https://bugzilla.gdcproject.org/show_bug.cgi?id=31
class RedBlackTree(T, alias less) class RedBlackTree(T, alias less)
...@@ -500,54 +388,6 @@ void test51() ...@@ -500,54 +388,6 @@ void test51()
} }
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=52
class C52
{
C52 a;
this()
{
printf("Construct: this=%p\n", cast(void*)this);
a = this;
}
bool check()
{
printf("Check: this=%p a=%p\n", cast(void*)this, cast(void*)a);
return this is a;
}
}
auto test52a()
{
import std.conv, std.traits;
struct Scoped
{
void[__traits (classInstanceSize, C52) ] Scoped_store = void;
inout(C52) Scoped_payload() inout
{
void* alignedStore = cast(void*) Scoped_store.ptr;
return cast(inout (C52)) alignedStore;
}
alias Scoped_payload this;
}
Scoped result;
emplace!(Unqual!C52)(result.Scoped_store);
assert(result.Scoped_payload().check);
return result;
}
void test52()
{
auto a1 = test52a();
assert(a1.Scoped_payload().check);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=57 // https://bugzilla.gdcproject.org/show_bug.cgi?id=57
struct S57 struct S57
...@@ -589,54 +429,6 @@ __vector(float[4]) d[2]; // ICE ...@@ -589,54 +429,6 @@ __vector(float[4]) d[2]; // ICE
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=71
struct Leaf
{
ubyte symbol;
ubyte codeLen;
}
struct CanonicalHuffman
{
Leaf[] table;
void print()
{
import std.algorithm;
import std.range;
auto list = zip(iota(table.length), table.dup).array
.sort!((a, b) => a[1].symbol < b[1].symbol)
.uniq!((a, b) => (a[0] & (1 << a[1].codeLen) - 1) == (b[0] & (1 << b[1].codeLen) - 1));
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=77
void fun(ubyte[3] buf)
{
import std.bitmanip : bigEndianToNative;
bigEndianToNative!ushort(buf[0..2]);
}
void test77()
{
fun([1,2,3]);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=108
@attribute("forceinline")
void test108()
{
import std.stdio : writeln;
writeln("Here");
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=115 // https://bugzilla.gdcproject.org/show_bug.cgi?id=115
void test115() void test115()
...@@ -658,21 +450,6 @@ void test115() ...@@ -658,21 +450,6 @@ void test115()
immutable char C121 = void; // ICE immutable char C121 = void; // ICE
/******************************************/ /******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=122
void test122()
{
import std.algorithm : map;
import std.parallelism : taskPool;
import std.range : iota;
immutable n = 10000;
enum delta = 1.0 / n; // XBUG: was 'immutable delta' https://issues.dlang.org/show_bug.cgi?id=17092
immutable pi = 4.0 * delta * taskPool.reduce!"a + b"(
map!((int i) { immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x * x); })(iota(n)));
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=127 // https://bugzilla.gdcproject.org/show_bug.cgi?id=127
int[0] test127a; // OK int[0] test127a; // OK
...@@ -1584,20 +1361,14 @@ void test309() ...@@ -1584,20 +1361,14 @@ void test309()
void main() void main()
{ {
test2();
test4(); test4();
test16();
test17(); test17();
test18();
test35(); test35();
test36(); test36();
test43(); test43();
test51(); test51();
test52();
test57(); test57();
test66(); test66();
test77();
test108();
test115(); test115();
test131(); test131();
test133(); test133();
......
// { dg-do run { target { hw && d_runtime_has_std_library } } }
module runnable;
import core.stdc.stdio;
import gcc.attribute;
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=2
struct S
{
string toString() { return "foo"; }
}
void test2()
{
import std.string : format;
assert(format("%s", S()) == "foo");
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=15
class B
{
class A { }
A a;
}
class C
{
void visit(B b)
{
import std.algorithm : map;
auto as = [b.a];
as.map!(d => d);
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=16
void test16()
{
import std.parallelism : taskPool;
taskPool.reduce!"a+b"([0, 1, 2, 3]);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=18
class C18
{
struct Link
{
int x;
int y;
}
void sort_links()
{
import std.algorithm : sort;
import std.array : empty;
import std.exception : enforce;
enforce(!_link.empty);
bool lt(Link a, Link b)
{
if(a.x > b.x)
return false;
if(a.x < b.x)
return true;
if(a.y >= b.y)
return false;
else
return true;
}
sort!(lt)(_link);
}
this()
{
_link ~= Link(8, 3);
_link ~= Link(4, 7);
_link ~= Link(4, 6);
_link ~= Link(3, 7);
_link ~= Link(2, 7);
_link ~= Link(2, 2);
_link ~= Link(4, 1);
}
Link[] _link;
}
void test18()
{
C18 foo = new C18;
foo.sort_links();
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=29
void test29()
{
import std.string : format;
import std.conv : text;
string s;
for (auto i = 0; i < 100000; i++)
{
s = format("%d", i);
s = text(i);
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=52
class C52
{
C52 a;
this()
{
printf("Construct: this=%p\n", cast(void*)this);
a = this;
}
bool check()
{
printf("Check: this=%p a=%p\n", cast(void*)this, cast(void*)a);
return this is a;
}
}
auto test52a()
{
import std.conv, std.traits;
struct Scoped
{
void[__traits (classInstanceSize, C52) ] Scoped_store = void;
inout(C52) Scoped_payload() inout
{
void* alignedStore = cast(void*) Scoped_store.ptr;
return cast(inout (C52)) alignedStore;
}
alias Scoped_payload this;
}
Scoped result;
emplace!(Unqual!C52)(result.Scoped_store);
assert(result.Scoped_payload().check);
return result;
}
void test52()
{
auto a1 = test52a();
assert(a1.Scoped_payload().check);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=71
struct Leaf
{
ubyte symbol;
ubyte codeLen;
}
struct CanonicalHuffman
{
Leaf[] table;
void print()
{
import std.algorithm;
import std.range;
auto list = zip(iota(table.length), table.dup).array
.sort!((a, b) => a[1].symbol < b[1].symbol)
.uniq!((a, b) => (a[0] & (1 << a[1].codeLen) - 1) == (b[0] & (1 << b[1].codeLen) - 1));
}
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=77
void fun(ubyte[3] buf)
{
import std.bitmanip : bigEndianToNative;
bigEndianToNative!ushort(buf[0..2]);
}
void test77()
{
fun([1,2,3]);
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=108
@attribute("forceinline")
void test108()
{
import std.stdio : writeln;
writeln("Here");
}
/******************************************/
// https://bugzilla.gdcproject.org/show_bug.cgi?id=122
void test122()
{
import std.algorithm : map;
import std.parallelism : taskPool;
import std.range : iota;
immutable n = 10000;
enum delta = 1.0 / n; // XBUG: was 'immutable delta' https://issues.dlang.org/show_bug.cgi?id=17092
immutable pi = 4.0 * delta * taskPool.reduce!"a + b"(
map!((int i) { immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x * x); })(iota(n)));
}
/******************************************/
void main()
{
test2();
test16();
test18();
test52();
test77();
test108();
printf("Success!\n");
}
...@@ -8069,6 +8069,21 @@ proc check_effective_target_d_runtime { } { ...@@ -8069,6 +8069,21 @@ proc check_effective_target_d_runtime { } {
}] }]
} }
# Return 1 if the target provides the D standard library.
proc check_effective_target_d_runtime_has_std_library { } {
return [check_no_compiler_messages d_runtime_has_std_library executable {
// D
module mod;
extern(C) int main() {
import std.math;
real function(real) pcos = &cos;
return 0;
}
}]
}
# Return 1 if target wchar_t is at least 4 bytes. # Return 1 if target wchar_t is at least 4 bytes.
proc check_effective_target_4byte_wchar_t { } { proc check_effective_target_4byte_wchar_t { } {
......
2020-04-18 Iain Buclaw <ibuclaw@gdcproject.org>
* testsuite/libphobos.phobos/phobos.exp: Skip if effective target is
not d_runtime_has_std_library.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
2020-04-13 Iain Buclaw <ibuclaw@gdcproject.org> 2020-04-13 Iain Buclaw <ibuclaw@gdcproject.org>
* libdruntime/core/stdc/stdarg.d: Remove run-time va_list template. * libdruntime/core/stdc/stdarg.d: Remove run-time va_list template.
......
...@@ -19,6 +19,11 @@ if { ![isnative] || ![is-effective-target static] } { ...@@ -19,6 +19,11 @@ if { ![isnative] || ![is-effective-target static] } {
return return
} }
# Skip running test if phobos was not built on the target.
if { ![is-effective-target d_runtime_has_std_library] } {
return
}
# Gather a list of all tests. # Gather a list of all tests.
set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]] set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]]
......
...@@ -19,6 +19,11 @@ if { ![isnative] || ![is-effective-target shared] } { ...@@ -19,6 +19,11 @@ if { ![isnative] || ![is-effective-target shared] } {
return return
} }
# Skip running test if phobos was not built on the target.
if { ![is-effective-target d_runtime_has_std_library] } {
return
}
# Gather a list of all tests. # Gather a list of all tests.
set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]] set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment