aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-16 12:46:39 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-10-18 16:52:43 -0700
commitcaddbbc315e834241c6ae7e22434b574c589e5fc (patch)
treefe412c607e0e4a21a8f43da130335ace3c4fe304 /src
parent10132126972604c4636b148df27ab7fe9e50136b (diff)
downloadzig-caddbbc315e834241c6ae7e22434b574c589e5fc.tar.gz
zig-caddbbc315e834241c6ae7e22434b574c589e5fc.zip
build: avoid compiling self-hosted twice
build.zig: add a 'compile' step to compile the self-hosted compiler without installing it. Compilation: set cache mode to whole when using the LLVM backend and --enable-cache is passed. This makes `zig build` act the same as it does with stage1. Upside is that a second invocation of `zig build` on an unmodified source tree will avoid redoing the compilation again. Downside is that it will proliferate more garbage in the project-local cache (same as stage1). This can eventually be fixed when Zig's incremental compilation is more robust; we can go back to having LLVM use CacheMode.incremental and rely on it detecting no changes and avoiding doing the flush() step.
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig13
-rw-r--r--src/link/Elf.zig2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 0ff9481875..659cfda9bd 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1109,11 +1109,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
const use_stage1 = options.use_stage1 orelse false;
- 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: {
if (options.use_llvm) |explicit|
@@ -1154,6 +1149,14 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
}
}
+ // TODO: once we support incremental compilation for the LLVM backend via
+ // saving the LLVM module into a bitcode file and restoring it, along with
+ // compiler state, the second clause here can be removed so that incremental
+ // cache mode is used for LLVM backend too. We need some fuzz testing before
+ // that can be enabled.
+ const cache_mode = if ((use_stage1 and !options.disable_lld_caching) or
+ (use_llvm and !options.disable_lld_caching)) CacheMode.whole else options.cache_mode;
+
const tsan = options.want_tsan orelse false;
// TSAN is implemented in C++ so it requires linking libc++.
const link_libcpp = options.link_libcpp or tsan;
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 4e67c095c0..1a722c1dde 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1282,7 +1282,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
// linked are in the hash that namespaces the directory we are outputting to. Therefore,
// we must hash those now, and the resulting digest will form the "id" of the linking
// job we are about to perform.
- // After a successful link, we store the id in the metadata of a symlink named "id.txt" in
+ // After a successful link, we store the id in the metadata of a symlink named "lld.id" in
// the artifact directory. So, now, we check if this symlink exists, and if it matches
// our digest. If so, we can skip linking. Otherwise, we proceed with invoking LLD.
const id_symlink_basename = "lld.id";