fix regressed stage2 test harness

This commit is contained in:
Andrew Kelley 2020-09-21 21:14:01 -07:00
parent ead50ea665
commit afac5d2895
9 changed files with 58 additions and 47 deletions

View File

@ -772,7 +772,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
if (build_options.is_stage1 and comp.bin_file.options.use_llvm) { if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {
try comp.work_queue.writeItem(.{ .stage1_module = {} }); try comp.work_queue.writeItem(.{ .stage1_module = {} });
} }
if (is_exe_or_dyn_lib) { if (is_exe_or_dyn_lib and comp.bin_file.options.use_llvm) {
try comp.work_queue.writeItem(.{ .libcompiler_rt = {} }); try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
if (!comp.bin_file.options.link_libc) { if (!comp.bin_file.options.link_libc) {
try comp.work_queue.writeItem(.{ .zig_libc = {} }); try comp.work_queue.writeItem(.{ .zig_libc = {} });
@ -1128,6 +1128,9 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
}; };
}, },
.stage1_module => { .stage1_module => {
if (!build_options.is_stage1)
unreachable;
self.updateStage1Module() catch |err| { self.updateStage1Module() catch |err| {
fatal("unable to build stage1 zig object: {}", .{@errorName(err)}); fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
}; };
@ -1685,11 +1688,13 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
test "classifyFileExt" { test "classifyFileExt" {
std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc")); std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim")); std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so")); std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1")); std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2")); std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2.3")); std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~")); std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
std.testing.expectEqual(FileExt.zir, classifyFileExt("foo.zir"));
} }
fn haveFramePointer(comp: *Compilation) bool { fn haveFramePointer(comp: *Compilation) bool {

View File

@ -29,7 +29,7 @@
#endif #endif
// ABI warning: the types and declarations in this file must match both those in // ABI warning: the types and declarations in this file must match both those in
// stage2.cpp and src-self-hosted/stage1.zig. // stage2.cpp and src/stage1.zig.
// ABI warning // ABI warning
enum Error { enum Error {

View File

@ -458,9 +458,15 @@ pub const TestContext = struct {
.path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }), .path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
}; };
const tmp_src_path = if (case.extension == .Zig) "test_case.zig" else if (case.extension == .ZIR) "test_case.zir" else unreachable; const tmp_src_path = switch (case.extension) {
const root_pkg = try Package.create(allocator, tmp.dir, ".", tmp_src_path); .Zig => "test_case.zig",
defer root_pkg.destroy(allocator); .ZIR => "test_case.zir",
};
var root_pkg: Package = .{
.root_src_directory = .{ .path = bogus_path, .handle = tmp.dir },
.root_src_path = tmp_src_path,
};
const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null; const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt); const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
@ -486,7 +492,7 @@ pub const TestContext = struct {
// TODO: support testing optimizations // TODO: support testing optimizations
.optimize_mode = .Debug, .optimize_mode = .Debug,
.emit_bin = emit_bin, .emit_bin = emit_bin,
.root_pkg = root_pkg, .root_pkg = &root_pkg,
.keep_source_files_loaded = true, .keep_source_files_loaded = true,
.object_format = ofmt, .object_format = ofmt,
.is_native_os = case.target.isNativeOs(), .is_native_os = case.target.isNativeOs(),

View File

@ -16,7 +16,7 @@
#include <stddef.h> #include <stddef.h>
// ABI warning - src-self-hosted/windows_sdk.zig // ABI warning - src/windows_sdk.zig
struct ZigWindowsSDK { struct ZigWindowsSDK {
const char *path10_ptr; const char *path10_ptr;
size_t path10_len; size_t path10_len;
@ -34,7 +34,7 @@ struct ZigWindowsSDK {
size_t msvc_lib_dir_len; size_t msvc_lib_dir_len;
}; };
// ABI warning - src-self-hosted/windows_sdk.zig // ABI warning - src/windows_sdk.zig
enum ZigFindWindowsSdkError { enum ZigFindWindowsSdkError {
ZigFindWindowsSdkErrorNone, ZigFindWindowsSdkErrorNone,
ZigFindWindowsSdkErrorOutOfMemory, ZigFindWindowsSdkErrorOutOfMemory,
@ -42,10 +42,10 @@ enum ZigFindWindowsSdkError {
ZigFindWindowsSdkErrorPathTooLong, ZigFindWindowsSdkErrorPathTooLong,
}; };
// ABI warning - src-self-hosted/windows_sdk.zig // ABI warning - src/windows_sdk.zig
ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk); ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);
// ABI warning - src-self-hosted/windows_sdk.zig // ABI warning - src/windows_sdk.zig
ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk); ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);
#endif #endif

View File

@ -14,7 +14,7 @@
// ATTENTION: If you modify this file, be sure to update the corresponding // ATTENTION: If you modify this file, be sure to update the corresponding
// extern function declarations in the self-hosted compiler file // extern function declarations in the self-hosted compiler file
// src-self-hosted/clang.zig. // src/clang.zig.
struct ZigClangSourceLocation { struct ZigClangSourceLocation {
unsigned ID; unsigned ID;

View File

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const TestContext = @import("../../src-self-hosted/test.zig").TestContext; const TestContext = @import("../../src/test.zig").TestContext;
// These tests should work with all platforms, but we're using linux_x64 for // These tests should work with all platforms, but we're using linux_x64 for
// now for consistency. Will be expanded eventually. // now for consistency. Will be expanded eventually.

View File

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const TestContext = @import("../../src-self-hosted/test.zig").TestContext; const TestContext = @import("../../src/test.zig").TestContext;
const spu = std.zig.CrossTarget{ const spu = std.zig.CrossTarget{
.cpu_arch = .spu_2, .cpu_arch = .spu_2,

View File

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const TestContext = @import("../../src-self-hosted/test.zig").TestContext; const TestContext = @import("../../src/test.zig").TestContext;
// Self-hosted has differing levels of support for various architectures. For now we pass explicit // Self-hosted has differing levels of support for various architectures. For now we pass explicit
// target parameters to each test case. At some point we will take this to the next level and have // target parameters to each test case. At some point we will take this to the next level and have

View File

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const TestContext = @import("../../src-self-hosted/test.zig").TestContext; const TestContext = @import("../../src/test.zig").TestContext;
// self-hosted does not yet support PE executable files / COFF object files // self-hosted does not yet support PE executable files / COFF object files
// or mach-o files. So we do the ZIR transform test cases cross compiling for // or mach-o files. So we do the ZIR transform test cases cross compiling for
// x86_64-linux. // x86_64-linux.