aboutsummaryrefslogtreecommitdiff
path: root/src/link/Coff.zig
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2021-01-03 16:09:32 +0100
committerTimon Kruiper <timonkruiper@gmail.com>2021-01-03 17:39:43 +0100
commit3c05c60accb534e857e4ad2c1a957d439af184e4 (patch)
treebe30787aba2c0c87e066e84c9f10dddc289d2ee6 /src/link/Coff.zig
parent0008bef1e643c190a12e13d99a21d5af7ebdaa1b (diff)
downloadzig-3c05c60accb534e857e4ad2c1a957d439af184e4.tar.gz
zig-3c05c60accb534e857e4ad2c1a957d439af184e4.zip
stage2: Output the LLVM object files in the cache directory
Also make sure to properly free everything.
Diffstat (limited to 'src/link/Coff.zig')
-rw-r--r--src/link/Coff.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index a3cb5cc4c7..117bdef4a7 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -811,8 +811,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
// If there is no Zig code to compile, then we should skip flushing the output file because it
// will not be part of the linker line anyway.
const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: {
- const use_stage1 = build_options.is_stage1 and self.base.options.use_llvm;
- if (use_stage1) {
+ // Both stage1 and stage2 LLVM backend put the object file in the cache directory.
+ if (self.base.options.use_llvm) {
+ // Stage2 has to call flushModule since that outputs the LLVM object file.
+ if (!build_options.is_stage1) try self.flushModule(comp);
+
const obj_basename = try std.zig.binNameAlloc(arena, .{
.root_name = self.base.options.root_name,
.target = self.base.options.target,