Commit e42b5e76ba

Jakub Konka <kubkon@jakubkonka.com>
2022-02-08 22:35:34
stage2: handle void type in Elf DWARF gen
Enable more behavior tests on both x64 and arm
1 parent c256603
Changed files (5)
src/link/Elf.zig
@@ -3057,8 +3057,10 @@ fn addDbgInfoType(
     var relocs = std.ArrayList(struct { ty: Type, reloc: u32 }).init(arena);
 
     switch (ty.zigTypeTag()) {
-        .Void => unreachable,
         .NoReturn => unreachable,
+        .Void => {
+            try dbg_info_buffer.append(abbrev_pad1);
+        },
         .Bool => {
             try dbg_info_buffer.appendSlice(&[_]u8{
                 abbrev_base_type,
test/behavior/bugs/2006.zig
@@ -7,7 +7,6 @@ const S = struct {
 };
 test "bug 2006" {
     if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
-    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     var a: S = undefined;
     a = S{ .p = undefined };
     try expect(@sizeOf(S) != 0);
test/behavior/bugs/3367.zig
@@ -12,7 +12,6 @@ const Mixin = struct {
 test "container member access usingnamespace decls" {
     if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
-    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     var foo = Foo{};
     foo.two();
 }
test/behavior/basic.zig
@@ -15,6 +15,8 @@ test "empty function with comments" {
 }
 
 test "truncate" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     try expect(testTruncate(0x10fd) == 0xfd);
     comptime try expect(testTruncate(0x10fd) == 0xfd);
 }
@@ -23,6 +25,9 @@ fn testTruncate(x: u32) u8 {
 }
 
 test "truncate to non-power-of-two integers" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     try testTrunc(u32, u1, 0b10101, 0b1);
     try testTrunc(u32, u1, 0b10110, 0b0);
     try testTrunc(u32, u2, 0b10101, 0b01);
@@ -108,14 +113,23 @@ fn first4KeysOfHomeRow() []const u8 {
 }
 
 test "return string from function" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
 }
 
 test "hex escape" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello"));
 }
 
 test "multiline string" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         \\one
         \\two)
@@ -126,6 +140,9 @@ test "multiline string" {
 }
 
 test "multiline string comments at start" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         //\\one
         \\two)
@@ -136,6 +153,9 @@ test "multiline string comments at start" {
 }
 
 test "multiline string comments at end" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         \\one
         \\two)
@@ -146,6 +166,9 @@ test "multiline string comments at end" {
 }
 
 test "multiline string comments in middle" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         \\one
         //\\two)
@@ -156,6 +179,9 @@ test "multiline string comments in middle" {
 }
 
 test "multiline string comments at multiple places" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         \\one
         //\\two
@@ -172,6 +198,9 @@ test "string concatenation" {
 }
 
 test "array mult operator" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     try expect(mem.eql(u8, "ab" ** 5, "ababababab"));
 }
 
@@ -195,6 +224,9 @@ test "compile time global reinterpret" {
 }
 
 test "cast undefined" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const array: [100]u8 = undefined;
     const slice = @as([]const u8, &array);
     testCastUndefined(slice);
@@ -204,6 +236,8 @@ fn testCastUndefined(x: []const u8) void {
 }
 
 test "implicit cast after unreachable" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     try expect(outer() == 1234);
 }
 fn inner() i32 {
@@ -259,6 +293,9 @@ fn fB() []const u8 {
 }
 
 test "call function pointer in struct" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     if (builtin.zig_backend == .stage1) return error.SkipZigTest;
 
     try expect(mem.eql(u8, f3(true), "a"));
@@ -282,6 +319,8 @@ const FnPtrWrapper = struct {
 };
 
 test "const ptr from var variable" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     var x: u64 = undefined;
     var y: u64 = undefined;
 
@@ -296,6 +335,8 @@ fn copy(src: *const u64, dst: *u64) void {
 }
 
 test "call result of if else expression" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
     if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
 
@@ -307,6 +348,8 @@ fn f2(x: bool) []const u8 {
 }
 
 test "memcpy and memset intrinsics" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
 
     try testMemcpyMemset();
@@ -327,6 +370,8 @@ fn testMemcpyMemset() !void {
 }
 
 test "variable is allowed to be a pointer to an opaque type" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
 
     var x: i32 = 1234;
@@ -338,6 +383,9 @@ fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {
 }
 
 test "take address of parameter" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     try testTakeAddressOfParameter(12.34);
 }
 fn testTakeAddressOfParameter(f: f32) !void {
@@ -360,6 +408,9 @@ fn testPointerToVoidReturnType2() *const void {
 }
 
 test "array 2D const double ptr" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
 
     const rect_2d_vertexes = [_][1]f32{
@@ -376,6 +427,9 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {
 }
 
 test "double implicit cast in same expression" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     var x = @as(i32, @as(u16, nine()));
     try expect(x == 9);
 }
@@ -384,6 +438,8 @@ fn nine() u8 {
 }
 
 test "struct inside function" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     try testStructInFn();
     comptime try testStructInFn();
 }
@@ -411,6 +467,8 @@ fn getNull() ?*i32 {
 }
 
 test "global variable assignment with optional unwrapping with var initialized to undefined" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     const S = struct {
         var data: i32 = 1234;
         fn foo() ?*i32 {
@@ -426,6 +484,9 @@ test "global variable assignment with optional unwrapping with var initialized t
 var global_foo: *i32 = undefined;
 
 test "peer result location with typed parent, runtime condition, comptime prongs" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const S = struct {
         fn doTheTest(arg: i32) i32 {
             const st = Structy{
@@ -523,6 +584,9 @@ test "self reference through fn ptr field" {
 }
 
 test "global variable initialized to global variable array element" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
 
     try expect(global_ptr == &gdt[0]);
@@ -537,6 +601,8 @@ var gdt = [_]GDTEntry{
 var global_ptr = &gdt[0];
 
 test "global constant is loaded with a runtime-known index" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+
     const S = struct {
         fn doTheTest() !void {
             var index: usize = 1;
@@ -552,6 +618,9 @@ test "global constant is loaded with a runtime-known index" {
 }
 
 test "multiline string literal is null terminated" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const s1 =
         \\one
         \\two)
@@ -582,6 +651,9 @@ test "explicit cast optional pointers" {
 }
 
 test "pointer comparison" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const a = @as([]const u8, "a");
     const b = &a;
     try expect(ptrEql(b, b));
@@ -591,6 +663,9 @@ fn ptrEql(a: *const []const u8, b: *const []const u8) bool {
 }
 
 test "string concatenation" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
     const a = "OK" ++ " IT " ++ "WORKED";
     const b = "OK IT WORKED";
 
@@ -610,6 +685,8 @@ test "string concatenation" {
 }
 
 test "thread local variable" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
 
     const S = struct {
@@ -634,6 +711,8 @@ fn maybe(x: bool) anyerror!?u32 {
 }
 
 test "pointer to thread local array" {
+    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
 
     const s = "Hello world";
test/behavior.zig
@@ -4,6 +4,7 @@ test {
     _ = @import("behavior/align.zig");
     _ = @import("behavior/alignof.zig");
     _ = @import("behavior/array.zig");
+    _ = @import("behavior/basic.zig");
     _ = @import("behavior/bit_shifting.zig");
     _ = @import("behavior/bool.zig");
     _ = @import("behavior/bugs/394.zig");
@@ -43,7 +44,6 @@ test {
     if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
         // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
         _ = @import("behavior/array_llvm.zig");
-        _ = @import("behavior/basic.zig");
         _ = @import("behavior/bitcast.zig");
         _ = @import("behavior/bugs/624.zig");
         _ = @import("behavior/bugs/704.zig");