Commit 4d59f77528

Andrew Kelley <andrew@ziglang.org>
2020-09-14 04:49:52
stage2: rename Module to Compilation
1 parent 2a8fc1a
src-self-hosted/link/C.zig
@@ -3,7 +3,7 @@ const mem = std.mem;
 const assert = std.debug.assert;
 const Allocator = std.mem.Allocator;
 const Module = @import("../ZigModule.zig");
-const Compilation = @import("../Module.zig");
+const Compilation = @import("../Compilation.zig");
 const fs = std.fs;
 const codegen = @import("../codegen/c.zig");
 const link = @import("../link.zig");
src-self-hosted/link/Coff.zig
@@ -8,7 +8,7 @@ const fs = std.fs;
 
 const trace = @import("../tracy.zig").trace;
 const Module = @import("../ZigModule.zig");
-const Compilation = @import("../Module.zig");
+const Compilation = @import("../Compilation.zig");
 const codegen = @import("../codegen.zig");
 const link = @import("../link.zig");
 
src-self-hosted/link/Elf.zig
@@ -4,7 +4,7 @@ const assert = std.debug.assert;
 const Allocator = std.mem.Allocator;
 const ir = @import("../ir.zig");
 const Module = @import("../ZigModule.zig");
-const Compilation = @import("../Module.zig");
+const Compilation = @import("../Compilation.zig");
 const fs = std.fs;
 const elf = std.elf;
 const codegen = @import("../codegen.zig");
src-self-hosted/link/MachO.zig
@@ -13,7 +13,7 @@ const trace = @import("../tracy.zig").trace;
 const Type = @import("../type.zig").Type;
 
 const Module = @import("../ZigModule.zig");
-const Compilation = @import("../Module.zig");
+const Compilation = @import("../Compilation.zig");
 const link = @import("../link.zig");
 const File = link.File;
 
src-self-hosted/link/Wasm.zig
@@ -7,7 +7,7 @@ const fs = std.fs;
 const leb = std.debug.leb;
 
 const Module = @import("../ZigModule.zig");
-const Compilation = @import("../Module.zig");
+const Compilation = @import("../Compilation.zig");
 const codegen = @import("../codegen/wasm.zig");
 const link = @import("../link.zig");
 
src-self-hosted/codegen.zig
@@ -8,7 +8,7 @@ const Value = @import("value.zig").Value;
 const TypedValue = @import("TypedValue.zig");
 const link = @import("link.zig");
 const Module = @import("ZigModule.zig");
-const Compilation = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 const ErrorMsg = Compilation.ErrorMsg;
 const Target = std.Target;
 const Allocator = mem.Allocator;
src-self-hosted/Module.zig → src-self-hosted/Compilation.zig
@@ -1,5 +1,3 @@
-//! TODO This is going to get renamed from Module to Compilation.
-const Module = @This();
 const Compilation = @This();
 
 const std = @import("std");
@@ -31,7 +29,7 @@ link_error_flags: link.File.ErrorFlags = .{},
 
 work_queue: std.fifo.LinearFifo(WorkItem, .Dynamic),
 
-/// The ErrorMsg memory is owned by the `CObject`, using Module's general purpose allocator.
+/// The ErrorMsg memory is owned by the `CObject`, using Compilation's general purpose allocator.
 failed_c_objects: std.AutoArrayHashMapUnmanaged(*CObject, *ErrorMsg) = .{},
 
 keep_source_files_loaded: bool,
@@ -39,7 +37,7 @@ use_clang: bool,
 sanitize_c: bool,
 /// When this is `true` it means invoking clang as a sub-process is expected to inherit
 /// stdin, stdout, stderr, and if it returns non success, to forward the exit code.
-/// Otherwise we attempt to parse the error messages and expose them via the Module API.
+/// Otherwise we attempt to parse the error messages and expose them via the Compilation API.
 /// This is `true` for `zig cc`, `zig c++`, and `zig translate-c`.
 clang_passthrough_mode: bool,
 /// Whether to print clang argvs to stdout.
@@ -96,7 +94,7 @@ const WorkItem = union(enum) {
     /// Decl may need its line number information updated in the debug info.
     update_line_number: *ZigModule.Decl,
     /// Invoke the Clang compiler to create an object file, which gets linked
-    /// with the Module.
+    /// with the Compilation.
     c_object: *CObject,
 
     /// one of the glibc static objects
@@ -192,8 +190,8 @@ pub const Directory = struct {
 
 pub const EmitLoc = struct {
     /// If this is `null` it means the file will be output to the cache directory.
-    /// When provided, both the open file handle and the path name must outlive the `Module`.
-    directory: ?Module.Directory,
+    /// When provided, both the open file handle and the path name must outlive the `Compilation`.
+    directory: ?Compilation.Directory,
     /// This may not have sub-directories in it.
     basename: []const u8,
 };
@@ -257,17 +255,17 @@ pub const InitOptions = struct {
     libc_installation: ?*const LibCInstallation = null,
 };
 
-pub fn create(gpa: *Allocator, options: InitOptions) !*Module {
-    const comp: *Module = comp: {
-        // For allocations that have the same lifetime as Module. This arena is used only during this
+pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
+    const comp: *Compilation = comp: {
+        // For allocations that have the same lifetime as Compilation. This arena is used only during this
         // initialization and then is freed in deinit().
         var arena_allocator = std.heap.ArenaAllocator.init(gpa);
         errdefer arena_allocator.deinit();
         const arena = &arena_allocator.allocator;
 
-        // We put the `Module` itself in the arena. Freeing the arena will free the module.
+        // We put the `Compilation` itself in the arena. Freeing the arena will free the module.
         // It's initialized later after we prepare the initialization options.
-        const comp = try arena.create(Module);
+        const comp = try arena.create(Compilation);
         const root_name = try arena.dupe(u8, options.root_name);
 
         const ofmt = options.object_format orelse options.target.getObjectFormat();
@@ -606,7 +604,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Module {
     return comp;
 }
 
-pub fn destroy(self: *Module) void {
+pub fn destroy(self: *Compilation) void {
     const optional_zig_module = self.bin_file.options.zig_module;
     self.bin_file.destroy();
     if (optional_zig_module) |zig_module| zig_module.deinit();
@@ -640,12 +638,12 @@ pub fn destroy(self: *Module) void {
     self.arena_state.promote(gpa).deinit();
 }
 
-pub fn getTarget(self: Module) Target {
+pub fn getTarget(self: Compilation) Target {
     return self.bin_file.options.target;
 }
 
 /// Detect changes to source files, perform semantic analysis, and update the output files.
-pub fn update(self: *Module) !void {
+pub fn update(self: *Compilation) !void {
     const tracy = trace(@src());
     defer tracy.end();
 
@@ -713,15 +711,15 @@ pub fn update(self: *Module) !void {
 /// binary is concerned. This will remove the write flag, or close the file,
 /// or whatever is needed so that it can be executed.
 /// After this, one must call` makeFileWritable` before calling `update`.
-pub fn makeBinFileExecutable(self: *Module) !void {
+pub fn makeBinFileExecutable(self: *Compilation) !void {
     return self.bin_file.makeExecutable();
 }
 
-pub fn makeBinFileWritable(self: *Module) !void {
+pub fn makeBinFileWritable(self: *Compilation) !void {
     return self.bin_file.makeWritable();
 }
 
-pub fn totalErrorCount(self: *Module) usize {
+pub fn totalErrorCount(self: *Compilation) usize {
     var total: usize = self.failed_c_objects.items().len;
 
     if (self.bin_file.options.zig_module) |zig_module| {
@@ -738,7 +736,7 @@ pub fn totalErrorCount(self: *Module) usize {
     return total;
 }
 
-pub fn getAllErrorsAlloc(self: *Module) !AllErrors {
+pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
     var arena = std.heap.ArenaAllocator.init(self.gpa);
     errdefer arena.deinit();
 
@@ -795,7 +793,7 @@ pub fn getAllErrorsAlloc(self: *Module) !AllErrors {
     };
 }
 
-pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {
+pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
     while (self.work_queue.readItem()) |work_item| switch (work_item) {
         .codegen_decl => |decl| switch (decl.analysis) {
             .unreferenced => unreachable,
@@ -1071,25 +1069,25 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
     };
 }
 
-fn tmpFilePath(mod: *Module, arena: *Allocator, suffix: []const u8) error{OutOfMemory}![]const u8 {
+fn tmpFilePath(comp: *Compilation, arena: *Allocator, suffix: []const u8) error{OutOfMemory}![]const u8 {
     const s = std.fs.path.sep_str;
     return std.fmt.allocPrint(
         arena,
         "{}" ++ s ++ "tmp" ++ s ++ "{x}-{}",
-        .{ mod.zig_cache_directory.path.?, mod.rand.int(u64), suffix },
+        .{ comp.zig_cache_directory.path.?, comp.rand.int(u64), suffix },
     );
 }
 
 /// Add common C compiler args between translate-c and C object compilation.
 fn addCCArgs(
-    mod: *Module,
+    comp: *Compilation,
     arena: *Allocator,
     argv: *std.ArrayList([]const u8),
     ext: FileExt,
     translate_c: bool,
     out_dep_path: ?[]const u8,
 ) !void {
-    const target = mod.getTarget();
+    const target = comp.getTarget();
 
     if (translate_c) {
         try argv.appendSlice(&[_][]const u8{ "-x", "c" });
@@ -1106,27 +1104,27 @@ fn addCCArgs(
     // We don't ever put `-fcolor-diagnostics` or `-fno-color-diagnostics` because in passthrough mode
     // we want Clang to infer it, and in normal mode we always want it off, which will be true since
     // clang will detect stderr as a pipe rather than a terminal.
-    if (!mod.clang_passthrough_mode) {
+    if (!comp.clang_passthrough_mode) {
         // Make stderr more easily parseable.
         try argv.append("-fno-caret-diagnostics");
     }
 
-    if (mod.bin_file.options.function_sections) {
+    if (comp.bin_file.options.function_sections) {
         try argv.append("-ffunction-sections");
     }
 
-    try argv.ensureCapacity(argv.items.len + mod.bin_file.options.framework_dirs.len * 2);
-    for (mod.bin_file.options.framework_dirs) |framework_dir| {
+    try argv.ensureCapacity(argv.items.len + comp.bin_file.options.framework_dirs.len * 2);
+    for (comp.bin_file.options.framework_dirs) |framework_dir| {
         argv.appendAssumeCapacity("-iframework");
         argv.appendAssumeCapacity(framework_dir);
     }
 
-    if (mod.bin_file.options.link_libcpp) {
+    if (comp.bin_file.options.link_libcpp) {
         const libcxx_include_path = try std.fs.path.join(arena, &[_][]const u8{
-            mod.zig_lib_directory.path.?, "libcxx", "include",
+            comp.zig_lib_directory.path.?, "libcxx", "include",
         });
         const libcxxabi_include_path = try std.fs.path.join(arena, &[_][]const u8{
-            mod.zig_lib_directory.path.?, "libcxxabi", "include",
+            comp.zig_lib_directory.path.?, "libcxxabi", "include",
         });
 
         try argv.append("-isystem");
@@ -1150,11 +1148,11 @@ fn addCCArgs(
             // According to Rich Felker libc headers are supposed to go before C language headers.
             // However as noted by @dimenus, appending libc headers before c_headers breaks intrinsics
             // and other compiler specific items.
-            const c_headers_dir = try std.fs.path.join(arena, &[_][]const u8{ mod.zig_lib_directory.path.?, "include" });
+            const c_headers_dir = try std.fs.path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, "include" });
             try argv.append("-isystem");
             try argv.append(c_headers_dir);
 
-            for (mod.libc_include_dir_list) |include_dir| {
+            for (comp.libc_include_dir_list) |include_dir| {
                 try argv.append("-isystem");
                 try argv.append(include_dir);
             }
@@ -1206,28 +1204,28 @@ fn addCCArgs(
         try argv.append("-Wno-pragma-pack");
     }
 
-    if (!mod.bin_file.options.strip) {
+    if (!comp.bin_file.options.strip) {
         try argv.append("-g");
     }
 
-    if (mod.haveFramePointer()) {
+    if (comp.haveFramePointer()) {
         try argv.append("-fno-omit-frame-pointer");
     } else {
         try argv.append("-fomit-frame-pointer");
     }
 
-    if (mod.sanitize_c) {
+    if (comp.sanitize_c) {
         try argv.append("-fsanitize=undefined");
         try argv.append("-fsanitize-trap=undefined");
     }
 
-    switch (mod.bin_file.options.optimize_mode) {
+    switch (comp.bin_file.options.optimize_mode) {
         .Debug => {
             // windows c runtime requires -D_DEBUG if using debug libraries
             try argv.append("-D_DEBUG");
             try argv.append("-Og");
 
-            if (mod.bin_file.options.link_libc) {
+            if (comp.bin_file.options.link_libc) {
                 try argv.append("-fstack-protector-strong");
                 try argv.append("--param");
                 try argv.append("ssp-buffer-size=4");
@@ -1239,7 +1237,7 @@ fn addCCArgs(
             // See the comment in the BuildModeFastRelease case for why we pass -O2 rather
             // than -O3 here.
             try argv.append("-O2");
-            if (mod.bin_file.options.link_libc) {
+            if (comp.bin_file.options.link_libc) {
                 try argv.append("-D_FORTIFY_SOURCE=2");
                 try argv.append("-fstack-protector-strong");
                 try argv.append("--param");
@@ -1265,25 +1263,25 @@ fn addCCArgs(
         },
     }
 
-    if (target_util.supports_fpic(target) and mod.bin_file.options.pic) {
+    if (target_util.supports_fpic(target) and comp.bin_file.options.pic) {
         try argv.append("-fPIC");
     }
 
-    try argv.appendSlice(mod.clang_argv);
+    try argv.appendSlice(comp.clang_argv);
 }
 
-fn failCObj(mod: *Module, c_object: *CObject, comptime format: []const u8, args: anytype) InnerError {
+fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) InnerError {
     @setCold(true);
-    const err_msg = try ErrorMsg.create(mod.gpa, 0, "unable to build C object: " ++ format, args);
-    return mod.failCObjWithOwnedErrorMsg(c_object, err_msg);
+    const err_msg = try ErrorMsg.create(comp.gpa, 0, "unable to build C object: " ++ format, args);
+    return comp.failCObjWithOwnedErrorMsg(c_object, err_msg);
 }
 
-fn failCObjWithOwnedErrorMsg(mod: *Module, c_object: *CObject, err_msg: *ErrorMsg) InnerError {
+fn failCObjWithOwnedErrorMsg(comp: *Compilation, c_object: *CObject, err_msg: *ErrorMsg) InnerError {
     {
-        errdefer err_msg.destroy(mod.gpa);
-        try mod.failed_c_objects.ensureCapacity(mod.gpa, mod.failed_c_objects.items().len + 1);
+        errdefer err_msg.destroy(comp.gpa);
+        try comp.failed_c_objects.ensureCapacity(comp.gpa, comp.failed_c_objects.items().len + 1);
     }
-    mod.failed_c_objects.putAssumeCapacityNoClobber(c_object, err_msg);
+    comp.failed_c_objects.putAssumeCapacityNoClobber(c_object, err_msg);
     c_object.status = .failure;
     return error.AnalysisFail;
 }
@@ -1389,9 +1387,9 @@ test "classifyFileExt" {
     std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
 }
 
-fn haveFramePointer(mod: *Module) bool {
-    return switch (mod.bin_file.options.optimize_mode) {
-        .Debug, .ReleaseSafe => !mod.bin_file.options.strip,
+fn haveFramePointer(comp: *Compilation) bool {
+    return switch (comp.bin_file.options.optimize_mode) {
+        .Debug, .ReleaseSafe => !comp.bin_file.options.strip,
         .ReleaseSmall, .ReleaseFast => false,
     };
 }
@@ -1496,17 +1494,17 @@ fn detectLibCFromLibCInstallation(arena: *Allocator, target: Target, lci: *const
     };
 }
 
-pub fn get_libc_crt_file(mod: *Module, arena: *Allocator, basename: []const u8) ![]const u8 {
-    if (mod.wantBuildGLibCFromSource()) {
-        return mod.crt_files.get(basename).?;
+pub fn get_libc_crt_file(comp: *Compilation, arena: *Allocator, basename: []const u8) ![]const u8 {
+    if (comp.wantBuildGLibCFromSource()) {
+        return comp.crt_files.get(basename).?;
     }
-    const lci = mod.bin_file.options.libc_installation orelse return error.LibCInstallationNotAvailable;
+    const lci = comp.bin_file.options.libc_installation orelse return error.LibCInstallationNotAvailable;
     const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCRTDir;
     const full_path = try std.fs.path.join(arena, &[_][]const u8{ crt_dir_path, basename });
     return full_path;
 }
 
-fn addBuildingGLibCWorkItems(mod: *Module) !void {
+fn addBuildingGLibCWorkItems(comp: *Compilation) !void {
     const static_file_work_items = [_]WorkItem{
         .{ .glibc_crt_file = .crti_o },
         .{ .glibc_crt_file = .crtn_o },
@@ -1515,15 +1513,15 @@ fn addBuildingGLibCWorkItems(mod: *Module) !void {
         .{ .glibc_crt_file = .scrt1_o },
         .{ .glibc_crt_file = .libc_nonshared_a },
     };
-    try mod.work_queue.ensureUnusedCapacity(static_file_work_items.len + glibc.libs.len);
-    mod.work_queue.writeAssumeCapacity(&static_file_work_items);
+    try comp.work_queue.ensureUnusedCapacity(static_file_work_items.len + glibc.libs.len);
+    comp.work_queue.writeAssumeCapacity(&static_file_work_items);
     for (glibc.libs) |*glibc_so| {
-        mod.work_queue.writeItemAssumeCapacity(.{ .glibc_so = glibc_so });
+        comp.work_queue.writeItemAssumeCapacity(.{ .glibc_so = glibc_so });
     }
 }
 
-fn wantBuildGLibCFromSource(mod: *Module) bool {
-    return mod.bin_file.options.link_libc and
-        mod.bin_file.options.libc_installation == null and
-        mod.bin_file.options.target.isGnuLibC();
+fn wantBuildGLibCFromSource(comp: *Compilation) bool {
+    return comp.bin_file.options.link_libc and
+        comp.bin_file.options.libc_installation == null and
+        comp.bin_file.options.target.isGnuLibC();
 }
src-self-hosted/glibc.zig
@@ -2,7 +2,7 @@ const std = @import("std");
 const Allocator = std.mem.Allocator;
 const target_util = @import("target.zig");
 const mem = std.mem;
-const Module = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 const path = std.fs.path;
 const build_options = @import("build_options");
 const trace = @import("tracy.zig").trace;
@@ -246,11 +246,11 @@ pub const CRTFile = enum {
     libc_nonshared_a,
 };
 
-pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
+pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
     if (!build_options.have_llvm) {
         return error.ZigCompilerNotBuiltWithLLVMExtensions;
     }
-    const gpa = mod.gpa;
+    const gpa = comp.gpa;
     var arena_allocator = std.heap.ArenaAllocator.init(gpa);
     errdefer arena_allocator.deinit();
     const arena = &arena_allocator.allocator;
@@ -258,29 +258,29 @@ pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
     switch (crt_file) {
         .crti_o => {
             var args = std.ArrayList([]const u8).init(arena);
-            try add_include_dirs(mod, arena, &args);
+            try add_include_dirs(comp, arena, &args);
             try args.appendSlice(&[_][]const u8{
                 "-D_LIBC_REENTRANT",
                 "-include",
-                try lib_path(mod, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
+                try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
                 "-DMODULE_NAME=libc",
                 "-Wno-nonportable-include-path",
                 "-include",
-                try lib_path(mod, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
+                try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
                 "-DTOP_NAMESPACE=glibc",
                 "-DASSEMBLER",
                 "-g",
                 "-Wa,--noexecstack",
             });
-            const c_source_file: Module.CSourceFile = .{
-                .src_path = try start_asm_path(mod, arena, "crti.S"),
+            const c_source_file: Compilation.CSourceFile = .{
+                .src_path = try start_asm_path(comp, arena, "crti.S"),
                 .extra_flags = args.items,
             };
-            return build_libc_object(mod, "crti.o", c_source_file);
+            return build_libc_object(comp, "crti.o", c_source_file);
         },
         .crtn_o => {
             var args = std.ArrayList([]const u8).init(arena);
-            try add_include_dirs(mod, arena, &args);
+            try add_include_dirs(comp, arena, &args);
             try args.appendSlice(&[_][]const u8{
                 "-D_LIBC_REENTRANT",
                 "-DMODULE_NAME=libc",
@@ -289,23 +289,23 @@ pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
                 "-g",
                 "-Wa,--noexecstack",
             });
-            const c_source_file: Module.CSourceFile = .{
-                .src_path = try start_asm_path(mod, arena, "crtn.S"),
+            const c_source_file: Compilation.CSourceFile = .{
+                .src_path = try start_asm_path(comp, arena, "crtn.S"),
                 .extra_flags = args.items,
             };
-            return build_libc_object(mod, "crtn.o", c_source_file);
+            return build_libc_object(comp, "crtn.o", c_source_file);
         },
         .start_os => {
             var args = std.ArrayList([]const u8).init(arena);
-            try add_include_dirs(mod, arena, &args);
+            try add_include_dirs(comp, arena, &args);
             try args.appendSlice(&[_][]const u8{
                 "-D_LIBC_REENTRANT",
                 "-include",
-                try lib_path(mod, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
+                try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
                 "-DMODULE_NAME=libc",
                 "-Wno-nonportable-include-path",
                 "-include",
-                try lib_path(mod, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
+                try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
                 "-DPIC",
                 "-DSHARED",
                 "-DTOP_NAMESPACE=glibc",
@@ -313,19 +313,19 @@ pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
                 "-g",
                 "-Wa,--noexecstack",
             });
-            const c_source_file: Module.CSourceFile = .{
-                .src_path = try start_asm_path(mod, arena, "start.S"),
+            const c_source_file: Compilation.CSourceFile = .{
+                .src_path = try start_asm_path(comp, arena, "start.S"),
                 .extra_flags = args.items,
             };
-            return build_libc_object(mod, "start.os", c_source_file);
+            return build_libc_object(comp, "start.os", c_source_file);
         },
         .abi_note_o => {
             var args = std.ArrayList([]const u8).init(arena);
             try args.appendSlice(&[_][]const u8{
                 "-I",
-                try lib_path(mod, arena, lib_libc_glibc ++ "glibc" ++ path.sep_str ++ "csu"),
+                try lib_path(comp, arena, lib_libc_glibc ++ "glibc" ++ path.sep_str ++ "csu"),
             });
-            try add_include_dirs(mod, arena, &args);
+            try add_include_dirs(comp, arena, &args);
             try args.appendSlice(&[_][]const u8{
                 "-D_LIBC_REENTRANT",
                 "-DMODULE_NAME=libc",
@@ -334,11 +334,11 @@ pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
                 "-g",
                 "-Wa,--noexecstack",
             });
-            const c_source_file: Module.CSourceFile = .{
-                .src_path = try lib_path(mod, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "abi-note.S"),
+            const c_source_file: Compilation.CSourceFile = .{
+                .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "abi-note.S"),
                 .extra_flags = args.items,
             };
-            return build_libc_object(mod, "abi-note.o", c_source_file);
+            return build_libc_object(comp, "abi-note.o", c_source_file);
         },
         .scrt1_o => {
             return error.Unimplemented; // TODO
@@ -349,8 +349,8 @@ pub fn buildCRTFile(mod: *Module, crt_file: CRTFile) !void {
     }
 }
 
-fn start_asm_path(mod: *Module, arena: *Allocator, basename: []const u8) ![]const u8 {
-    const arch = mod.getTarget().cpu.arch;
+fn start_asm_path(comp: *Compilation, arena: *Allocator, basename: []const u8) ![]const u8 {
+    const arch = comp.getTarget().cpu.arch;
     const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le;
     const is_aarch64 = arch == .aarch64 or arch == .aarch64_be;
     const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparcv9;
@@ -359,7 +359,7 @@ fn start_asm_path(mod: *Module, arena: *Allocator, basename: []const u8) ![]cons
     const s = path.sep_str;
 
     var result = std.ArrayList(u8).init(arena);
-    try result.appendSlice(mod.zig_lib_directory.path.?);
+    try result.appendSlice(comp.zig_lib_directory.path.?);
     try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
     if (is_sparc) {
         if (is_64) {
@@ -392,76 +392,76 @@ fn start_asm_path(mod: *Module, arena: *Allocator, basename: []const u8) ![]cons
     return result.items;
 }
 
-fn add_include_dirs(mod: *Module, arena: *Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
-    const target = mod.getTarget();
+fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
+    const target = comp.getTarget();
     const arch = target.cpu.arch;
     const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
-    const glibc = try lib_path(mod, arena, lib_libc ++ "glibc");
+    const glibc = try lib_path(comp, arena, lib_libc ++ "glibc");
 
     const s = path.sep_str;
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "include"));
+    try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include"));
 
     if (target.os.tag == .linux) {
-        try add_include_dirs_arch(arena, args, arch, null, try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
+        try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
     }
 
     if (opt_nptl) |nptl| {
-        try add_include_dirs_arch(arena, args, arch, nptl, try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps"));
+        try add_include_dirs_arch(arena, args, arch, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
     }
 
     if (target.os.tag == .linux) {
         try args.append("-I");
-        try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+        try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
             "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "generic"));
 
         try args.append("-I");
-        try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+        try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
             "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "include"));
         try args.append("-I");
-        try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+        try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
             "unix" ++ s ++ "sysv" ++ s ++ "linux"));
     }
     if (opt_nptl) |nptl| {
         try args.append("-I");
-        try args.append(try path.join(arena, &[_][]const u8{ mod.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
+        try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
     }
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread"));
+    try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread"));
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv"));
+    try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv"));
 
-    try add_include_dirs_arch(arena, args, arch, null, try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
+    try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
+    try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
 
-    try add_include_dirs_arch(arena, args, arch, null, try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps"));
+    try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
+    try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
 
     try args.append("-I");
-    try args.append(try path.join(arena, &[_][]const u8{ mod.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
+    try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
 
     try args.append("-I");
     try args.append(try std.fmt.allocPrint(arena, "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-{}", .{
-        mod.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi),
+        comp.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi),
     }));
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
+    try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
 
     try args.append("-I");
     try args.append(try std.fmt.allocPrint(arena, "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-linux-any", .{
-        mod.zig_lib_directory.path.?, @tagName(arch),
+        comp.zig_lib_directory.path.?, @tagName(arch),
     }));
 
     try args.append("-I");
-    try args.append(try lib_path(mod, arena, lib_libc ++ "include" ++ s ++ "any-linux-any"));
+    try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "any-linux-any"));
 }
 
 fn add_include_dirs_arch(
@@ -576,60 +576,60 @@ fn add_include_dirs_arch(
     }
 }
 
-fn path_from_lib(mod: *Module, arena: *Allocator, sub_path: []const u8) ![]const u8 {
-    return path.join(arena, &[_][]const u8{ mod.zig_lib_directory.path.?, sub_path });
+fn path_from_lib(comp: *Compilation, arena: *Allocator, sub_path: []const u8) ![]const u8 {
+    return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
 }
 
 const lib_libc = "libc" ++ path.sep_str;
 const lib_libc_glibc = lib_libc ++ "glibc" ++ path.sep_str;
 
-fn lib_path(mod: *Module, arena: *Allocator, sub_path: []const u8) ![]const u8 {
-    return path.join(arena, &[_][]const u8{ mod.zig_lib_directory.path.?, sub_path });
+fn lib_path(comp: *Compilation, arena: *Allocator, sub_path: []const u8) ![]const u8 {
+    return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
 }
 
-fn build_libc_object(mod: *Module, basename: []const u8, c_source_file: Module.CSourceFile) !void {
+fn build_libc_object(comp: *Compilation, basename: []const u8, c_source_file: Compilation.CSourceFile) !void {
     const tracy = trace(@src());
     defer tracy.end();
 
     // TODO: This is extracted into a local variable to work around a stage1 miscompilation.
-    const emit_bin = Module.EmitLoc{
+    const emit_bin = Compilation.EmitLoc{
         .directory = null, // Put it in the cache directory.
         .basename = basename,
     };
-    const sub_module = try Module.create(mod.gpa, .{
+    const sub_compilation = try Compilation.create(comp.gpa, .{
         // TODO use the global cache directory here
-        .zig_cache_directory = mod.zig_cache_directory,
-        .zig_lib_directory = mod.zig_lib_directory,
-        .target = mod.getTarget(),
+        .zig_cache_directory = comp.zig_cache_directory,
+        .zig_lib_directory = comp.zig_lib_directory,
+        .target = comp.getTarget(),
         .root_name = mem.split(basename, ".").next().?,
         .root_pkg = null,
         .output_mode = .Obj,
-        .rand = mod.rand,
-        .libc_installation = mod.bin_file.options.libc_installation,
+        .rand = comp.rand,
+        .libc_installation = comp.bin_file.options.libc_installation,
         .emit_bin = emit_bin,
-        .optimize_mode = mod.bin_file.options.optimize_mode,
+        .optimize_mode = comp.bin_file.options.optimize_mode,
         .want_sanitize_c = false,
         .want_stack_check = false,
         .want_valgrind = false,
-        .want_pic = mod.bin_file.options.pic,
+        .want_pic = comp.bin_file.options.pic,
         .emit_h = null,
-        .strip = mod.bin_file.options.strip,
-        .is_native_os = mod.bin_file.options.is_native_os,
-        .self_exe_path = mod.self_exe_path,
-        .c_source_files = &[1]Module.CSourceFile{c_source_file},
-        .debug_cc = mod.debug_cc,
-        .debug_link = mod.bin_file.options.debug_link,
+        .strip = comp.bin_file.options.strip,
+        .is_native_os = comp.bin_file.options.is_native_os,
+        .self_exe_path = comp.self_exe_path,
+        .c_source_files = &[1]Compilation.CSourceFile{c_source_file},
+        .debug_cc = comp.debug_cc,
+        .debug_link = comp.bin_file.options.debug_link,
     });
-    defer sub_module.destroy();
+    defer sub_compilation.destroy();
 
-    try sub_module.update();
+    try sub_compilation.update();
 
-    try mod.crt_files.ensureCapacity(mod.gpa, mod.crt_files.count() + 1);
-    const artifact_path = if (sub_module.bin_file.options.directory.path) |p|
-        try std.fs.path.join(mod.gpa, &[_][]const u8{ p, basename })
+    try comp.crt_files.ensureCapacity(comp.gpa, comp.crt_files.count() + 1);
+    const artifact_path = if (sub_compilation.bin_file.options.directory.path) |p|
+        try std.fs.path.join(comp.gpa, &[_][]const u8{ p, basename })
     else
-        try mod.gpa.dupe(u8, basename);
+        try comp.gpa.dupe(u8, basename);
 
     // TODO obtain a lock on the artifact and put that in crt_files as well.
-    mod.crt_files.putAssumeCapacityNoClobber(basename, artifact_path);
+    comp.crt_files.putAssumeCapacityNoClobber(basename, artifact_path);
 }
src-self-hosted/introspect.zig
@@ -2,12 +2,12 @@ const std = @import("std");
 const mem = std.mem;
 const fs = std.fs;
 const CacheHash = std.cache_hash.CacheHash;
-const Module = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 
 /// Returns the sub_path that worked, or `null` if none did.
 /// The path of the returned Directory is relative to `base`.
 /// The handle of the returned Directory is open.
-fn testZigInstallPrefix(base_dir: fs.Dir) ?Module.Directory {
+fn testZigInstallPrefix(base_dir: fs.Dir) ?Compilation.Directory {
     const test_index_file = "std" ++ fs.path.sep_str ++ "std.zig";
 
     zig_dir: {
@@ -19,7 +19,7 @@ fn testZigInstallPrefix(base_dir: fs.Dir) ?Module.Directory {
             break :zig_dir;
         };
         file.close();
-        return Module.Directory{ .handle = test_zig_dir, .path = lib_zig };
+        return Compilation.Directory{ .handle = test_zig_dir, .path = lib_zig };
     }
 
     // Try lib/std/std.zig
@@ -29,11 +29,11 @@ fn testZigInstallPrefix(base_dir: fs.Dir) ?Module.Directory {
         return null;
     };
     file.close();
-    return Module.Directory{ .handle = test_zig_dir, .path = "lib" };
+    return Compilation.Directory{ .handle = test_zig_dir, .path = "lib" };
 }
 
 /// Both the directory handle and the path are newly allocated resources which the caller now owns.
-pub fn findZigLibDir(gpa: *mem.Allocator) !Module.Directory {
+pub fn findZigLibDir(gpa: *mem.Allocator) !Compilation.Directory {
     const self_exe_path = try fs.selfExePathAlloc(gpa);
     defer gpa.free(self_exe_path);
 
@@ -44,7 +44,7 @@ pub fn findZigLibDir(gpa: *mem.Allocator) !Module.Directory {
 pub fn findZigLibDirFromSelfExe(
     allocator: *mem.Allocator,
     self_exe_path: []const u8,
-) error{ OutOfMemory, FileNotFound }!Module.Directory {
+) error{ OutOfMemory, FileNotFound }!Compilation.Directory {
     const cwd = fs.cwd();
     var cur_path: []const u8 = self_exe_path;
     while (fs.path.dirname(cur_path)) |dirname| : (cur_path = dirname) {
@@ -52,7 +52,7 @@ pub fn findZigLibDirFromSelfExe(
         defer base_dir.close();
 
         const sub_directory = testZigInstallPrefix(base_dir) orelse continue;
-        return Module.Directory{
+        return Compilation.Directory{
             .handle = sub_directory.handle,
             .path = try fs.path.join(allocator, &[_][]const u8{ dirname, sub_directory.path.? }),
         };
src-self-hosted/link.zig
@@ -1,6 +1,6 @@
 const std = @import("std");
 const Allocator = std.mem.Allocator;
-const Compilation = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 const ZigModule = @import("ZigModule.zig");
 const fs = std.fs;
 const trace = @import("tracy.zig").trace;
@@ -23,7 +23,6 @@ pub const Options = struct {
     optimize_mode: std.builtin.Mode,
     root_name: []const u8,
     /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.
-    /// TODO rename Module to Compilation and then (as a separate commit) ZigModule to Module.
     zig_module: ?*ZigModule,
     dynamic_linker: ?[]const u8 = null,
     /// Used for calculating how much space to reserve for symbols in case the binary file
src-self-hosted/main.zig
@@ -7,7 +7,7 @@ const process = std.process;
 const Allocator = mem.Allocator;
 const ArrayList = std.ArrayList;
 const ast = std.zig.ast;
-const Module = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 const link = @import("link.zig");
 const Package = @import("Package.zig");
 const zir = @import("zir.zig");
@@ -331,7 +331,7 @@ pub fn buildOutputType(
     var rpath_list = std.ArrayList([]const u8).init(gpa);
     defer rpath_list.deinit();
 
-    var c_source_files = std.ArrayList(Module.CSourceFile).init(gpa);
+    var c_source_files = std.ArrayList(Compilation.CSourceFile).init(gpa);
     defer c_source_files.deinit();
 
     var link_objects = std.ArrayList([]const u8).init(gpa);
@@ -566,7 +566,7 @@ pub fn buildOutputType(
                 mem.endsWith(u8, arg, ".lib"))
             {
                 try link_objects.append(arg);
-            } else if (Module.hasAsmExt(arg) or Module.hasCExt(arg) or Module.hasCppExt(arg)) {
+            } else if (Compilation.hasAsmExt(arg) or Compilation.hasCExt(arg) or Compilation.hasCppExt(arg)) {
                 // TODO a way to pass extra flags on the CLI
                 try c_source_files.append(.{ .src_path = arg });
             } else if (mem.endsWith(u8, arg, ".so") or
@@ -611,7 +611,7 @@ pub fn buildOutputType(
                     try clang_argv.appendSlice(it.other_args);
                 },
                 .positional => {
-                    const file_ext = Module.classifyFileExt(mem.spanZ(it.only_arg));
+                    const file_ext = Compilation.classifyFileExt(mem.spanZ(it.only_arg));
                     switch (file_ext) {
                         .assembly, .c, .cpp, .ll, .bc, .h => try c_source_files.append(.{ .src_path = it.only_arg }),
                         .unknown, .so => try link_objects.append(it.only_arg),
@@ -998,9 +998,9 @@ pub fn buildOutputType(
     var cleanup_emit_bin_dir: ?fs.Dir = null;
     defer if (cleanup_emit_bin_dir) |*dir| dir.close();
 
-    const emit_bin_loc: ?Module.EmitLoc = switch (emit_bin) {
+    const emit_bin_loc: ?Compilation.EmitLoc = switch (emit_bin) {
         .no => null,
-        .yes_default_path => Module.EmitLoc{
+        .yes_default_path => Compilation.EmitLoc{
             .directory = .{ .path = null, .handle = fs.cwd() },
             .basename = try std.zig.binNameAlloc(
                 arena,
@@ -1016,7 +1016,7 @@ pub fn buildOutputType(
             if (fs.path.dirname(full_path)) |dirname| {
                 const handle = try fs.cwd().openDir(dirname, .{});
                 cleanup_emit_bin_dir = handle;
-                break :b Module.EmitLoc{
+                break :b Compilation.EmitLoc{
                     .basename = basename,
                     .directory = .{
                         .path = dirname,
@@ -1024,7 +1024,7 @@ pub fn buildOutputType(
                     },
                 };
             } else {
-                break :b Module.EmitLoc{
+                break :b Compilation.EmitLoc{
                     .basename = basename,
                     .directory = .{ .path = null, .handle = fs.cwd() },
                 };
@@ -1035,9 +1035,9 @@ pub fn buildOutputType(
     var cleanup_emit_h_dir: ?fs.Dir = null;
     defer if (cleanup_emit_h_dir) |*dir| dir.close();
 
-    const emit_h_loc: ?Module.EmitLoc = switch (emit_h) {
+    const emit_h_loc: ?Compilation.EmitLoc = switch (emit_h) {
         .no => null,
-        .yes_default_path => Module.EmitLoc{
+        .yes_default_path => Compilation.EmitLoc{
             .directory = .{ .path = null, .handle = fs.cwd() },
             .basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name}),
         },
@@ -1046,7 +1046,7 @@ pub fn buildOutputType(
             if (fs.path.dirname(full_path)) |dirname| {
                 const handle = try fs.cwd().openDir(dirname, .{});
                 cleanup_emit_h_dir = handle;
-                break :b Module.EmitLoc{
+                break :b Compilation.EmitLoc{
                     .basename = basename,
                     .directory = .{
                         .path = dirname,
@@ -1054,7 +1054,7 @@ pub fn buildOutputType(
                     },
                 };
             } else {
-                break :b Module.EmitLoc{
+                break :b Compilation.EmitLoc{
                     .basename = basename,
                     .directory = .{ .path = null, .handle = fs.cwd() },
                 };
@@ -1103,7 +1103,7 @@ pub fn buildOutputType(
     const cache_parent_dir = if (root_pkg) |pkg| pkg.root_src_directory.handle else fs.cwd();
     var cache_dir = try cache_parent_dir.makeOpenPath("zig-cache", .{});
     defer cache_dir.close();
-    const zig_cache_directory: Module.Directory = .{
+    const zig_cache_directory: Compilation.Directory = .{
         .handle = cache_dir,
         .path = blk: {
             if (root_pkg) |pkg| {
@@ -1115,7 +1115,7 @@ pub fn buildOutputType(
         },
     };
 
-    const module = Module.create(gpa, .{
+    const comp = Compilation.create(gpa, .{
         .zig_lib_directory = zig_lib_directory,
         .zig_cache_directory = zig_cache_directory,
         .root_name = root_name,
@@ -1170,15 +1170,15 @@ pub fn buildOutputType(
         .debug_cc = debug_cc,
         .debug_link = debug_link,
     }) catch |err| {
-        fatal("unable to create module: {}", .{@errorName(err)});
+        fatal("unable to create compilation: {}", .{@errorName(err)});
     };
-    defer module.destroy();
+    defer comp.destroy();
 
     const stdin = std.io.getStdIn().inStream();
     const stderr = std.io.getStdErr().outStream();
     var repl_buf: [1024]u8 = undefined;
 
-    try updateModule(gpa, module, zir_out_path);
+    try updateModule(gpa, comp, zir_out_path);
 
     if (build_options.have_llvm and only_pp_or_asm) {
         // this may include dumping the output to stdout
@@ -1188,7 +1188,7 @@ pub fn buildOutputType(
     while (watch) {
         try stderr.print("🦎 ", .{});
         if (output_mode == .Exe) {
-            try module.makeBinFileExecutable();
+            try comp.makeBinFileExecutable();
         }
         if (stdin.readUntilDelimiterOrEof(&repl_buf, '\n') catch |err| {
             try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)});
@@ -1198,9 +1198,9 @@ pub fn buildOutputType(
 
             if (mem.eql(u8, actual_line, "update")) {
                 if (output_mode == .Exe) {
-                    try module.makeBinFileWritable();
+                    try comp.makeBinFileWritable();
                 }
-                try updateModule(gpa, module, zir_out_path);
+                try updateModule(gpa, comp, zir_out_path);
             } else if (mem.eql(u8, actual_line, "exit")) {
                 break;
             } else if (mem.eql(u8, actual_line, "help")) {
@@ -1214,11 +1214,11 @@ pub fn buildOutputType(
     }
 }
 
-fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !void {
-    try module.update();
+fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8) !void {
+    try comp.update();
 
-    var errors = try module.getAllErrorsAlloc();
-    defer errors.deinit(module.gpa);
+    var errors = try comp.getAllErrorsAlloc();
+    defer errors.deinit(comp.gpa);
 
     if (errors.list.len != 0) {
         for (errors.list) |full_err_msg| {
@@ -1232,7 +1232,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo
     }
 
     if (zir_out_path) |zop| {
-        const zig_module = module.bin_file.options.zig_module orelse
+        const zig_module = comp.bin_file.options.zig_module orelse
             fatal("-femit-zir with no zig source code", .{});
         var new_zir_module = try zir.emit(gpa, zig_module);
         defer new_zir_module.deinit(gpa);
src-self-hosted/Package.zig
@@ -1,6 +1,6 @@
 pub const Table = std.StringHashMapUnmanaged(*Package);
 
-root_src_directory: Module.Directory,
+root_src_directory: Compilation.Directory,
 /// Relative to `root_src_directory`.
 root_src_path: []u8,
 table: Table,
@@ -56,4 +56,4 @@ const mem = std.mem;
 const Allocator = std.mem.Allocator;
 const assert = std.debug.assert;
 const Package = @This();
-const Module = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
src-self-hosted/test.zig
@@ -1,6 +1,6 @@
 const std = @import("std");
 const link = @import("link.zig");
-const Module = @import("Module.zig");
+const Compilation = @import("Compilation.zig");
 const Allocator = std.mem.Allocator;
 const zir = @import("zir.zig");
 const Package = @import("Package.zig");
@@ -61,7 +61,7 @@ pub const TestContext = struct {
         ZIR,
     };
 
-    /// A Case consists of a set of *updates*. The same Module is used for each
+    /// A Case consists of a set of *updates*. The same Compilation is used for each
     /// update, so each update's source is treated as a single file being
     /// updated by the test harness and incrementally compiled.
     pub const Case = struct {
@@ -437,7 +437,7 @@ pub const TestContext = struct {
         allocator: *Allocator,
         root_node: *std.Progress.Node,
         case: Case,
-        zig_lib_directory: Module.Directory,
+        zig_lib_directory: Compilation.Directory,
         rand: *std.rand.Random,
     ) !void {
         const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target);
@@ -453,7 +453,7 @@ pub const TestContext = struct {
         var cache_dir = try tmp.dir.makeOpenPath("zig-cache", .{});
         defer cache_dir.close();
         const bogus_path = "bogus"; // TODO this will need to be fixed before we can test LLVM extensions
-        const zig_cache_directory: Module.Directory = .{
+        const zig_cache_directory: Compilation.Directory = .{
             .handle = cache_dir,
             .path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
         };
@@ -465,15 +465,15 @@ pub const TestContext = struct {
         const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
         const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
 
-        const emit_directory: Module.Directory = .{
+        const emit_directory: Compilation.Directory = .{
             .path = bogus_path,
             .handle = tmp.dir,
         };
-        const emit_bin: Module.EmitLoc = .{
+        const emit_bin: Compilation.EmitLoc = .{
             .directory = emit_directory,
             .basename = bin_name,
         };
-        const module = try Module.create(allocator, .{
+        const comp = try Compilation.create(allocator, .{
             .zig_cache_directory = zig_cache_directory,
             .zig_lib_directory = zig_lib_directory,
             .rand = rand,
@@ -491,7 +491,7 @@ pub const TestContext = struct {
             .object_format = ofmt,
             .is_native_os = case.target.isNativeOs(),
         });
-        defer module.destroy();
+        defer comp.destroy();
 
         for (case.updates.items) |update, update_index| {
             var update_node = root_node.start("update", 3);
@@ -505,20 +505,20 @@ pub const TestContext = struct {
 
             var module_node = update_node.start("parse/analysis/codegen", null);
             module_node.activate();
-            try module.makeBinFileWritable();
-            try module.update();
+            try comp.makeBinFileWritable();
+            try comp.update();
             module_node.end();
 
             if (update.case != .Error) {
-                var all_errors = try module.getAllErrorsAlloc();
+                var all_errors = try comp.getAllErrorsAlloc();
                 defer all_errors.deinit(allocator);
                 if (all_errors.list.len != 0) {
-                    std.debug.print("\nErrors occurred updating the module:\n================\n", .{});
+                    std.debug.print("\nErrors occurred updating the compilation:\n================\n", .{});
                     for (all_errors.list) |err| {
                         std.debug.print(":{}:{}: error: {}\n================\n", .{ err.line + 1, err.column + 1, err.msg });
                     }
                     if (case.cbe) {
-                        const C = module.bin_file.cast(link.File.C).?;
+                        const C = comp.bin_file.cast(link.File.C).?;
                         std.debug.print("Generated C: \n===============\n{}\n\n===========\n\n", .{C.main.items});
                     }
                     std.debug.print("Test failed.\n", .{});
@@ -549,7 +549,7 @@ pub const TestContext = struct {
                         update_node.estimated_total_items = 5;
                         var emit_node = update_node.start("emit", null);
                         emit_node.activate();
-                        var new_zir_module = try zir.emit(allocator, module.bin_file.options.zig_module.?);
+                        var new_zir_module = try zir.emit(allocator, comp.bin_file.options.zig_module.?);
                         defer new_zir_module.deinit(allocator);
                         emit_node.end();
 
@@ -584,7 +584,7 @@ pub const TestContext = struct {
                     for (handled_errors) |*h| {
                         h.* = false;
                     }
-                    var all_errors = try module.getAllErrorsAlloc();
+                    var all_errors = try comp.getAllErrorsAlloc();
                     defer all_errors.deinit(allocator);
                     for (all_errors.list) |a| {
                         for (e) |ex, i| {
@@ -666,7 +666,7 @@ pub const TestContext = struct {
                             },
                         }
 
-                        try module.makeBinFileExecutable();
+                        try comp.makeBinFileExecutable();
 
                         break :x try std.ChildProcess.exec(.{
                             .allocator = allocator,
src-self-hosted/ZigModule.zig
@@ -1,9 +1,7 @@
-//! TODO This is going to get renamed from ZigModule to Module (but first we have to rename
-//! Module to Compilation).
+//! TODO This is going to get renamed from ZigModule to Module
 const Module = @This();
-const Compilation = @import("Module.zig");
-
 const std = @import("std");
+const Compilation = @import("Compilation.zig");
 const mem = std.mem;
 const Allocator = std.mem.Allocator;
 const ArrayListUnmanaged = std.ArrayListUnmanaged;