From 36eadb569a31a87b610b9b70e225a981dc181df4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 28 Feb 2018 18:56:26 -0500 Subject: [PATCH] run coroutine tests only in Debug mode LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code. So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet. Luckily, Clang users are running into the same crashes, so folks from the LLVM community are working on fixes. If we're really lucky they'll be fixed in 6.0.1. Otherwise we can hope for 7.0.0. --- test/behavior.zig | 14 +++++++++++++- test/cases/coroutines.zig | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/behavior.zig b/test/behavior.zig index 81f2c5dd00..b9cfeb8e0b 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -1,3 +1,5 @@ +const builtin = @import("builtin"); + comptime { _ = @import("cases/align.zig"); _ = @import("cases/alignof.zig"); @@ -11,7 +13,6 @@ comptime { _ = @import("cases/bugs/656.zig"); _ = @import("cases/cast.zig"); _ = @import("cases/const_slice_child.zig"); - _ = @import("cases/coroutines.zig"); _ = @import("cases/defer.zig"); _ = @import("cases/enum.zig"); _ = @import("cases/enum_with_members.zig"); @@ -48,4 +49,15 @@ comptime { _ = @import("cases/var_args.zig"); _ = @import("cases/void.zig"); _ = @import("cases/while.zig"); + + + // LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code. + // So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet. + // Luckily, Clang users are running into the same crashes, so folks from the LLVM + // community are working on fixes. If we're really lucky they'll be fixed in 6.0.1. + // Otherwise we can hope for 7.0.0. + if (builtin.mode == builtin.Mode.Debug) { + _ = @import("cases/coroutines.zig"); + } + } diff --git a/test/cases/coroutines.zig b/test/cases/coroutines.zig index a20a314c8b..f5e70774fa 100644 --- a/test/cases/coroutines.zig +++ b/test/cases/coroutines.zig @@ -4,12 +4,12 @@ const assert = std.debug.assert; var x: i32 = 1; test "create a coroutine and cancel it" { - const p = try (async(std.debug.global_allocator) emptyAsyncFn()); + const p = try (async(std.debug.global_allocator) simpleAsyncFn()); cancel p; assert(x == 2); } -async fn emptyAsyncFn() void { +async fn simpleAsyncFn() void { x += 1; suspend; x += 1;