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(
30573057 var relocs = std.ArrayList(struct { ty: Type, reloc: u32 }).init(arena);
30583058
30593059 switch (ty.zigTypeTag()) {
3060 .Void => unreachable,
30613060 .NoReturn => unreachable,
3061 .Void => {
3062 try dbg_info_buffer.append(abbrev_pad1);
3063 },
30623064 .Bool => {
30633065 try dbg_info_buffer.appendSlice(&[_]u8{
30643066 abbrev_base_type,
test/behavior.zig+1-1
......@@ -4,6 +4,7 @@ test {
44 _ = @import("behavior/align.zig");
55 _ = @import("behavior/alignof.zig");
66 _ = @import("behavior/array.zig");
7 _ = @import("behavior/basic.zig");
78 _ = @import("behavior/bit_shifting.zig");
89 _ = @import("behavior/bool.zig");
910 _ = @import("behavior/bugs/394.zig");
......@@ -43,7 +44,6 @@ test {
4344 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
4445 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
4546 _ = @import("behavior/array_llvm.zig");
46 _ = @import("behavior/basic.zig");
4747 _ = @import("behavior/bitcast.zig");
4848 _ = @import("behavior/bugs/624.zig");
4949 _ = @import("behavior/bugs/704.zig");
test/behavior/basic.zig+79
......@@ -15,6 +15,8 @@ test "empty function with comments" {
1515}
1616
1717test "truncate" {
18 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
19
1820 try expect(testTruncate(0x10fd) == 0xfd);
1921 comptime try expect(testTruncate(0x10fd) == 0xfd);
2022}
......@@ -23,6 +25,9 @@ fn testTruncate(x: u32) u8 {
2325}
2426
2527test "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
2631 try testTrunc(u32, u1, 0b10101, 0b1);
2732 try testTrunc(u32, u1, 0b10110, 0b0);
2833 try testTrunc(u32, u2, 0b10101, 0b01);
......@@ -108,14 +113,23 @@ fn first4KeysOfHomeRow() []const u8 {
108113}
109114
110115test "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
111119 try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
112120}
113121
114122test "hex escape" {
123 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
124 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
125
115126 try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello"));
116127}
117128
118129test "multiline string" {
130 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
131 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
132
119133 const s1 =
120134 \\one
121135 \\two)
......@@ -126,6 +140,9 @@ test "multiline string" {
126140}
127141
128142test "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
129146 const s1 =
130147 //\\one
131148 \\two)
......@@ -136,6 +153,9 @@ test "multiline string comments at start" {
136153}
137154
138155test "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
139159 const s1 =
140160 \\one
141161 \\two)
......@@ -146,6 +166,9 @@ test "multiline string comments at end" {
146166}
147167
148168test "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
149172 const s1 =
150173 \\one
151174 //\\two)
......@@ -156,6 +179,9 @@ test "multiline string comments in middle" {
156179}
157180
158181test "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
159185 const s1 =
160186 \\one
161187 //\\two
......@@ -172,6 +198,9 @@ test "string concatenation" {
172198}
173199
174200test "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
175204 try expect(mem.eql(u8, "ab" ** 5, "ababababab"));
176205}
177206
......@@ -195,6 +224,9 @@ test "compile time global reinterpret" {
195224}
196225
197226test "cast undefined" {
227 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
228 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
229
198230 const array: [100]u8 = undefined;
199231 const slice = @as([]const u8, &array);
200232 testCastUndefined(slice);
......@@ -204,6 +236,8 @@ fn testCastUndefined(x: []const u8) void {
204236}
205237
206238test "implicit cast after unreachable" {
239 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
240
207241 try expect(outer() == 1234);
208242}
209243fn inner() i32 {
......@@ -259,6 +293,9 @@ fn fB() []const u8 {
259293}
260294
261295test "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
262299 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
263300
264301 try expect(mem.eql(u8, f3(true), "a"));
......@@ -282,6 +319,8 @@ const FnPtrWrapper = struct {
282319};
283320
284321test "const ptr from var variable" {
322 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
323
285324 var x: u64 = undefined;
286325 var y: u64 = undefined;
287326
......@@ -296,6 +335,8 @@ fn copy(src: *const u64, dst: *u64) void {
296335}
297336
298337test "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;
299340 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
300341 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
301342
......@@ -307,6 +348,8 @@ fn f2(x: bool) []const u8 {
307348}
308349
309350test "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;
310353 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
311354
312355 try testMemcpyMemset();
......@@ -327,6 +370,8 @@ fn testMemcpyMemset() !void {
327370}
328371
329372test "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;
330375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
331376
332377 var x: i32 = 1234;
......@@ -338,6 +383,9 @@ fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {
338383}
339384
340385test "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
341389 try testTakeAddressOfParameter(12.34);
342390}
343391fn testTakeAddressOfParameter(f: f32) !void {
......@@ -360,6 +408,9 @@ fn testPointerToVoidReturnType2() *const void {
360408}
361409
362410test "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
363414 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
364415
365416 const rect_2d_vertexes = [_][1]f32{
......@@ -376,6 +427,9 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {
376427}
377428
378429test "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
379433 var x = @as(i32, @as(u16, nine()));
380434 try expect(x == 9);
381435}
......@@ -384,6 +438,8 @@ fn nine() u8 {
384438}
385439
386440test "struct inside function" {
441 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
442
387443 try testStructInFn();
388444 comptime try testStructInFn();
389445}
......@@ -411,6 +467,8 @@ fn getNull() ?*i32 {
411467}
412468
413469test "global variable assignment with optional unwrapping with var initialized to undefined" {
470 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
471
414472 const S = struct {
415473 var data: i32 = 1234;
416474 fn foo() ?*i32 {
......@@ -426,6 +484,9 @@ test "global variable assignment with optional unwrapping with var initialized t
426484var global_foo: *i32 = undefined;
427485
428486test "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
429490 const S = struct {
430491 fn doTheTest(arg: i32) i32 {
431492 const st = Structy{
......@@ -523,6 +584,9 @@ test "self reference through fn ptr field" {
523584}
524585
525586test "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
526590 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
527591
528592 try expect(global_ptr == &gdt[0]);
......@@ -537,6 +601,8 @@ var gdt = [_]GDTEntry{
537601var global_ptr = &gdt[0];
538602
539603test "global constant is loaded with a runtime-known index" {
604 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
605
540606 const S = struct {
541607 fn doTheTest() !void {
542608 var index: usize = 1;
......@@ -552,6 +618,9 @@ test "global constant is loaded with a runtime-known index" {
552618}
553619
554620test "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
555624 const s1 =
556625 \\one
557626 \\two)
......@@ -582,6 +651,9 @@ test "explicit cast optional pointers" {
582651}
583652
584653test "pointer comparison" {
654 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
655 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
656
585657 const a = @as([]const u8, "a");
586658 const b = &a;
587659 try expect(ptrEql(b, b));
......@@ -591,6 +663,9 @@ fn ptrEql(a: *const []const u8, b: *const []const u8) bool {
591663}
592664
593665test "string concatenation" {
666 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
667 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
668
594669 const a = "OK" ++ " IT " ++ "WORKED";
595670 const b = "OK IT WORKED";
596671
......@@ -610,6 +685,8 @@ test "string concatenation" {
610685}
611686
612687test "thread local variable" {
688 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
689 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
613690 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
614691
615692 const S = struct {
......@@ -634,6 +711,8 @@ fn maybe(x: bool) anyerror!?u32 {
634711}
635712
636713test "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;
637716 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
638717
639718 const s = "Hello world";
test/behavior/bugs/2006.zig-1
......@@ -7,7 +7,6 @@ const S = struct {
77};
88test "bug 2006" {
99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1110 var a: S = undefined;
1211 a = S{ .p = undefined };
1312 try expect(@sizeOf(S) != 0);
test/behavior/bugs/3367.zig-1
......@@ -12,7 +12,6 @@ const Mixin = struct {
1212test "container member access usingnamespace decls" {
1313 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1414 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
15 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1615 var foo = Foo{};
1716 foo.two();
1817}