mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
lld+macho: address review comments
This commit is contained in:
parent
5cba16c707
commit
d3be499270
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
16
src/main.zig
16
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user