aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-06-12 20:46:36 -0400
committerGitHub <noreply@github.com>2025-06-12 20:46:36 -0400
commitdcdb4422b801f2d184107fdd7b9493f7840a0244 (patch)
treeca7a37c544382c10e45fbad68ea7701a05d0543c /lib/std/Build/Step/Compile.zig
parent5e3c0b7af7cd866f5464c244b9775e488b93ae48 (diff)
parent43d01ff69f6c6c46bef81dd4de2c78fb0a942b65 (diff)
downloadzig-dcdb4422b801f2d184107fdd7b9493f7840a0244.tar.gz
zig-dcdb4422b801f2d184107fdd7b9493f7840a0244.zip
Merge pull request #24124 from mlugg/better-backend-pipeline-2
compiler: threaded codegen (and more goodies)
Diffstat (limited to 'lib/std/Build/Step/Compile.zig')
-rw-r--r--lib/std/Build/Step/Compile.zig66
1 files changed, 25 insertions, 41 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index dd8c4158ce..924dc18f91 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -1834,47 +1834,16 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
lp.path = b.fmt("{}", .{output_dir});
}
- // -femit-bin[=path] (default) Output machine code
- if (compile.generated_bin) |bin| {
- bin.path = output_dir.joinString(b.allocator, compile.out_filename) catch @panic("OOM");
- }
-
- const sep = std.fs.path.sep_str;
-
- // output PDB if someone requested it
- if (compile.generated_pdb) |pdb| {
- pdb.path = b.fmt("{}" ++ sep ++ "{s}.pdb", .{ output_dir, compile.name });
- }
-
- // -femit-implib[=path] (default) Produce an import .lib when building a Windows DLL
- if (compile.generated_implib) |implib| {
- implib.path = b.fmt("{}" ++ sep ++ "{s}.lib", .{ output_dir, compile.name });
- }
-
- // -femit-h[=path] Generate a C header file (.h)
- if (compile.generated_h) |lp| {
- lp.path = b.fmt("{}" ++ sep ++ "{s}.h", .{ output_dir, compile.name });
- }
-
- // -femit-docs[=path] Create a docs/ dir with html documentation
- if (compile.generated_docs) |generated_docs| {
- generated_docs.path = output_dir.joinString(b.allocator, "docs") catch @panic("OOM");
- }
-
- // -femit-asm[=path] Output .s (assembly code)
- if (compile.generated_asm) |lp| {
- lp.path = b.fmt("{}" ++ sep ++ "{s}.s", .{ output_dir, compile.name });
- }
-
- // -femit-llvm-ir[=path] Produce a .ll file with optimized LLVM IR (requires LLVM extensions)
- if (compile.generated_llvm_ir) |lp| {
- lp.path = b.fmt("{}" ++ sep ++ "{s}.ll", .{ output_dir, compile.name });
- }
-
- // -femit-llvm-bc[=path] Produce an optimized LLVM module as a .bc file (requires LLVM extensions)
- if (compile.generated_llvm_bc) |lp| {
- lp.path = b.fmt("{}" ++ sep ++ "{s}.bc", .{ output_dir, compile.name });
- }
+ // zig fmt: off
+ if (compile.generated_bin) |lp| lp.path = compile.outputPath(output_dir, .bin);
+ if (compile.generated_pdb) |lp| lp.path = compile.outputPath(output_dir, .pdb);
+ if (compile.generated_implib) |lp| lp.path = compile.outputPath(output_dir, .implib);
+ if (compile.generated_h) |lp| lp.path = compile.outputPath(output_dir, .h);
+ if (compile.generated_docs) |lp| lp.path = compile.outputPath(output_dir, .docs);
+ if (compile.generated_asm) |lp| lp.path = compile.outputPath(output_dir, .@"asm");
+ if (compile.generated_llvm_ir) |lp| lp.path = compile.outputPath(output_dir, .llvm_ir);
+ if (compile.generated_llvm_bc) |lp| lp.path = compile.outputPath(output_dir, .llvm_bc);
+ // zig fmt: on
}
if (compile.kind == .lib and compile.linkage != null and compile.linkage.? == .dynamic and
@@ -1888,6 +1857,21 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
);
}
}
+fn outputPath(c: *Compile, out_dir: std.Build.Cache.Path, ea: std.zig.EmitArtifact) []const u8 {
+ const arena = c.step.owner.graph.arena;
+ const name = ea.cacheName(arena, .{
+ .root_name = c.name,
+ .target = c.root_module.resolved_target.?.result,
+ .output_mode = switch (c.kind) {
+ .lib => .Lib,
+ .obj, .test_obj => .Obj,
+ .exe, .@"test" => .Exe,
+ },
+ .link_mode = c.linkage,
+ .version = c.version,
+ }) catch @panic("OOM");
+ return out_dir.joinString(arena, name) catch @panic("OOM");
+}
pub fn rebuildInFuzzMode(c: *Compile, progress_node: std.Progress.Node) !Path {
const gpa = c.step.owner.allocator;