authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-08 22:35:34+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-08 23:43:25+01:00
loge42b5e76bacaf221f3da3f4ffe769f603a51cf44
treeef7fe815d0657a7929fb769e35f8cc7110208ff1
parentc256603eaef162e7df004d3508bbd4f2ec3470eb

stage2: handle void type in Elf DWARF gen

Enable more behavior tests on both x64 and arm

5 files changed, 83 insertions(+), 4 deletions(-)

src/link/Elf.zig+3-1
...@@ -3057,8 +3057,10 @@ fn addDbgInfoType(...@@ -3057,8 +3057,10 @@ fn addDbgInfoType(
3057 var relocs = std.ArrayList(struct { ty: Type, reloc: u32 }).init(arena);3057 var relocs = std.ArrayList(struct { ty: Type, reloc: u32 }).init(arena);
30583058
3059 switch (ty.zigTypeTag()) {3059 switch (ty.zigTypeTag()) {
3060 .Void => unreachable,
3061 .NoReturn => unreachable,3060 .NoReturn => unreachable,
3061 .Void => {
3062 try dbg_info_buffer.append(abbrev_pad1);
3063 },
3062 .Bool => {3064 .Bool => {
3063 try dbg_info_buffer.appendSlice(&[_]u8{3065 try dbg_info_buffer.appendSlice(&[_]u8{
3064 abbrev_base_type,3066 abbrev_base_type,
test/behavior.zig+1-1
...@@ -4,6 +4,7 @@ test {...@@ -4,6 +4,7 @@ test {
4 _ = @import("behavior/align.zig");4 _ = @import("behavior/align.zig");
5 _ = @import("behavior/alignof.zig");5 _ = @import("behavior/alignof.zig");
6 _ = @import("behavior/array.zig");6 _ = @import("behavior/array.zig");
7 _ = @import("behavior/basic.zig");
7 _ = @import("behavior/bit_shifting.zig");8 _ = @import("behavior/bit_shifting.zig");
8 _ = @import("behavior/bool.zig");9 _ = @import("behavior/bool.zig");
9 _ = @import("behavior/bugs/394.zig");10 _ = @import("behavior/bugs/394.zig");
...@@ -43,7 +44,6 @@ test {...@@ -43,7 +44,6 @@ test {
43 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {44 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
44 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.45 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
45 _ = @import("behavior/array_llvm.zig");46 _ = @import("behavior/array_llvm.zig");
46 _ = @import("behavior/basic.zig");
47 _ = @import("behavior/bitcast.zig");47 _ = @import("behavior/bitcast.zig");
48 _ = @import("behavior/bugs/624.zig");48 _ = @import("behavior/bugs/624.zig");
49 _ = @import("behavior/bugs/704.zig");49 _ = @import("behavior/bugs/704.zig");
test/behavior/basic.zig+79
...@@ -15,6 +15,8 @@ test "empty function with comments" {...@@ -15,6 +15,8 @@ test "empty function with comments" {
15}15}
1616
17test "truncate" {17test "truncate" {
18 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
19
18 try expect(testTruncate(0x10fd) == 0xfd);20 try expect(testTruncate(0x10fd) == 0xfd);
19 comptime try expect(testTruncate(0x10fd) == 0xfd);21 comptime try expect(testTruncate(0x10fd) == 0xfd);
20}22}
...@@ -23,6 +25,9 @@ fn testTruncate(x: u32) u8 {...@@ -23,6 +25,9 @@ fn testTruncate(x: u32) u8 {
23}25}
2426
25test "truncate to non-power-of-two integers" {27test "truncate to non-power-of-two integers" {
28 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
29 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
30
26 try testTrunc(u32, u1, 0b10101, 0b1);31 try testTrunc(u32, u1, 0b10101, 0b1);
27 try testTrunc(u32, u1, 0b10110, 0b0);32 try testTrunc(u32, u1, 0b10110, 0b0);
28 try testTrunc(u32, u2, 0b10101, 0b01);33 try testTrunc(u32, u2, 0b10101, 0b01);
...@@ -108,14 +113,23 @@ fn first4KeysOfHomeRow() []const u8 {...@@ -108,14 +113,23 @@ fn first4KeysOfHomeRow() []const u8 {
108}113}
109114
110test "return string from function" {115test "return string from function" {
116 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
117 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
118
111 try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));119 try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
112}120}
113121
114test "hex escape" {122test "hex escape" {
123 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
124 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
125
115 try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello"));126 try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello"));
116}127}
117128
118test "multiline string" {129test "multiline string" {
130 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
131 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
132
119 const s1 =133 const s1 =
120 \\one134 \\one
121 \\two)135 \\two)
...@@ -126,6 +140,9 @@ test "multiline string" {...@@ -126,6 +140,9 @@ test "multiline string" {
126}140}
127141
128test "multiline string comments at start" {142test "multiline string comments at start" {
143 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
144 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
145
129 const s1 =146 const s1 =
130 //\\one147 //\\one
131 \\two)148 \\two)
...@@ -136,6 +153,9 @@ test "multiline string comments at start" {...@@ -136,6 +153,9 @@ test "multiline string comments at start" {
136}153}
137154
138test "multiline string comments at end" {155test "multiline string comments at end" {
156 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
157 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
158
139 const s1 =159 const s1 =
140 \\one160 \\one
141 \\two)161 \\two)
...@@ -146,6 +166,9 @@ test "multiline string comments at end" {...@@ -146,6 +166,9 @@ test "multiline string comments at end" {
146}166}
147167
148test "multiline string comments in middle" {168test "multiline string comments in middle" {
169 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
170 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
171
149 const s1 =172 const s1 =
150 \\one173 \\one
151 //\\two)174 //\\two)
...@@ -156,6 +179,9 @@ test "multiline string comments in middle" {...@@ -156,6 +179,9 @@ test "multiline string comments in middle" {
156}179}
157180
158test "multiline string comments at multiple places" {181test "multiline string comments at multiple places" {
182 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
183 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
184
159 const s1 =185 const s1 =
160 \\one186 \\one
161 //\\two187 //\\two
...@@ -172,6 +198,9 @@ test "string concatenation" {...@@ -172,6 +198,9 @@ test "string concatenation" {
172}198}
173199
174test "array mult operator" {200test "array mult operator" {
201 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
202 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
203
175 try expect(mem.eql(u8, "ab" ** 5, "ababababab"));204 try expect(mem.eql(u8, "ab" ** 5, "ababababab"));
176}205}
177206
...@@ -195,6 +224,9 @@ test "compile time global reinterpret" {...@@ -195,6 +224,9 @@ test "compile time global reinterpret" {
195}224}
196225
197test "cast undefined" {226test "cast undefined" {
227 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
228 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
229
198 const array: [100]u8 = undefined;230 const array: [100]u8 = undefined;
199 const slice = @as([]const u8, &array);231 const slice = @as([]const u8, &array);
200 testCastUndefined(slice);232 testCastUndefined(slice);
...@@ -204,6 +236,8 @@ fn testCastUndefined(x: []const u8) void {...@@ -204,6 +236,8 @@ fn testCastUndefined(x: []const u8) void {
204}236}
205237
206test "implicit cast after unreachable" {238test "implicit cast after unreachable" {
239 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
240
207 try expect(outer() == 1234);241 try expect(outer() == 1234);
208}242}
209fn inner() i32 {243fn inner() i32 {
...@@ -259,6 +293,9 @@ fn fB() []const u8 {...@@ -259,6 +293,9 @@ fn fB() []const u8 {
259}293}
260294
261test "call function pointer in struct" {295test "call function pointer in struct" {
296 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
297 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
298
262 if (builtin.zig_backend == .stage1) return error.SkipZigTest;299 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
263300
264 try expect(mem.eql(u8, f3(true), "a"));301 try expect(mem.eql(u8, f3(true), "a"));
...@@ -282,6 +319,8 @@ const FnPtrWrapper = struct {...@@ -282,6 +319,8 @@ const FnPtrWrapper = struct {
282};319};
283320
284test "const ptr from var variable" {321test "const ptr from var variable" {
322 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
323
285 var x: u64 = undefined;324 var x: u64 = undefined;
286 var y: u64 = undefined;325 var y: u64 = undefined;
287326
...@@ -296,6 +335,8 @@ fn copy(src: *const u64, dst: *u64) void {...@@ -296,6 +335,8 @@ fn copy(src: *const u64, dst: *u64) void {
296}335}
297336
298test "call result of if else expression" {337test "call result of if else expression" {
338 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
339 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
299 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO340 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
300 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO341 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
301342
...@@ -307,6 +348,8 @@ fn f2(x: bool) []const u8 {...@@ -307,6 +348,8 @@ fn f2(x: bool) []const u8 {
307}348}
308349
309test "memcpy and memset intrinsics" {350test "memcpy and memset intrinsics" {
351 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
352 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
310 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO353 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
311354
312 try testMemcpyMemset();355 try testMemcpyMemset();
...@@ -327,6 +370,8 @@ fn testMemcpyMemset() !void {...@@ -327,6 +370,8 @@ fn testMemcpyMemset() !void {
327}370}
328371
329test "variable is allowed to be a pointer to an opaque type" {372test "variable is allowed to be a pointer to an opaque type" {
373 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
374 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
330 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
331376
332 var x: i32 = 1234;377 var x: i32 = 1234;
...@@ -338,6 +383,9 @@ fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {...@@ -338,6 +383,9 @@ fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {
338}383}
339384
340test "take address of parameter" {385test "take address of parameter" {
386 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
387 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
388
341 try testTakeAddressOfParameter(12.34);389 try testTakeAddressOfParameter(12.34);
342}390}
343fn testTakeAddressOfParameter(f: f32) !void {391fn testTakeAddressOfParameter(f: f32) !void {
...@@ -360,6 +408,9 @@ fn testPointerToVoidReturnType2() *const void {...@@ -360,6 +408,9 @@ fn testPointerToVoidReturnType2() *const void {
360}408}
361409
362test "array 2D const double ptr" {410test "array 2D const double ptr" {
411 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
412 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
413
363 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO414 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
364415
365 const rect_2d_vertexes = [_][1]f32{416 const rect_2d_vertexes = [_][1]f32{
...@@ -376,6 +427,9 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {...@@ -376,6 +427,9 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {
376}427}
377428
378test "double implicit cast in same expression" {429test "double implicit cast in same expression" {
430 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
431 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
432
379 var x = @as(i32, @as(u16, nine()));433 var x = @as(i32, @as(u16, nine()));
380 try expect(x == 9);434 try expect(x == 9);
381}435}
...@@ -384,6 +438,8 @@ fn nine() u8 {...@@ -384,6 +438,8 @@ fn nine() u8 {
384}438}
385439
386test "struct inside function" {440test "struct inside function" {
441 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
442
387 try testStructInFn();443 try testStructInFn();
388 comptime try testStructInFn();444 comptime try testStructInFn();
389}445}
...@@ -411,6 +467,8 @@ fn getNull() ?*i32 {...@@ -411,6 +467,8 @@ fn getNull() ?*i32 {
411}467}
412468
413test "global variable assignment with optional unwrapping with var initialized to undefined" {469test "global variable assignment with optional unwrapping with var initialized to undefined" {
470 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
471
414 const S = struct {472 const S = struct {
415 var data: i32 = 1234;473 var data: i32 = 1234;
416 fn foo() ?*i32 {474 fn foo() ?*i32 {
...@@ -426,6 +484,9 @@ test "global variable assignment with optional unwrapping with var initialized t...@@ -426,6 +484,9 @@ test "global variable assignment with optional unwrapping with var initialized t
426var global_foo: *i32 = undefined;484var global_foo: *i32 = undefined;
427485
428test "peer result location with typed parent, runtime condition, comptime prongs" {486test "peer result location with typed parent, runtime condition, comptime prongs" {
487 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
488 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
489
429 const S = struct {490 const S = struct {
430 fn doTheTest(arg: i32) i32 {491 fn doTheTest(arg: i32) i32 {
431 const st = Structy{492 const st = Structy{
...@@ -523,6 +584,9 @@ test "self reference through fn ptr field" {...@@ -523,6 +584,9 @@ test "self reference through fn ptr field" {
523}584}
524585
525test "global variable initialized to global variable array element" {586test "global variable initialized to global variable array element" {
587 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
588 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
589
526 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;590 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
527591
528 try expect(global_ptr == &gdt[0]);592 try expect(global_ptr == &gdt[0]);
...@@ -537,6 +601,8 @@ var gdt = [_]GDTEntry{...@@ -537,6 +601,8 @@ var gdt = [_]GDTEntry{
537var global_ptr = &gdt[0];601var global_ptr = &gdt[0];
538602
539test "global constant is loaded with a runtime-known index" {603test "global constant is loaded with a runtime-known index" {
604 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
605
540 const S = struct {606 const S = struct {
541 fn doTheTest() !void {607 fn doTheTest() !void {
542 var index: usize = 1;608 var index: usize = 1;
...@@ -552,6 +618,9 @@ test "global constant is loaded with a runtime-known index" {...@@ -552,6 +618,9 @@ test "global constant is loaded with a runtime-known index" {
552}618}
553619
554test "multiline string literal is null terminated" {620test "multiline string literal is null terminated" {
621 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
622 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
623
555 const s1 =624 const s1 =
556 \\one625 \\one
557 \\two)626 \\two)
...@@ -582,6 +651,9 @@ test "explicit cast optional pointers" {...@@ -582,6 +651,9 @@ test "explicit cast optional pointers" {
582}651}
583652
584test "pointer comparison" {653test "pointer comparison" {
654 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
655 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
656
585 const a = @as([]const u8, "a");657 const a = @as([]const u8, "a");
586 const b = &a;658 const b = &a;
587 try expect(ptrEql(b, b));659 try expect(ptrEql(b, b));
...@@ -591,6 +663,9 @@ fn ptrEql(a: *const []const u8, b: *const []const u8) bool {...@@ -591,6 +663,9 @@ fn ptrEql(a: *const []const u8, b: *const []const u8) bool {
591}663}
592664
593test "string concatenation" {665test "string concatenation" {
666 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
667 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
668
594 const a = "OK" ++ " IT " ++ "WORKED";669 const a = "OK" ++ " IT " ++ "WORKED";
595 const b = "OK IT WORKED";670 const b = "OK IT WORKED";
596671
...@@ -610,6 +685,8 @@ test "string concatenation" {...@@ -610,6 +685,8 @@ test "string concatenation" {
610}685}
611686
612test "thread local variable" {687test "thread local variable" {
688 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
689 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
613 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO690 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
614691
615 const S = struct {692 const S = struct {
...@@ -634,6 +711,8 @@ fn maybe(x: bool) anyerror!?u32 {...@@ -634,6 +711,8 @@ fn maybe(x: bool) anyerror!?u32 {
634}711}
635712
636test "pointer to thread local array" {713test "pointer to thread local array" {
714 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
715 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
637 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO716 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
638717
639 const s = "Hello world";718 const s = "Hello world";
test/behavior/bugs/2006.zig-1
...@@ -7,7 +7,6 @@ const S = struct {...@@ -7,7 +7,6 @@ const S = struct {
7};7};
8test "bug 2006" {8test "bug 2006" {
9 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;9 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
11 var a: S = undefined;10 var a: S = undefined;
12 a = S{ .p = undefined };11 a = S{ .p = undefined };
13 try expect(@sizeOf(S) != 0);12 try expect(@sizeOf(S) != 0);
test/behavior/bugs/3367.zig-1
...@@ -12,7 +12,6 @@ const Mixin = struct {...@@ -12,7 +12,6 @@ const Mixin = struct {
12test "container member access usingnamespace decls" {12test "container member access usingnamespace decls" {
13 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;13 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
15 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
16 var foo = Foo{};15 var foo = Foo{};
17 foo.two();16 foo.two();
18}17}