Commit 3e2d1ccaad

Jakub Konka <kubkon@jakubkonka.com>
2020-12-02 00:03:07
lld+macho: rename final artefact in main.zig
1 parent b58a2a4
Changed files (2)
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, .{});
             }
         }
     }
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,