Merge remote-tracking branch 'origin/master' into register-allocation
This commit is contained in:
@@ -27,7 +27,7 @@ root_pkg: *Package,
|
||||
/// Module owns this resource.
|
||||
/// The `Scope` is either a `Scope.ZIRModule` or `Scope.File`.
|
||||
root_scope: *Scope,
|
||||
bin_file: link.ElfFile,
|
||||
bin_file: *link.File,
|
||||
bin_file_dir: std.fs.Dir,
|
||||
bin_file_path: []const u8,
|
||||
/// It's rare for a decl to be exported, so we save memory by having a sparse map of
|
||||
@@ -46,7 +46,7 @@ export_owners: std.AutoHashMapUnmanaged(*Decl, []*Export) = .{},
|
||||
decl_table: std.HashMapUnmanaged(Scope.NameHash, *Decl, Scope.name_hash_hash, Scope.name_hash_eql, false) = .{},
|
||||
|
||||
optimize_mode: std.builtin.Mode,
|
||||
link_error_flags: link.ElfFile.ErrorFlags = .{},
|
||||
link_error_flags: link.File.ErrorFlags = .{},
|
||||
|
||||
work_queue: std.fifo.LinearFifo(WorkItem, .Dynamic),
|
||||
|
||||
@@ -90,7 +90,7 @@ pub const Export = struct {
|
||||
/// Byte offset into the file that contains the export directive.
|
||||
src: usize,
|
||||
/// Represents the position of the export, if any, in the output file.
|
||||
link: link.ElfFile.Export,
|
||||
link: link.File.Elf.Export,
|
||||
/// The Decl that performs the export. Note that this is *not* the Decl being exported.
|
||||
owner_decl: *Decl,
|
||||
/// The Decl being exported. Note this is *not* the Decl performing the export.
|
||||
@@ -168,7 +168,7 @@ pub const Decl = struct {
|
||||
|
||||
/// Represents the position of the code in the output file.
|
||||
/// This is populated regardless of semantic analysis and code generation.
|
||||
link: link.ElfFile.TextBlock = link.ElfFile.TextBlock.empty,
|
||||
link: link.File.Elf.TextBlock = link.File.Elf.TextBlock.empty,
|
||||
|
||||
contents_hash: std.zig.SrcHash,
|
||||
|
||||
@@ -723,17 +723,19 @@ pub const InitOptions = struct {
|
||||
object_format: ?std.builtin.ObjectFormat = null,
|
||||
optimize_mode: std.builtin.Mode = .Debug,
|
||||
keep_source_files_loaded: bool = false,
|
||||
cbe: bool = false,
|
||||
};
|
||||
|
||||
pub fn init(gpa: *Allocator, options: InitOptions) !Module {
|
||||
const bin_file_dir = options.bin_file_dir orelse std.fs.cwd();
|
||||
var bin_file = try link.openBinFilePath(gpa, bin_file_dir, options.bin_file_path, .{
|
||||
const bin_file = try link.openBinFilePath(gpa, bin_file_dir, options.bin_file_path, .{
|
||||
.target = options.target,
|
||||
.output_mode = options.output_mode,
|
||||
.link_mode = options.link_mode orelse .Static,
|
||||
.object_format = options.object_format orelse options.target.getObjectFormat(),
|
||||
.cbe = options.cbe,
|
||||
});
|
||||
errdefer bin_file.deinit();
|
||||
errdefer bin_file.destroy();
|
||||
|
||||
const root_scope = blk: {
|
||||
if (mem.endsWith(u8, options.root_pkg.root_src_path, ".zig")) {
|
||||
@@ -776,7 +778,7 @@ pub fn init(gpa: *Allocator, options: InitOptions) !Module {
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Module) void {
|
||||
self.bin_file.deinit();
|
||||
self.bin_file.destroy();
|
||||
const gpa = self.gpa;
|
||||
self.deletion_set.deinit(gpa);
|
||||
self.work_queue.deinit();
|
||||
@@ -825,7 +827,7 @@ fn freeExportList(gpa: *Allocator, export_list: []*Export) void {
|
||||
}
|
||||
|
||||
pub fn target(self: Module) std.Target {
|
||||
return self.bin_file.options.target;
|
||||
return self.bin_file.options().target;
|
||||
}
|
||||
|
||||
/// Detect changes to source files, perform semantic analysis, and update the output files.
|
||||
@@ -872,7 +874,7 @@ pub fn update(self: *Module) !void {
|
||||
try self.bin_file.flush();
|
||||
}
|
||||
|
||||
self.link_error_flags = self.bin_file.error_flags;
|
||||
self.link_error_flags = self.bin_file.errorFlags();
|
||||
std.log.debug(.module, "link_error_flags: {}\n", .{self.link_error_flags});
|
||||
|
||||
// If there are any errors, we anticipate the source files being loaded
|
||||
@@ -1985,8 +1987,9 @@ fn deleteDeclExports(self: *Module, decl: *Decl) void {
|
||||
self.decl_exports.removeAssertDiscard(exp.exported_decl);
|
||||
}
|
||||
}
|
||||
|
||||
self.bin_file.deleteExport(exp.link);
|
||||
if (self.bin_file.cast(link.File.Elf)) |elf| {
|
||||
elf.deleteExport(exp.link);
|
||||
}
|
||||
if (self.failed_exports.remove(exp)) |entry| {
|
||||
entry.value.destroy(self.gpa);
|
||||
}
|
||||
@@ -2048,7 +2051,7 @@ fn allocateNewDecl(
|
||||
.analysis = .unreferenced,
|
||||
.deletion_flag = false,
|
||||
.contents_hash = contents_hash,
|
||||
.link = link.ElfFile.TextBlock.empty,
|
||||
.link = link.File.Elf.TextBlock.empty,
|
||||
.generation = 0,
|
||||
};
|
||||
return new_decl;
|
||||
@@ -2559,7 +2562,7 @@ fn createAnonymousDecl(
|
||||
) !*Decl {
|
||||
const name_index = self.getNextAnonNameIndex();
|
||||
const scope_decl = scope.decl().?;
|
||||
const name = try std.fmt.allocPrint(self.gpa, "{}${}", .{ scope_decl.name, name_index });
|
||||
const name = try std.fmt.allocPrint(self.gpa, "{}__anon_{}", .{ scope_decl.name, name_index });
|
||||
defer self.gpa.free(name);
|
||||
const name_hash = scope.namespace().fullyQualifiedNameHash(name);
|
||||
const src_hash: std.zig.SrcHash = undefined;
|
||||
|
||||
Reference in New Issue
Block a user