Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm: incremental Builder improvements #16487

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/std/Build/Step.zig
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub fn evalZigProcess(
s: *Step,
argv: []const []const u8,
prog_node: *std.Progress.Node,
) ![]const u8 {
) !?[]const u8 {
assert(argv.len != 0);
const b = s.owner;
const arena = b.allocator;
Expand Down Expand Up @@ -423,6 +423,8 @@ pub fn evalZigProcess(
});
}

if (s.cast(Compile)) |compile| if (compile.emit_bin == .no_emit) return result;
jacobly0 marked this conversation as resolved.
Show resolved Hide resolved

return result orelse return s.fail(
"the following command failed to communicate the compilation result:\n{s}",
.{try allocPrintCmd(arena, null, argv)},
Expand Down
7 changes: 4 additions & 3 deletions lib/std/Build/Step/Compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1997,18 +1997,19 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
try zig_args.append(resolved_args_file);
}

const output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) {
const maybe_output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) {
error.NeedCompileErrorCheck => {
assert(self.expect_errors.len != 0);
try checkCompileErrors(self);
return;
},
else => |e| return e,
};
const output_dir = fs.path.dirname(output_bin_path).?;

// Update generated files
{
if (maybe_output_bin_path) |output_bin_path| {
const output_dir = fs.path.dirname(output_bin_path).?;

self.output_dirname_source.path = output_dir;

self.output_path_source.path = b.pathJoin(
Expand Down
4 changes: 2 additions & 2 deletions lib/std/Build/Step/TranslateC.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {

const output_path = try step.evalZigProcess(argv_list.items, prog_node);

self.out_basename = fs.path.basename(output_path);
const output_dir = fs.path.dirname(output_path).?;
self.out_basename = fs.path.basename(output_path.?);
const output_dir = fs.path.dirname(output_path.?).?;

self.output_file.path = try fs.path.join(
b.allocator,
Expand Down
10 changes: 7 additions & 3 deletions lib/std/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ pub const Target = struct {
return switch (target.cpu.arch) {
.amdgcn => 4,
.x86 => switch (target.os.tag) {
.windows => 4,
.windows, .uefi => 4,
else => 16,
},
.arm,
Expand All @@ -1931,8 +1931,6 @@ pub const Target = struct {
.bpfel,
.mips64,
.mips64el,
.powerpc64,
.powerpc64le,
.riscv32,
.riscv64,
.sparc64,
Expand All @@ -1941,6 +1939,12 @@ pub const Target = struct {
.wasm32,
.wasm64,
=> 16,
.powerpc64,
.powerpc64le,
=> switch (target.os.tag) {
else => 8,
.linux => 16,
},
else => @divExact(target.ptrBitWidth(), 8),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
buf.appendSliceAssumeCapacity(",");
}
}
if (buf.items.len == 0) break :blk "";
assert(mem.endsWith(u8, buf.items, ","));
buf.items[buf.items.len - 1] = 0;
buf.shrinkAndFree(buf.items.len);
Expand Down
Loading