Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-fno-emit-bin crashes #16347

Closed
clickingbuttons opened this issue Jul 7, 2023 · 0 comments
Closed

-fno-emit-bin crashes #16347

clickingbuttons opened this issue Jul 7, 2023 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior linking
Milestone

Comments

@clickingbuttons
Copy link
Contributor

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.

@clickingbuttons clickingbuttons added the bug Observed behavior contradicts documented or intended behavior label Jul 7, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Jul 22, 2023
QusaiHroub pushed a commit to QusaiHroub/zig that referenced this issue Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior linking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants