diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 47df2a7d3d..70aa2fec04 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -762,9 +762,6 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { try self.writeHeader(); // Generate adhoc code signature try self.writeCodeSignature(); - // Move file in-place to please the kernel - const emit = self.base.options.emit.?; - try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{}); } } } diff --git a/src/main.zig b/src/main.zig index b6858588e9..b69a019d71 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1773,8 +1773,16 @@ fn buildOutputType( error.SemanticAnalyzeFail => process.exit(1), else => |e| return e, }; - if (output_mode == .Exe) { - try comp.makeBinFileExecutable(); + switch (output_mode) { + .Exe => try comp.makeBinFileExecutable(), + .Lib => { + if (link_mode) |lm| { + if (lm == .Dynamic) { + try comp.makeBinFileExecutable(); + } + } + }, + else => {}, } if (build_options.is_stage1 and comp.stage1_lock != null and watch) { @@ -2413,6 +2421,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v defer comp.destroy(); try updateModule(gpa, comp, null, .none); + try comp.makeBinFileExecutable(); child_argv.items[argv_index_exe] = try comp.bin_file.options.emit.?.directory.join( arena,