diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/link.zig | 8 | ||||
| -rw-r--r-- | src/link/MachO.zig | 12 | ||||
| -rw-r--r-- | src/main.zig | 16 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/link.zig b/src/link.zig index 3df3727fc3..159f7ed910 100644 --- a/src/link.zig +++ b/src/link.zig @@ -238,6 +238,14 @@ pub const File = struct { } pub fn makeExecutable(base: *File) !void { + switch (base.options.output_mode) { + .Obj => return, + .Lib => switch (base.options.link_mode) { + .Static => return, + .Dynamic => {}, + }, + .Exe => {}, + } switch (base.tag) { .macho => if (base.file) |f| { if (base.intermediary_basename != null) { diff --git a/src/link/MachO.zig b/src/link/MachO.zig index d7bc26c312..97d2332018 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -681,7 +681,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { if (result.term != .Exited or result.term.Exited != 0) { // TODO parse this output and surface with the Compilation API rather than // directly outputting to stderr here. - std.debug.print("{}", .{result.stderr}); + std.log.err("{}", .{result.stderr}); return error.LDReportedFailure; } } else { @@ -716,7 +716,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { if (!ok) { // TODO parse this output and surface with the Compilation API rather than // directly outputting to stderr here. - std.debug.print("{}", .{stderr_context.data.items}); + std.log.err("{}", .{stderr_context.data.items}); return error.LLDReportedFailure; } if (stderr_context.data.items.len != 0) { @@ -736,10 +736,10 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { // TODO We are in the position to be able to increase the padding by moving all sections // by the required offset, but this requires a little bit more thinking and bookkeeping. // For now, return an error informing the user of the problem. - std.debug.print("Not enough padding between load commands and start of __text section:\n", .{}); - std.debug.print("Offset after last load command: 0x{x}\n", .{after_last_cmd_offset}); - std.debug.print("Beginning of __text section: 0x{x}\n", .{text_section.offset}); - std.debug.print("Needed size: 0x{x}\n", .{needed_size}); + std.log.err("Not enough padding between load commands and start of __text section:\n", .{}); + std.log.err("Offset after last load command: 0x{x}\n", .{after_last_cmd_offset}); + std.log.err("Beginning of __text section: 0x{x}\n", .{text_section.offset}); + std.log.err("Needed size: 0x{x}\n", .{needed_size}); return error.NotEnoughPadding; } const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; diff --git a/src/main.zig b/src/main.zig index b69a019d71..ca4a8ebe2b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1773,17 +1773,7 @@ fn buildOutputType( error.SemanticAnalyzeFail => process.exit(1), else => |e| return e, }; - switch (output_mode) { - .Exe => try comp.makeBinFileExecutable(), - .Lib => { - if (link_mode) |lm| { - if (lm == .Dynamic) { - try comp.makeBinFileExecutable(); - } - } - }, - else => {}, - } + try comp.makeBinFileExecutable(); if (build_options.is_stage1 and comp.stage1_lock != null and watch) { warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{}); @@ -1882,9 +1872,7 @@ fn buildOutputType( while (watch) { try stderr.print("(zig) ", .{}); - if (output_mode == .Exe) { - try comp.makeBinFileExecutable(); - } + try comp.makeBinFileExecutable(); if (stdin.readUntilDelimiterOrEof(&repl_buf, '\n') catch |err| { try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)}); continue; |
