Skip to content

build: setOutputDir causes barfing #6560

@ghost

Description

Latest master 0.6.0+0e2d858d6 prebuilt binary on Mac. I say it barfs because I'm not really sure what's going on, there's a big stack(?) dump with a bunch of different errors in it, including OOM errors. I haven't looked into the cause myself yet.

setOutputDir doesn't work no matter whether it's "zig-cache" or "." or anything else, and whether the folder exists or not. It does get as far as creating the folder if it doesn't exist though.

build.zig:

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    var o = b.addExecutable("main", "main.zig");
    o.setOutputDir("build"); // comment this out and it works
    b.step("main", "Main").dependOn(&o.step);
}

main.zig:

const std = @import("std");

pub fn main() !void {
    std.debug.warn("hi\n", .{});
}

Output of zig build main:

error: FileNotFound
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/heap/arena_allocator.zig:104:17: 0x10072d9e2 in std.heap.arena_allocator.ArenaAllocator.resize (build)
                return error.OutOfMemory;
                ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/heap/arena_allocator.zig:104:17: 0x10072d9e2 in std.heap.arena_allocator.ArenaAllocator.resize (build)
                return error.OutOfMemory;
                ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/heap.zig:270:9: 0x100713638 in std.heap.PageAllocator.resize (build)
        return error.OutOfMemory;
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/mem/Allocator.zig:319:16: 0x10075f0b2 in std.mem.Allocator.resize (build)
    const rc = try self.resizeFn(self, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress());
               ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/os.zig:2122:19: 0x100729f38 in std.os.mkdiratZ (build)
        EEXIST => return error.PathAlreadyExists,
                  ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/os.zig:2083:9: 0x100729bc0 in std.os.mkdirat (build)
        return mkdiratZ(dir_fd, &sub_dir_path_c, mode);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/fs.zig:922:9: 0x100729a36 in std.fs.Dir.makeDir (build)
        try os.mkdirat(self.fd, sub_path, default_new_dir_mode);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/heap.zig:270:9: 0x100713638 in std.heap.PageAllocator.resize (build)
        return error.OutOfMemory;
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/mem/Allocator.zig:319:16: 0x10075f0b2 in std.mem.Allocator.resize (build)
    const rc = try self.resizeFn(self, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress());
               ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/os.zig:2122:19: 0x100729f38 in std.os.mkdiratZ (build)
        EEXIST => return error.PathAlreadyExists,
                  ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/os.zig:2083:9: 0x100729bc0 in std.os.mkdirat (build)
        return mkdiratZ(dir_fd, &sub_dir_path_c, mode);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/fs.zig:922:9: 0x100729a36 in std.fs.Dir.makeDir (build)
        try os.mkdirat(self.fd, sub_path, default_new_dir_mode);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/os.zig:1193:23: 0x10076726e in std.os.openatZ (build)
            ENOENT => return error.FileNotFound,
                      ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/fs.zig:754:13: 0x10073975e in std.fs.Dir.openFileZ (build)
            try os.openatZ(self.fd, sub_path, os_flags, 0);
            ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/fs.zig:687:9: 0x10073837b in std.fs.Dir.openFile (build)
        return self.openFileZ(&path_c, flags);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/fs.zig:1765:24: 0x10077cd41 in std.fs.Dir.updateFile (build)
        var src_file = try source_dir.openFile(source_path, .{});
                       ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/build.zig:2342:25: 0x10077741a in std.build.LibExeObjStep.make (build)
                    _ = try src_dir.updateFile(entry.name, dest_dir, entry.name, .{});
                        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/build.zig:2595:9: 0x10072b03e in std.build.Step.make (build)
        try self.makeFn(self);
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/build.zig:417:9: 0x100729390 in std.build.Builder.makeOneStep (build)
        try s.make();
        ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/build.zig:411:17: 0x10072930f in std.build.Builder.makeOneStep (build)
                return err;
                ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/build.zig:372:13: 0x100718d81 in std.build.Builder.make (build)
            try self.makeOneStep(s);
            ^
/Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/lib/zig/std/special/build_runner.zig:130:21: 0x100714ca7 in main (build)
            else => return err,
                    ^
error: the following build command failed with exit code 1:
/Users/dbandstra/code/simple_project/zig-cache/o/4dfead05ab1bbb6a3a735f2f30843ca8/build /Users/dbandstra/zig-macos-x86_64-0.6.0+0e2d858d6/zig /Users/dbandstra/code/simple_project /Users/dbandstra/code/simple_project/zig-cache main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions