From dbe9a5114e2d56f847b674539ffa0d28fc57ea78 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 16 Sep 2021 21:03:55 -0700 Subject: stage2: implement `@setAlignStack` and 128-bit cmpxchg * test runner is improved to respect `error.SkipZigTest` * start code is improved to `@setAlignStack(16)` before calling main() * the newly passing behavior test has a workaround for the fact that stage2 cannot yet call `std.Target.x86.featureSetHas()` at comptime. This is blocking on comptime closures. The workaround is that there is a new decl `@import("builtin").stage2_x86_cx16` which is a `bool`. * Implement `@setAlignStack`. This language feature should be re-evaluated at some point - I'll file an issue for it. * LLVM backend: apply/remove the cold attribute and noinline attribute where appropriate. * LLVM backend: loads and stores are properly annotated with alignment and volatile attributes. * LLVM backend: allocas are properly annotated with alignment. * Type: fix integers reporting wrong alignment for 256-bit integers and beyond. Once you get to 16 byte aligned, there is no further alignment for larger integers. --- lib/std/special/test_runner.zig | 10 +++++++++- lib/std/start.zig | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/std') diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig index c7375303e9..b762e7784e 100644 --- a/lib/std/special/test_runner.zig +++ b/lib/std/special/test_runner.zig @@ -123,8 +123,16 @@ pub fn log( } pub fn main2() anyerror!void { + var bad = false; // Simpler main(), exercising fewer language features, so that stage2 can handle it. for (builtin.test_functions) |test_fn| { - try test_fn.func(); + test_fn.func() catch |err| { + if (err != error.SkipZigTest) { + bad = true; + } + }; + } + if (bad) { + return error.TestsFailed; } } diff --git a/lib/std/start.zig b/lib/std/start.zig index d8e5796d37..057fde62f6 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -87,6 +87,11 @@ fn main2() callconv(.C) c_int { } fn _start2() callconv(.Naked) noreturn { + callMain2(); +} + +fn callMain2() noreturn { + @setAlignStack(16); root.main(); exit2(0); } -- cgit v1.2.3