Skip to content

Zig 0.12.0 fails to link against dynamic library on MacOS #19753

@aherrmann

Description

@aherrmann

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

Zig fails to link against a dynamic library when it is passed by filename on the command-line, i.e. a command like

$ zig build-lib some-dir/libadd.dylib main.zig

fails with an error of the form

error: unknown file type for an object file
    note: while parsing some-dir/libadd.dylib

However, it succeeds when instead using -L and -l flags as follows

$ zig build-lib -Lsome-dir -ladd main.zig

See aherrmann/rules_zig#274 for further details.

Note, this used to work with Zig 0.11.0. So, this is a regression.

Expected Behavior

The linking should succeed with both types of commands. For reference zig build-lib --help states:

Supported file types:
                    .zig    Zig source code
...
                  .dylib    Mach-O (macOS) dynamic library
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions