Skip to content

Commit

Permalink
self hosted compiler: final small fixes to get it compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu committed Nov 24, 2019
1 parent 010494d commit 5e0132d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn build(b: *Builder) !void {
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
if (!skip_self_hosted and builtin.os == .linux) {
// TODO evented I/O other OS'spu
// TODO evented I/O other OS's
test_step.dependOn(&exe.step);
}

Expand Down Expand Up @@ -226,6 +226,9 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
{
var it = mem.tokenize(libs_output, " \r\n");
while (it.next()) |lib_arg| {
if (mem.endsWith(u8, lib_arg, ".lib")) {
lib_arg = lib_arg[0 .. lib_arg.len - 4];
}
if (mem.startsWith(u8, lib_arg, "-l")) {
try result.system_libs.append(lib_arg[2..]);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src-self-hosted/compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ pub const Compilation = struct {
comp.target_layout_str = llvm.CopyStringRepOfTargetData(comp.target_data_ref) orelse return error.OutOfMemory;
defer llvm.DisposeMessage(comp.target_layout_str);

comp.events = try allocator.create(event.Channel(Event));
defer allocator.destroy(comp.events);

comp.events.init([0]Event{});
defer comp.events.deinit();

Expand Down
12 changes: 8 additions & 4 deletions src-self-hosted/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ test "stage2" {
// TODO provide a way to run tests in evented I/O mode
if (!std.io.is_async) return error.SkipZigTest;

// TODO https://github.com/ziglang/zig/issues/1364
// TODO https://github.com/ziglang/zig/issues/3117
if (true) return error.SkipZigTest;

try ctx.init();
defer ctx.deinit();

try @import("stage2_tests").addCases(&ctx);

_ = async ctx.run();
try ctx.run();
}

const file1 = "1.zig";
Expand Down Expand Up @@ -61,8 +65,8 @@ pub const TestContext = struct {
self.zig_compiler.deinit();
}

fn run(self: *TestContext) void {
std.event.Loop.instance.?.startCpuBoundOperation();
fn run(self: *TestContext) !void {
std.event.Loop.startCpuBoundOperation();
self.any_err = self.group.wait();
return self.any_err;
}
Expand Down Expand Up @@ -112,7 +116,7 @@ pub const TestContext = struct {
const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());
const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });

const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{.Native = {}}).exeFileExt());
const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{ .Native = {} }).exeFileExt());
if (std.fs.path.dirname(file1_path)) |dirname| {
try std.fs.makePath(allocator, dirname);
}
Expand Down

0 comments on commit 5e0132d

Please sign in to comment.