Skip to content

Zig cc: support -Wl,-adhoc_codesign and -Wl,-no_adhoc_codesign #17000

Description

@dan-smetana

Zig Version

0.11.0

Steps to Reproduce and Observed Behavior

I've been using zig cc in combination with rcodesign and I ran into an issue where rcodesign would complain about there not being enough space left for the signature. This only happened with some programs.

Interestingly this never happened for aarch64 builds. I decided to look into the Zig code, and I found this interesting bit: https://github.com/ziglang/zig/blob/master/src/link/MachO.zig#L691

I patched Zig with the following patch and the issue disappeared completely:

diff --git a/src/link/MachO/load_commands.zig b/src/link/MachO/load_commands.zig
index 8f803d98c..721b4e3c5 100644
--- a/src/link/MachO/load_commands.zig
+++ b/src/link/MachO/load_commands.zig
@@ -105,7 +105,7 @@ fn calcLCsSize(gpa: Allocator, options: *const link.Options, ctx: CalcLCsSizeCtx
         const target = options.target;
         const requires_codesig = blk: {
             if (options.entitlements) |_| break :blk true;
-            if (target.cpu.arch == .aarch64 and (target.os.tag == .macos or target.abi == .simulator))
+            if (target.os.tag == .macos or target.abi == .simulator)
                 break :blk true;
             break :blk false;
         };

Is it possible to add a flag to enable codesigning using zig cc? Or enable it by default, seeing it's already doing that on aarch64? What are the reasons for it to be disabled on amd64?

Expected Behavior

Either codesigning should be enabled by default for macos/amd64 too, or there should be a flag in zig cc to enable it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions