From d6c5602d4665ba4e9e7c0b7f42bd00b2489d420c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 30 Dec 2021 17:05:17 -0700 Subject: stage2: fix CLI not populating output binary files This fixes a regression in this branch that can be reproduced with the following steps: 1. `zig build-exe hello.zig` 2. delete the "hello" binary 3. `zig build-exe hello.zig` 4. observe that the "hello" binary is missing This happened because it was a cache hit, but nothing got copied to the output directory. This commit sets CacheMode to incremental - even for stage1 - when the CLI requests `disable_lld_caching` (this option should be renamed), resulting in the main Compilation to be repeated (uncached) for stage1, populating the binary into the cwd as expected. For stage2 the result is even better: the incremental compilation system will look for build artifacts to incrementally compile, and start fresh if not found. --- src/Compilation.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index ac48804848..ddf331d4f3 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -899,7 +899,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { break :blk build_options.is_stage1; }; - const cache_mode = if (use_stage1) CacheMode.whole else options.cache_mode; + const cache_mode = if (use_stage1 and !options.disable_lld_caching) + CacheMode.whole + else + options.cache_mode; // Make a decision on whether to use LLVM or our own backend. const use_llvm = build_options.have_llvm and blk: { @@ -1951,8 +1954,6 @@ pub fn update(comp: *Compilation) !void { }; } - comp.emitOthers(); - assert(comp.bin_file.lock == null); comp.bin_file.lock = man.toOwnedLock(); return; -- cgit v1.2.3