Skip to content

bad permissions in macho archive file #23164

@vrischmann

Description

@vrischmann

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

Hello,

Some context.

I'm working on an project where I have a "core" library in zig and a ui in Qt that will consume this.

This core library is made of C dependencies and Zig code that I build with the zig build system, each dependency and my code is its own .a file.

To simplify consuming these libraries in my ui code, I want to merge everything into a single "fat" library. Without going into too much details, I wrote a build system step that does that for me using zig ar x and then zig ar rcs.

This works fine on Linux but on macOS I've encountered an issue: the file permissions of the object files in the archive are all 0, see this zig ar tv foo.a output:

---------       0/0       1431776 Jan  1 01:00 1970 libzig_a_perm.a.o

and this has the effect that zir ar x foo.a produces files on the filesystem that all have 0 permissions has well:

$ ll
----------  1 vincent  staff  1431776 Mar  9 19:35 libzig_a_perm.a.o

I'm not sure if this is intended, however I tested producing a .a file with cmake+clang and the permissions are different there:

rw-r--r-- 501/20    536 Mar  7 00:32 2025 main.c.o

so this makes me think the permissions are wrong.

Expected Behavior

I'm not sure what to expect for permissions, I'm not that familiar with the archive format. But I think I at least expect the permissions to allow reads.

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