Skip to content

-fno-emit-bin crashes #16347

@clickingbuttons

Description

@clickingbuttons

Zig Version

0.11.0-dev.3941+91daf1c8d

Steps to Reproduce and Observed Behavior

lib.zig

pub export fn add(a: i32, b: i32) i32 {
    return a + b;
}
~/src/zig/build/stage3/bin/zig build-lib lib.zig -fno-emit-bin

Gives the following trace:

thread 210714 panic: attempt to use null value
/home/thesm/src/zig/src/link.zig:973:44: 0x5bbd4b7 in linkAsArchive (zig)
        const directory = base.options.emit.?.directory; // Just an alias to make it shorter to type.
                                           ^
/home/thesm/src/zig/src/link.zig:786:38: 0x5984951 in flush (zig)
            return base.linkAsArchive(comp, prog_node);
                                     ^
/home/thesm/src/zig/src/Compilation.zig:2169:24: 0x59843b5 in flush (zig)
    comp.bin_file.flush(comp, prog_node) catch |err| switch (err) {
                       ^
/home/thesm/src/zig/src/Compilation.zig:2150:23: 0x59871f4 in update (zig)
        try comp.flush(main_progress_node);
                      ^
/home/thesm/src/zig/src/main.zig:3862:24: 0x59b34e0 in updateModule (zig)
        try comp.update(main_progress_node);
                       ^
/home/thesm/src/zig/src/main.zig:3297:17: 0x58445fb in buildOutputType (zig)
    updateModule(comp) catch |err| switch (err) {
                ^
/home/thesm/src/zig/src/main.zig:271:31: 0x57f3302 in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Lib });
                              ^
/home/thesm/src/zig/src/main.zig:213:20: 0x57f0805 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/thesm/src/zig/lib/std/start.zig:608:37: 0x57f0287 in main (zig)
            const result = root.main() catch |err| {
                                    ^
zsh: IOT instruction (core dumped)  ~/src/zig/build/stage3/bin/zig build-lib lib.zig -fno-emit-bin

Expected Behavior

No crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorlinking

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions