From 2456df5f4ebf9fef147d86736974e95403e2d40d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 13 Sep 2020 19:56:35 -0700 Subject: [PATCH] stage2: rename ZigModule to Module --- src-self-hosted/Compilation.zig | 116 +++++++++--------- src-self-hosted/{ZigModule.zig => Module.zig} | 1 - src-self-hosted/astgen.zig | 2 +- src-self-hosted/codegen.zig | 2 +- src-self-hosted/codegen/c.zig | 2 +- src-self-hosted/codegen/wasm.zig | 2 +- src-self-hosted/ir.zig | 2 +- src-self-hosted/link.zig | 20 +-- src-self-hosted/link/C.zig | 2 +- src-self-hosted/link/Coff.zig | 2 +- src-self-hosted/link/Elf.zig | 20 +-- src-self-hosted/link/MachO.zig | 2 +- src-self-hosted/link/Wasm.zig | 4 +- src-self-hosted/main.zig | 4 +- src-self-hosted/test.zig | 2 +- src-self-hosted/type.zig | 2 +- src-self-hosted/value.zig | 2 +- src-self-hosted/zir.zig | 2 +- src-self-hosted/zir_sema.zig | 2 +- 19 files changed, 95 insertions(+), 96 deletions(-) rename src-self-hosted/{ZigModule.zig => Module.zig} (99%) diff --git a/src-self-hosted/Compilation.zig b/src-self-hosted/Compilation.zig index ab105deb07..9a46b88619 100644 --- a/src-self-hosted/Compilation.zig +++ b/src-self-hosted/Compilation.zig @@ -16,7 +16,7 @@ const build_options = @import("build_options"); const LibCInstallation = @import("libc_installation.zig").LibCInstallation; const glibc = @import("glibc.zig"); const fatal = @import("main.zig").fatal; -const ZigModule = @import("ZigModule.zig"); +const Module = @import("Module.zig"); /// General-purpose allocator. Used for both temporary and long-term storage. gpa: *Allocator, @@ -75,7 +75,7 @@ crt_files: std.StringHashMapUnmanaged([]const u8) = .{}, /// Keeping track of this possibly open resource so we can close it later. owned_link_dir: ?std.fs.Dir, -pub const InnerError = ZigModule.InnerError; +pub const InnerError = Module.InnerError; /// For passing to a C compiler. pub const CSourceFile = struct { @@ -85,14 +85,14 @@ pub const CSourceFile = struct { const WorkItem = union(enum) { /// Write the machine code for a Decl to the output file. - codegen_decl: *ZigModule.Decl, + codegen_decl: *Module.Decl, /// The Decl needs to be analyzed and possibly export itself. /// It may have already be analyzed, or it may have been determined /// to be outdated; in this case perform semantic analysis again. - analyze_decl: *ZigModule.Decl, + analyze_decl: *Module.Decl, /// The source file containing the Decl has been updated, and so the /// Decl may need its line number information updated in the debug info. - update_line_number: *ZigModule.Decl, + update_line_number: *Module.Decl, /// Invoke the Clang compiler to create an object file, which gets linked /// with the Compilation. c_object: *CObject, @@ -402,7 +402,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { cache.hash.add(options.output_mode); // TODO audit this and make sure everything is in it - const zig_module: ?*ZigModule = if (options.root_pkg) |root_pkg| blk: { + const module: ?*Module = if (options.root_pkg) |root_pkg| blk: { // Options that are specific to zig source files, that cannot be // modified between incremental updates. var hash = cache.hash; @@ -442,11 +442,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { // this is where we would load it. We have open a handle to the directory where // the output either already is, or will be. // However we currently do not have serialization of such metadata, so for now - // we set up an empty ZigModule that does the entire compilation fresh. + // we set up an empty Module that does the entire compilation fresh. const root_scope = rs: { if (mem.endsWith(u8, root_pkg.root_src_path, ".zig")) { - const root_scope = try gpa.create(ZigModule.Scope.File); + const root_scope = try gpa.create(Module.Scope.File); root_scope.* = .{ .sub_file_path = root_pkg.root_src_path, .source = .{ .unloaded = {} }, @@ -459,7 +459,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { }; break :rs &root_scope.base; } else if (mem.endsWith(u8, root_pkg.root_src_path, ".zir")) { - const root_scope = try gpa.create(ZigModule.Scope.ZIRModule); + const root_scope = try gpa.create(Module.Scope.ZIRModule); root_scope.* = .{ .sub_file_path = root_pkg.root_src_path, .source = .{ .unloaded = {} }, @@ -473,24 +473,24 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { } }; - const zig_module = try arena.create(ZigModule); - zig_module.* = .{ + const module = try arena.create(Module); + module.* = .{ .gpa = gpa, .comp = comp, .root_pkg = root_pkg, .root_scope = root_scope, .zig_cache_artifact_directory = zig_cache_artifact_directory, }; - break :blk zig_module; + break :blk module; } else null; - errdefer if (zig_module) |zm| zm.deinit(); + errdefer if (module) |zm| zm.deinit(); // For resource management purposes. var owned_link_dir: ?std.fs.Dir = null; errdefer if (owned_link_dir) |*dir| dir.close(); const bin_directory = emit_bin.directory orelse blk: { - if (zig_module) |zm| break :blk zm.zig_cache_artifact_directory; + if (module) |zm| break :blk zm.zig_cache_artifact_directory; const digest = cache.hash.peek(); const artifact_sub_dir = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest }); @@ -510,7 +510,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .directory = bin_directory, .sub_path = emit_bin.basename, .root_name = root_name, - .zig_module = zig_module, + .module = module, .target = options.target, .dynamic_linker = options.dynamic_linker, .output_mode = options.output_mode, @@ -605,9 +605,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { } pub fn destroy(self: *Compilation) void { - const optional_zig_module = self.bin_file.options.zig_module; + const optional_module = self.bin_file.options.module; self.bin_file.destroy(); - if (optional_zig_module) |zig_module| zig_module.deinit(); + if (optional_module) |module| module.deinit(); const gpa = self.gpa; self.work_queue.deinit(); @@ -655,23 +655,23 @@ pub fn update(self: *Compilation) !void { self.work_queue.writeItemAssumeCapacity(.{ .c_object = entry.key }); } - if (self.bin_file.options.zig_module) |zig_module| { - zig_module.generation += 1; + if (self.bin_file.options.module) |module| { + module.generation += 1; // TODO Detect which source files changed. // Until then we simulate a full cache miss. Source files could have been loaded for any reason; // to force a refresh we unload now. - if (zig_module.root_scope.cast(ZigModule.Scope.File)) |zig_file| { - zig_file.unload(zig_module.gpa); - zig_module.analyzeContainer(&zig_file.root_container) catch |err| switch (err) { + if (module.root_scope.cast(Module.Scope.File)) |zig_file| { + zig_file.unload(module.gpa); + module.analyzeContainer(&zig_file.root_container) catch |err| switch (err) { error.AnalysisFail => { assert(self.totalErrorCount() != 0); }, else => |e| return e, }; - } else if (zig_module.root_scope.cast(ZigModule.Scope.ZIRModule)) |zir_module| { - zir_module.unload(zig_module.gpa); - zig_module.analyzeRootZIRModule(zir_module) catch |err| switch (err) { + } else if (module.root_scope.cast(Module.Scope.ZIRModule)) |zir_module| { + zir_module.unload(module.gpa); + module.analyzeRootZIRModule(zir_module) catch |err| switch (err) { error.AnalysisFail => { assert(self.totalErrorCount() != 0); }, @@ -682,14 +682,14 @@ pub fn update(self: *Compilation) !void { try self.performAllTheWork(); - if (self.bin_file.options.zig_module) |zig_module| { + if (self.bin_file.options.module) |module| { // Process the deletion set. - while (zig_module.deletion_set.popOrNull()) |decl| { + while (module.deletion_set.popOrNull()) |decl| { if (decl.dependants.items().len != 0) { decl.deletion_flag = false; continue; } - try zig_module.deleteDecl(decl); + try module.deleteDecl(decl); } } @@ -701,8 +701,8 @@ pub fn update(self: *Compilation) !void { // If there are any errors, we anticipate the source files being loaded // to report error messages. Otherwise we unload all source files to save memory. if (self.totalErrorCount() == 0 and !self.keep_source_files_loaded) { - if (self.bin_file.options.zig_module) |zig_module| { - zig_module.root_scope.unload(self.gpa); + if (self.bin_file.options.module) |module| { + module.root_scope.unload(self.gpa); } } } @@ -722,10 +722,10 @@ pub fn makeBinFileWritable(self: *Compilation) !void { pub fn totalErrorCount(self: *Compilation) usize { var total: usize = self.failed_c_objects.items().len; - if (self.bin_file.options.zig_module) |zig_module| { - total += zig_module.failed_decls.items().len + - zig_module.failed_exports.items().len + - zig_module.failed_files.items().len; + if (self.bin_file.options.module) |module| { + total += module.failed_decls.items().len + + module.failed_exports.items().len + + module.failed_files.items().len; } // The "no entry point found" error only counts if there are no other errors. @@ -748,30 +748,30 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors { const err_msg = entry.value; try AllErrors.add(&arena, &errors, c_object.src_path, "", err_msg.*); } - if (self.bin_file.options.zig_module) |zig_module| { - for (zig_module.failed_files.items()) |entry| { + if (self.bin_file.options.module) |module| { + for (module.failed_files.items()) |entry| { const scope = entry.key; const err_msg = entry.value; - const source = try scope.getSource(zig_module); + const source = try scope.getSource(module); try AllErrors.add(&arena, &errors, scope.subFilePath(), source, err_msg.*); } - for (zig_module.failed_decls.items()) |entry| { + for (module.failed_decls.items()) |entry| { const decl = entry.key; const err_msg = entry.value; - const source = try decl.scope.getSource(zig_module); + const source = try decl.scope.getSource(module); try AllErrors.add(&arena, &errors, decl.scope.subFilePath(), source, err_msg.*); } - for (zig_module.failed_exports.items()) |entry| { + for (module.failed_exports.items()) |entry| { const decl = entry.key.owner_decl; const err_msg = entry.value; - const source = try decl.scope.getSource(zig_module); + const source = try decl.scope.getSource(module); try AllErrors.add(&arena, &errors, decl.scope.subFilePath(), source, err_msg.*); } } if (errors.items.len == 0 and self.link_error_flags.no_entry_point_found) { const global_err_src_path = blk: { - if (self.bin_file.options.zig_module) |zig_module| break :blk zig_module.root_pkg.root_src_path; + if (self.bin_file.options.module) |module| break :blk module.root_pkg.root_src_path; if (self.c_source_files.len != 0) break :blk self.c_source_files[0].src_path; if (self.bin_file.options.objects.len != 0) break :blk self.bin_file.options.objects[0]; break :blk "(no file)"; @@ -807,10 +807,10 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void { => continue, .complete, .codegen_failure_retryable => { - const zig_module = self.bin_file.options.zig_module.?; + const module = self.bin_file.options.module.?; if (decl.typed_value.most_recent.typed_value.val.cast(Value.Payload.Function)) |payload| { switch (payload.func.analysis) { - .queued => zig_module.analyzeFnBody(decl, payload.func) catch |err| switch (err) { + .queued => module.analyzeFnBody(decl, payload.func) catch |err| switch (err) { error.AnalysisFail => { assert(payload.func.analysis != .in_progress); continue; @@ -823,23 +823,23 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void { } // Here we tack on additional allocations to the Decl's arena. The allocations are // lifetime annotations in the ZIR. - var decl_arena = decl.typed_value.most_recent.arena.?.promote(zig_module.gpa); + var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa); defer decl.typed_value.most_recent.arena.?.* = decl_arena.state; log.debug("analyze liveness of {}\n", .{decl.name}); - try liveness.analyze(zig_module.gpa, &decl_arena.allocator, payload.func.analysis.success); + try liveness.analyze(module.gpa, &decl_arena.allocator, payload.func.analysis.success); } assert(decl.typed_value.most_recent.typed_value.ty.hasCodeGenBits()); - self.bin_file.updateDecl(zig_module, decl) catch |err| switch (err) { + self.bin_file.updateDecl(module, decl) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.AnalysisFail => { decl.analysis = .dependency_failure; }, else => { - try zig_module.failed_decls.ensureCapacity(zig_module.gpa, zig_module.failed_decls.items().len + 1); - zig_module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( - zig_module.gpa, + try module.failed_decls.ensureCapacity(module.gpa, module.failed_decls.items().len + 1); + module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( + module.gpa, decl.src(), "unable to codegen: {}", .{@errorName(err)}, @@ -850,18 +850,18 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void { }, }, .analyze_decl => |decl| { - const zig_module = self.bin_file.options.zig_module.?; - zig_module.ensureDeclAnalyzed(decl) catch |err| switch (err) { + const module = self.bin_file.options.module.?; + module.ensureDeclAnalyzed(decl) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.AnalysisFail => continue, }; }, .update_line_number => |decl| { - const zig_module = self.bin_file.options.zig_module.?; - self.bin_file.updateDeclLineNumber(zig_module, decl) catch |err| { - try zig_module.failed_decls.ensureCapacity(zig_module.gpa, zig_module.failed_decls.items().len + 1); - zig_module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( - zig_module.gpa, + const module = self.bin_file.options.module.?; + self.bin_file.updateDeclLineNumber(module, decl) catch |err| { + try module.failed_decls.ensureCapacity(module.gpa, module.failed_decls.items().len + 1); + module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( + module.gpa, decl.src(), "unable to update line number: {}", .{@errorName(err)}, @@ -949,7 +949,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { // Special case when doing build-obj for just one C file. When there are more than one object // file and building an object we need to link them together, but with just one it should go // directly to the output file. - const direct_o = comp.c_source_files.len == 1 and comp.bin_file.options.zig_module == null and + const direct_o = comp.c_source_files.len == 1 and comp.bin_file.options.module == null and comp.bin_file.options.output_mode == .Obj and comp.bin_file.options.objects.len == 0; const o_basename_noext = if (direct_o) comp.bin_file.options.root_name diff --git a/src-self-hosted/ZigModule.zig b/src-self-hosted/Module.zig similarity index 99% rename from src-self-hosted/ZigModule.zig rename to src-self-hosted/Module.zig index 53d35fb41b..ebe7cdfb1e 100644 --- a/src-self-hosted/ZigModule.zig +++ b/src-self-hosted/Module.zig @@ -1,4 +1,3 @@ -//! TODO This is going to get renamed from ZigModule to Module const Module = @This(); const std = @import("std"); const Compilation = @import("Compilation.zig"); diff --git a/src-self-hosted/astgen.zig b/src-self-hosted/astgen.zig index f39612b7ef..2c091a86ec 100644 --- a/src-self-hosted/astgen.zig +++ b/src-self-hosted/astgen.zig @@ -6,7 +6,7 @@ const Type = @import("type.zig").Type; const TypedValue = @import("TypedValue.zig"); const assert = std.debug.assert; const zir = @import("zir.zig"); -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); const ast = std.zig.ast; const trace = @import("tracy.zig").trace; const Scope = Module.Scope; diff --git a/src-self-hosted/codegen.zig b/src-self-hosted/codegen.zig index 212843a38c..a1d3cc2fc4 100644 --- a/src-self-hosted/codegen.zig +++ b/src-self-hosted/codegen.zig @@ -7,7 +7,7 @@ const Type = @import("type.zig").Type; const Value = @import("value.zig").Value; const TypedValue = @import("TypedValue.zig"); const link = @import("link.zig"); -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); const Compilation = @import("Compilation.zig"); const ErrorMsg = Compilation.ErrorMsg; const Target = std.Target; diff --git a/src-self-hosted/codegen/c.zig b/src-self-hosted/codegen/c.zig index 4ad2a6dafc..34ddcfbb3b 100644 --- a/src-self-hosted/codegen/c.zig +++ b/src-self-hosted/codegen/c.zig @@ -1,7 +1,7 @@ const std = @import("std"); const link = @import("../link.zig"); -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Inst = @import("../ir.zig").Inst; const Value = @import("../value.zig").Value; diff --git a/src-self-hosted/codegen/wasm.zig b/src-self-hosted/codegen/wasm.zig index 5f44aa8c65..4ea8838409 100644 --- a/src-self-hosted/codegen/wasm.zig +++ b/src-self-hosted/codegen/wasm.zig @@ -5,7 +5,7 @@ const assert = std.debug.assert; const leb = std.debug.leb; const mem = std.mem; -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Decl = Module.Decl; const Inst = @import("../ir.zig").Inst; const Type = @import("../type.zig").Type; diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig index 2b07110a90..26afa52929 100644 --- a/src-self-hosted/ir.zig +++ b/src-self-hosted/ir.zig @@ -1,7 +1,7 @@ const std = @import("std"); const Value = @import("value.zig").Value; const Type = @import("type.zig").Type; -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); const assert = std.debug.assert; const codegen = @import("codegen.zig"); const ast = std.zig.ast; diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index b2d9a0416f..4078b263e9 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -1,7 +1,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const Compilation = @import("Compilation.zig"); -const ZigModule = @import("ZigModule.zig"); +const Module = @import("Module.zig"); const fs = std.fs; const trace = @import("tracy.zig").trace; const Package = @import("Package.zig"); @@ -23,7 +23,7 @@ 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`. - zig_module: ?*ZigModule, + module: ?*Module, dynamic_linker: ?[]const u8 = null, /// Used for calculating how much space to reserve for symbols in case the binary file /// does not already have a symbol table. @@ -186,7 +186,7 @@ pub const File = struct { /// May be called before or after updateDeclExports but must be called /// after allocateDeclIndexes for any given Decl. - pub fn updateDecl(base: *File, module: *ZigModule, decl: *ZigModule.Decl) !void { + pub fn updateDecl(base: *File, module: *Module, decl: *Module.Decl) !void { switch (base.tag) { .coff => return @fieldParentPtr(Coff, "base", base).updateDecl(module, decl), .elf => return @fieldParentPtr(Elf, "base", base).updateDecl(module, decl), @@ -196,7 +196,7 @@ pub const File = struct { } } - pub fn updateDeclLineNumber(base: *File, module: *ZigModule, decl: *ZigModule.Decl) !void { + pub fn updateDeclLineNumber(base: *File, module: *Module, decl: *Module.Decl) !void { switch (base.tag) { .coff => return @fieldParentPtr(Coff, "base", base).updateDeclLineNumber(module, decl), .elf => return @fieldParentPtr(Elf, "base", base).updateDeclLineNumber(module, decl), @@ -207,7 +207,7 @@ pub const File = struct { /// Must be called before any call to updateDecl or updateDeclExports for /// any given Decl. - pub fn allocateDeclIndexes(base: *File, decl: *ZigModule.Decl) !void { + pub fn allocateDeclIndexes(base: *File, decl: *Module.Decl) !void { switch (base.tag) { .coff => return @fieldParentPtr(Coff, "base", base).allocateDeclIndexes(decl), .elf => return @fieldParentPtr(Elf, "base", base).allocateDeclIndexes(decl), @@ -271,7 +271,7 @@ pub const File = struct { }; } - pub fn freeDecl(base: *File, decl: *ZigModule.Decl) void { + pub fn freeDecl(base: *File, decl: *Module.Decl) void { switch (base.tag) { .coff => @fieldParentPtr(Coff, "base", base).freeDecl(decl), .elf => @fieldParentPtr(Elf, "base", base).freeDecl(decl), @@ -295,9 +295,9 @@ pub const File = struct { /// allocateDeclIndexes for any given Decl. pub fn updateDeclExports( base: *File, - module: *ZigModule, - decl: *const ZigModule.Decl, - exports: []const *ZigModule.Export, + module: *Module, + decl: *const Module.Decl, + exports: []const *Module.Export, ) !void { switch (base.tag) { .coff => return @fieldParentPtr(Coff, "base", base).updateDeclExports(module, decl, exports), @@ -308,7 +308,7 @@ pub const File = struct { } } - pub fn getDeclVAddr(base: *File, decl: *const ZigModule.Decl) u64 { + pub fn getDeclVAddr(base: *File, decl: *const Module.Decl) u64 { switch (base.tag) { .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl), .elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl), diff --git a/src-self-hosted/link/C.zig b/src-self-hosted/link/C.zig index 6cf406f353..54c244d3e5 100644 --- a/src-self-hosted/link/C.zig +++ b/src-self-hosted/link/C.zig @@ -2,7 +2,7 @@ const std = @import("std"); const mem = std.mem; const assert = std.debug.assert; const Allocator = std.mem.Allocator; -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Compilation = @import("../Compilation.zig"); const fs = std.fs; const codegen = @import("../codegen/c.zig"); diff --git a/src-self-hosted/link/Coff.zig b/src-self-hosted/link/Coff.zig index 7d45f61f24..308c9c2332 100644 --- a/src-self-hosted/link/Coff.zig +++ b/src-self-hosted/link/Coff.zig @@ -7,7 +7,7 @@ const assert = std.debug.assert; const fs = std.fs; const trace = @import("../tracy.zig").trace; -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Compilation = @import("../Compilation.zig"); const codegen = @import("../codegen.zig"); const link = @import("../link.zig"); diff --git a/src-self-hosted/link/Elf.zig b/src-self-hosted/link/Elf.zig index b88790a8cc..2131f44f3d 100644 --- a/src-self-hosted/link/Elf.zig +++ b/src-self-hosted/link/Elf.zig @@ -3,7 +3,7 @@ const mem = std.mem; const assert = std.debug.assert; const Allocator = std.mem.Allocator; const ir = @import("../ir.zig"); -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Compilation = @import("../Compilation.zig"); const fs = std.fs; const elf = std.elf; @@ -743,7 +743,7 @@ pub fn flush(self: *Elf, comp: *Compilation) !void { fn flushInner(self: *Elf, comp: *Compilation) !void { // TODO This linker code currently assumes there is only 1 compilation unit and it corresponds to the // Zig source code. - const zig_module = self.base.options.zig_module orelse return error.LinkingWithoutZigSourceUnimplemented; + const module = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented; const target_endian = self.base.options.target.cpu.arch.endian(); const foreign_endian = target_endian != std.Target.current.cpu.arch.endian(); @@ -866,8 +866,8 @@ fn flushInner(self: *Elf, comp: *Compilation) !void { }, } // Write the form for the compile unit, which must match the abbrev table above. - const name_strp = try self.makeDebugString(zig_module.root_pkg.root_src_path); - const comp_dir_strp = try self.makeDebugString(zig_module.root_pkg.root_src_directory.path.?); + const name_strp = try self.makeDebugString(module.root_pkg.root_src_path); + const comp_dir_strp = try self.makeDebugString(module.root_pkg.root_src_directory.path.?); const producer_strp = try self.makeDebugString(link.producer_string); // Currently only one compilation unit is supported, so the address range is simply // identical to the main program header virtual address and memory size. @@ -1036,7 +1036,7 @@ fn flushInner(self: *Elf, comp: *Compilation) !void { 0, // include_directories (none except the compilation unit cwd) }); // file_names[0] - di_buf.appendSliceAssumeCapacity(zig_module.root_pkg.root_src_path); // relative path name + di_buf.appendSliceAssumeCapacity(module.root_pkg.root_src_path); // relative path name di_buf.appendSliceAssumeCapacity(&[_]u8{ 0, // null byte for the relative path name 0, // directory_index @@ -1230,7 +1230,7 @@ fn linkWithLLD(self: *Elf, 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 zig_module_obj_path: ?[]const u8 = if (self.base.options.zig_module) |module| blk: { + const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: { try self.flushInner(comp); const obj_basename = self.base.intermediary_basename.?; @@ -1270,7 +1270,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { .failure => return error.NotAllCSourceFilesAvailableToLink, .success => |success| _ = try ch.addFile(success.object_path, null), }; - try ch.addOptionalFile(zig_module_obj_path); + try ch.addOptionalFile(module_obj_path); // We can skip hashing libc and libc++ components that we are in charge of building from Zig // installation sources because they are always a product of the compiler version + target information. ch.hash.addOptional(self.base.options.stack_size_override); @@ -1500,7 +1500,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { .success => |success| try argv.append(success.object_path), }; - if (zig_module_obj_path) |p| { + if (module_obj_path) |p| { try argv.append(p); } @@ -2837,8 +2837,8 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 { directory_count * 8 + file_name_count * 8 + // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like // because of a workaround for readelf and gdb failing to understand DWARFv5 correctly. - self.base.options.zig_module.?.root_pkg.root_src_directory.path.?.len + - self.base.options.zig_module.?.root_pkg.root_src_path.len); + self.base.options.module.?.root_pkg.root_src_directory.path.?.len + + self.base.options.module.?.root_pkg.root_src_path.len); } fn dbgInfoNeededHeaderBytes(self: Elf) u32 { diff --git a/src-self-hosted/link/MachO.zig b/src-self-hosted/link/MachO.zig index dd70cc7c2b..0c7e3ce2ed 100644 --- a/src-self-hosted/link/MachO.zig +++ b/src-self-hosted/link/MachO.zig @@ -12,7 +12,7 @@ const mem = std.mem; const trace = @import("../tracy.zig").trace; const Type = @import("../type.zig").Type; -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Compilation = @import("../Compilation.zig"); const link = @import("../link.zig"); const File = link.File; diff --git a/src-self-hosted/link/Wasm.zig b/src-self-hosted/link/Wasm.zig index 85634daca5..25e623bebb 100644 --- a/src-self-hosted/link/Wasm.zig +++ b/src-self-hosted/link/Wasm.zig @@ -6,7 +6,7 @@ const assert = std.debug.assert; const fs = std.fs; const leb = std.debug.leb; -const Module = @import("../ZigModule.zig"); +const Module = @import("../Module.zig"); const Compilation = @import("../Compilation.zig"); const codegen = @import("../codegen/wasm.zig"); const link = @import("../link.zig"); @@ -165,7 +165,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void { } // Export section - if (self.base.options.zig_module) |module| { + if (self.base.options.module) |module| { const header_offset = try reserveVecSectionHeader(file); const writer = file.writer(); var count: u32 = 0; diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index d0bce3e19f..b7ec9ee712 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -1232,9 +1232,9 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8) } if (zir_out_path) |zop| { - const zig_module = comp.bin_file.options.zig_module orelse + const module = comp.bin_file.options.module orelse fatal("-femit-zir with no zig source code", .{}); - var new_zir_module = try zir.emit(gpa, zig_module); + var new_zir_module = try zir.emit(gpa, module); defer new_zir_module.deinit(gpa); const baf = try io.BufferedAtomicFile.create(gpa, fs.cwd(), zop, .{}); diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index edff8aa262..154a839a3c 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -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, comp.bin_file.options.zig_module.?); + var new_zir_module = try zir.emit(allocator, comp.bin_file.options.module.?); defer new_zir_module.deinit(allocator); emit_node.end(); diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig index 0c3d077477..4966395512 100644 --- a/src-self-hosted/type.zig +++ b/src-self-hosted/type.zig @@ -3,7 +3,7 @@ const Value = @import("value.zig").Value; const assert = std.debug.assert; const Allocator = std.mem.Allocator; const Target = std.Target; -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); /// This is the raw data, with no bookkeeping, no memory awareness, no de-duplication. /// It's important for this type to be small. diff --git a/src-self-hosted/value.zig b/src-self-hosted/value.zig index 2344b813b3..b65aa06bea 100644 --- a/src-self-hosted/value.zig +++ b/src-self-hosted/value.zig @@ -6,7 +6,7 @@ const BigIntConst = std.math.big.int.Const; const BigIntMutable = std.math.big.int.Mutable; const Target = std.Target; const Allocator = std.mem.Allocator; -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); /// This is the raw data, with no bookkeeping, no memory awareness, /// no de-duplication, and no type system awareness. diff --git a/src-self-hosted/zir.zig b/src-self-hosted/zir.zig index f543f8b2ce..7e723fc674 100644 --- a/src-self-hosted/zir.zig +++ b/src-self-hosted/zir.zig @@ -10,7 +10,7 @@ const Type = @import("type.zig").Type; const Value = @import("value.zig").Value; const TypedValue = @import("TypedValue.zig"); const ir = @import("ir.zig"); -const IrModule = @import("ZigModule.zig"); +const IrModule = @import("Module.zig"); /// This struct is relevent only for the ZIR Module text format. It is not used for /// semantic analysis of Zig source code. diff --git a/src-self-hosted/zir_sema.zig b/src-self-hosted/zir_sema.zig index 6a93bc2a5e..10543d2ee6 100644 --- a/src-self-hosted/zir_sema.zig +++ b/src-self-hosted/zir_sema.zig @@ -16,7 +16,7 @@ const TypedValue = @import("TypedValue.zig"); const assert = std.debug.assert; const ir = @import("ir.zig"); const zir = @import("zir.zig"); -const Module = @import("ZigModule.zig"); +const Module = @import("Module.zig"); const Inst = ir.Inst; const Body = ir.Body; const trace = @import("tracy.zig").trace;