authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:14:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:14:01-07:00
logafac5d28951cfd913851094649e8b9f2136694ca
tree85587c7cc735424cc4595c616d3c1a1c7ad3461e
parentead50ea6657d31632f5661f788b035a66c344d13

fix regressed stage2 test harness


9 files changed, 58 insertions(+), 47 deletions(-)

src/Compilation.zig+10-5
...@@ -772,7 +772,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {...@@ -772,7 +772,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
772 if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {772 if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {
773 try comp.work_queue.writeItem(.{ .stage1_module = {} });773 try comp.work_queue.writeItem(.{ .stage1_module = {} });
774 }774 }
775 if (is_exe_or_dyn_lib) {775 if (is_exe_or_dyn_lib and comp.bin_file.options.use_llvm) {
776 try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });776 try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
777 if (!comp.bin_file.options.link_libc) {777 if (!comp.bin_file.options.link_libc) {
778 try comp.work_queue.writeItem(.{ .zig_libc = {} });778 try comp.work_queue.writeItem(.{ .zig_libc = {} });
...@@ -1128,6 +1128,9 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {...@@ -1128,6 +1128,9 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
1128 };1128 };
1129 },1129 },
1130 .stage1_module => {1130 .stage1_module => {
1131 if (!build_options.is_stage1)
1132 unreachable;
1133
1131 self.updateStage1Module() catch |err| {1134 self.updateStage1Module() catch |err| {
1132 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});1135 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
1133 };1136 };
...@@ -1685,11 +1688,13 @@ pub fn classifyFileExt(filename: []const u8) FileExt {...@@ -1685,11 +1688,13 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
1685test "classifyFileExt" {1688test "classifyFileExt" {
1686 std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));1689 std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
1687 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));1690 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
1688 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so"));1691 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
1689 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1"));1692 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
1690 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2"));1693 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
1691 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2.3"));1694 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
1692 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));1695 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
1696 std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
1697 std.testing.expectEqual(FileExt.zir, classifyFileExt("foo.zir"));
1693}1698}
16941699
1695fn haveFramePointer(comp: *Compilation) bool {1700fn haveFramePointer(comp: *Compilation) bool {
src/stage1/stage2.h+1-1
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29#endif29#endif
3030
31// ABI warning: the types and declarations in this file must match both those in31// ABI warning: the types and declarations in this file must match both those in
32// stage2.cpp and src-self-hosted/stage1.zig.32// stage2.cpp and src/stage1.zig.
3333
34// ABI warning34// ABI warning
35enum Error {35enum Error {
src/test.zig+10-4
...@@ -458,9 +458,15 @@ pub const TestContext = struct {...@@ -458,9 +458,15 @@ pub const TestContext = struct {
458 .path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),458 .path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
459 };459 };
460460
461 const tmp_src_path = if (case.extension == .Zig) "test_case.zig" else if (case.extension == .ZIR) "test_case.zir" else unreachable;461 const tmp_src_path = switch (case.extension) {
462 const root_pkg = try Package.create(allocator, tmp.dir, ".", tmp_src_path);462 .Zig => "test_case.zig",
463 defer root_pkg.destroy(allocator);463 .ZIR => "test_case.zir",
464 };
465
466 var root_pkg: Package = .{
467 .root_src_directory = .{ .path = bogus_path, .handle = tmp.dir },
468 .root_src_path = tmp_src_path,
469 };
464470
465 const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;471 const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
466 const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);472 const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
...@@ -486,7 +492,7 @@ pub const TestContext = struct {...@@ -486,7 +492,7 @@ pub const TestContext = struct {
486 // TODO: support testing optimizations492 // TODO: support testing optimizations
487 .optimize_mode = .Debug,493 .optimize_mode = .Debug,
488 .emit_bin = emit_bin,494 .emit_bin = emit_bin,
489 .root_pkg = root_pkg,495 .root_pkg = &root_pkg,
490 .keep_source_files_loaded = true,496 .keep_source_files_loaded = true,
491 .object_format = ofmt,497 .object_format = ofmt,
492 .is_native_os = case.target.isNativeOs(),498 .is_native_os = case.target.isNativeOs(),
src/windows_sdk.h+4-4
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
1616
17#include <stddef.h>17#include <stddef.h>
1818
19// ABI warning - src-self-hosted/windows_sdk.zig19// ABI warning - src/windows_sdk.zig
20struct ZigWindowsSDK {20struct ZigWindowsSDK {
21 const char *path10_ptr;21 const char *path10_ptr;
22 size_t path10_len;22 size_t path10_len;
...@@ -34,7 +34,7 @@ struct ZigWindowsSDK {...@@ -34,7 +34,7 @@ struct ZigWindowsSDK {
34 size_t msvc_lib_dir_len;34 size_t msvc_lib_dir_len;
35};35};
3636
37// ABI warning - src-self-hosted/windows_sdk.zig37// ABI warning - src/windows_sdk.zig
38enum ZigFindWindowsSdkError {38enum ZigFindWindowsSdkError {
39 ZigFindWindowsSdkErrorNone,39 ZigFindWindowsSdkErrorNone,
40 ZigFindWindowsSdkErrorOutOfMemory,40 ZigFindWindowsSdkErrorOutOfMemory,
...@@ -42,10 +42,10 @@ enum ZigFindWindowsSdkError {...@@ -42,10 +42,10 @@ enum ZigFindWindowsSdkError {
42 ZigFindWindowsSdkErrorPathTooLong,42 ZigFindWindowsSdkErrorPathTooLong,
43};43};
4444
45// ABI warning - src-self-hosted/windows_sdk.zig45// ABI warning - src/windows_sdk.zig
46ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);46ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);
4747
48// ABI warning - src-self-hosted/windows_sdk.zig48// ABI warning - src/windows_sdk.zig
49ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);49ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);
5050
51#endif51#endif
src/zig_clang.h+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15// ATTENTION: If you modify this file, be sure to update the corresponding15// ATTENTION: If you modify this file, be sure to update the corresponding
16// extern function declarations in the self-hosted compiler file16// extern function declarations in the self-hosted compiler file
17// src-self-hosted/clang.zig.17// src/clang.zig.
1818
19struct ZigClangSourceLocation {19struct ZigClangSourceLocation {
20 unsigned ID;20 unsigned ID;
test/stage2/cbe.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;2const TestContext = @import("../../src/test.zig").TestContext;
33
4// These tests should work with all platforms, but we're using linux_x64 for4// These tests should work with all platforms, but we're using linux_x64 for
5// now for consistency. Will be expanded eventually.5// now for consistency. Will be expanded eventually.
test/stage2/spu-ii.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;2const TestContext = @import("../../src/test.zig").TestContext;
33
4const spu = std.zig.CrossTarget{4const spu = std.zig.CrossTarget{
5 .cpu_arch = .spu_2,5 .cpu_arch = .spu_2,
test/stage2/test.zig+28-28
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;2const TestContext = @import("../../src/test.zig").TestContext;
33
4// Self-hosted has differing levels of support for various architectures. For now we pass explicit4// Self-hosted has differing levels of support for various architectures. For now we pass explicit
5// target parameters to each test case. At some point we will take this to the next level and have5// target parameters to each test case. At some point we will take this to the next level and have
...@@ -76,7 +76,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -76,7 +76,7 @@ pub fn addCases(ctx: *TestContext) !void {
76 \\ );76 \\ );
77 \\ unreachable;77 \\ unreachable;
78 \\}78 \\}
79 ,79 ,
80 "Hello, World!\n",80 "Hello, World!\n",
81 );81 );
82 // Now change the message only82 // Now change the message only
...@@ -108,7 +108,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -108,7 +108,7 @@ pub fn addCases(ctx: *TestContext) !void {
108 \\ );108 \\ );
109 \\ unreachable;109 \\ unreachable;
110 \\}110 \\}
111 ,111 ,
112 "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n",112 "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n",
113 );113 );
114 // Now we print it twice.114 // Now we print it twice.
...@@ -184,7 +184,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -184,7 +184,7 @@ pub fn addCases(ctx: *TestContext) !void {
184 \\ );184 \\ );
185 \\ unreachable;185 \\ unreachable;
186 \\}186 \\}
187 ,187 ,
188 "Hello, World!\n",188 "Hello, World!\n",
189 );189 );
190 }190 }
...@@ -219,7 +219,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -219,7 +219,7 @@ pub fn addCases(ctx: *TestContext) !void {
219 \\ );219 \\ );
220 \\ unreachable;220 \\ unreachable;
221 \\}221 \\}
222 ,222 ,
223 "Hello, World!\n",223 "Hello, World!\n",
224 );224 );
225 }225 }
...@@ -244,7 +244,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -244,7 +244,7 @@ pub fn addCases(ctx: *TestContext) !void {
244 \\ );244 \\ );
245 \\ unreachable;245 \\ unreachable;
246 \\}246 \\}
247 ,247 ,
248 "Hello, World!\n",248 "Hello, World!\n",
249 );249 );
250 }250 }
...@@ -271,7 +271,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -271,7 +271,7 @@ pub fn addCases(ctx: *TestContext) !void {
271 \\ );271 \\ );
272 \\ unreachable;272 \\ unreachable;
273 \\}273 \\}
274 ,274 ,
275 "",275 "",
276 );276 );
277 }277 }
...@@ -298,7 +298,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -298,7 +298,7 @@ pub fn addCases(ctx: *TestContext) !void {
298 \\ );298 \\ );
299 \\ unreachable;299 \\ unreachable;
300 \\}300 \\}
301 ,301 ,
302 "",302 "",
303 );303 );
304 }304 }
...@@ -329,7 +329,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -329,7 +329,7 @@ pub fn addCases(ctx: *TestContext) !void {
329 \\ );329 \\ );
330 \\ unreachable;330 \\ unreachable;
331 \\}331 \\}
332 ,332 ,
333 "",333 "",
334 );334 );
335335
...@@ -362,7 +362,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -362,7 +362,7 @@ pub fn addCases(ctx: *TestContext) !void {
362 \\ );362 \\ );
363 \\ unreachable;363 \\ unreachable;
364 \\}364 \\}
365 ,365 ,
366 "",366 "",
367 );367 );
368368
...@@ -398,7 +398,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -398,7 +398,7 @@ pub fn addCases(ctx: *TestContext) !void {
398 \\ );398 \\ );
399 \\ unreachable;399 \\ unreachable;
400 \\}400 \\}
401 ,401 ,
402 "",402 "",
403 );403 );
404404
...@@ -435,7 +435,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -435,7 +435,7 @@ pub fn addCases(ctx: *TestContext) !void {
435 \\ );435 \\ );
436 \\ unreachable;436 \\ unreachable;
437 \\}437 \\}
438 ,438 ,
439 "",439 "",
440 );440 );
441441
...@@ -465,7 +465,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -465,7 +465,7 @@ pub fn addCases(ctx: *TestContext) !void {
465 \\ );465 \\ );
466 \\ unreachable;466 \\ unreachable;
467 \\}467 \\}
468 ,468 ,
469 "",469 "",
470 );470 );
471471
...@@ -499,7 +499,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -499,7 +499,7 @@ pub fn addCases(ctx: *TestContext) !void {
499 \\ );499 \\ );
500 \\ unreachable;500 \\ unreachable;
501 \\}501 \\}
502 ,502 ,
503 "",503 "",
504 );504 );
505505
...@@ -523,7 +523,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -523,7 +523,7 @@ pub fn addCases(ctx: *TestContext) !void {
523 \\ );523 \\ );
524 \\ unreachable;524 \\ unreachable;
525 \\}525 \\}
526 ,526 ,
527 "",527 "",
528 );528 );
529529
...@@ -562,7 +562,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -562,7 +562,7 @@ pub fn addCases(ctx: *TestContext) !void {
562 \\ );562 \\ );
563 \\ unreachable;563 \\ unreachable;
564 \\}564 \\}
565 ,565 ,
566 "hello\nhello\nhello\nhello\n",566 "hello\nhello\nhello\nhello\n",
567 );567 );
568568
...@@ -599,7 +599,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -599,7 +599,7 @@ pub fn addCases(ctx: *TestContext) !void {
599 \\ );599 \\ );
600 \\ unreachable;600 \\ unreachable;
601 \\}601 \\}
602 ,602 ,
603 "",603 "",
604 );604 );
605605
...@@ -641,7 +641,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -641,7 +641,7 @@ pub fn addCases(ctx: *TestContext) !void {
641 \\ );641 \\ );
642 \\ unreachable;642 \\ unreachable;
643 \\}643 \\}
644 ,644 ,
645 "",645 "",
646 );646 );
647647
...@@ -693,7 +693,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -693,7 +693,7 @@ pub fn addCases(ctx: *TestContext) !void {
693 \\ );693 \\ );
694 \\ unreachable;694 \\ unreachable;
695 \\}695 \\}
696 ,696 ,
697 "",697 "",
698 );698 );
699699
...@@ -755,7 +755,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -755,7 +755,7 @@ pub fn addCases(ctx: *TestContext) !void {
755 \\ );755 \\ );
756 \\ unreachable;756 \\ unreachable;
757 \\}757 \\}
758 ,758 ,
759 "",759 "",
760 );760 );
761761
...@@ -788,7 +788,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -788,7 +788,7 @@ pub fn addCases(ctx: *TestContext) !void {
788 \\ );788 \\ );
789 \\ unreachable;789 \\ unreachable;
790 \\}790 \\}
791 ,791 ,
792 "",792 "",
793 );793 );
794794
...@@ -820,7 +820,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -820,7 +820,7 @@ pub fn addCases(ctx: *TestContext) !void {
820 \\ );820 \\ );
821 \\ unreachable;821 \\ unreachable;
822 \\}822 \\}
823 ,823 ,
824 "",824 "",
825 );825 );
826826
...@@ -845,7 +845,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -845,7 +845,7 @@ pub fn addCases(ctx: *TestContext) !void {
845 \\ );845 \\ );
846 \\ unreachable;846 \\ unreachable;
847 \\}847 \\}
848 ,848 ,
849 "",849 "",
850 );850 );
851851
...@@ -871,7 +871,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -871,7 +871,7 @@ pub fn addCases(ctx: *TestContext) !void {
871 \\ );871 \\ );
872 \\ unreachable;872 \\ unreachable;
873 \\}873 \\}
874 ,874 ,
875 "",875 "",
876 );876 );
877877
...@@ -904,7 +904,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -904,7 +904,7 @@ pub fn addCases(ctx: *TestContext) !void {
904 \\ );904 \\ );
905 \\ unreachable;905 \\ unreachable;
906 \\}906 \\}
907 ,907 ,
908 "hello\nhello\nhello\nhello\nhello\n",908 "hello\nhello\nhello\nhello\nhello\n",
909 );909 );
910 }910 }
...@@ -923,7 +923,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -923,7 +923,7 @@ pub fn addCases(ctx: *TestContext) !void {
923 \\ bar();923 \\ bar();
924 \\}924 \\}
925 \\fn bar() void {}925 \\fn bar() void {}
926 ,926 ,
927 "42\n",927 "42\n",
928 );928 );
929929
...@@ -941,7 +941,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -941,7 +941,7 @@ pub fn addCases(ctx: *TestContext) !void {
941 \\ bar();941 \\ bar();
942 \\}942 \\}
943 \\fn bar() void {}943 \\fn bar() void {}
944 ,944 ,
945 "42\n",945 "42\n",
946 );946 );
947947
...@@ -957,7 +957,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -957,7 +957,7 @@ pub fn addCases(ctx: *TestContext) !void {
957 \\ bar();957 \\ bar();
958 \\}958 \\}
959 \\fn bar() void {}959 \\fn bar() void {}
960 ,960 ,
961 // This is what you get when you take the bits of the IEE-754961 // This is what you get when you take the bits of the IEE-754
962 // representation of 42.0 and reinterpret them as an unsigned962 // representation of 42.0 and reinterpret them as an unsigned
963 // integer. Guess that's a bug in wasmtime.963 // integer. Guess that's a bug in wasmtime.
test/stage2/zir.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;2const TestContext = @import("../../src/test.zig").TestContext;
3// self-hosted does not yet support PE executable files / COFF object files3// self-hosted does not yet support PE executable files / COFF object files
4// or mach-o files. So we do the ZIR transform test cases cross compiling for4// or mach-o files. So we do the ZIR transform test cases cross compiling for
5// x86_64-linux.5// x86_64-linux.
...@@ -156,7 +156,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -156,7 +156,7 @@ pub fn addCases(ctx: *TestContext) !void {
156 \\ %0 = call(@a, [])156 \\ %0 = call(@a, [])
157 \\ %1 = returnvoid()157 \\ %1 = returnvoid()
158 \\})158 \\})
159 ,159 ,
160 &[_][]const u8{160 &[_][]const u8{
161 ":18:21: error: message",161 ":18:21: error: message",
162 },162 },