authorgravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 17:14:15+02:00
committergravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 17:14:15+02:00
log16d118a8d9ce48143ef406ff7b3a1f9d62021d98
treeed1ee766942fbdc7ee0d9cd154dfad24f7a483a8
parent2439f67061b007197bdd1b0037ffe4ba7b520024

update std and src-self-hosted for std.log breaking change


5 files changed, 41 insertions(+), 40 deletions(-)

lib/std/heap/general_purpose_allocator.zig+5-4
...@@ -93,6 +93,7 @@...@@ -93,6 +93,7 @@
93//! in a `std.HashMap` using the backing allocator.93//! in a `std.HashMap` using the backing allocator.
9494
95const std = @import("std");95const std = @import("std");
96const log = std.log.scoped(.std);
96const math = std.math;97const math = std.math;
97const assert = std.debug.assert;98const assert = std.debug.assert;
98const mem = std.mem;99const mem = std.mem;
...@@ -288,7 +289,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -288,7 +289,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
288 if (is_used) {289 if (is_used) {
289 const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index);290 const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index);
290 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);291 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);
291 std.log.err(.std, "Memory leak detected: {}", .{stack_trace});292 log.err("Memory leak detected: {}", .{stack_trace});
292 leaks = true;293 leaks = true;
293 }294 }
294 if (bit_index == math.maxInt(u3))295 if (bit_index == math.maxInt(u3))
...@@ -315,7 +316,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -315,7 +316,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
315 }316 }
316 }317 }
317 for (self.large_allocations.items()) |*large_alloc| {318 for (self.large_allocations.items()) |*large_alloc| {
318 std.log.err(.std, "Memory leak detected: {}", .{large_alloc.value.getStackTrace()});319 log.err("Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
319 leaks = true;320 leaks = true;
320 }321 }
321 return leaks;322 return leaks;
...@@ -450,7 +451,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -450,7 +451,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
450 .index = 0,451 .index = 0,
451 };452 };
452 std.debug.captureStackTrace(ret_addr, &free_stack_trace);453 std.debug.captureStackTrace(ret_addr, &free_stack_trace);
453 std.log.err(.std, "Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{454 log.err("Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
454 entry.value.bytes.len,455 entry.value.bytes.len,
455 old_mem.len,456 old_mem.len,
456 entry.value.getStackTrace(),457 entry.value.getStackTrace(),
...@@ -533,7 +534,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -533,7 +534,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
533 .index = 0,534 .index = 0,
534 };535 };
535 std.debug.captureStackTrace(ret_addr, &second_free_stack_trace);536 std.debug.captureStackTrace(ret_addr, &second_free_stack_trace);
536 std.log.err(.std, "Double free detected. Allocation: {} First free: {} Second free: {}", .{537 log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{
537 alloc_stack_trace,538 alloc_stack_trace,
538 free_stack_trace,539 free_stack_trace,
539 second_free_stack_trace,540 second_free_stack_trace,
src-self-hosted/Module.zig+9-9
...@@ -6,7 +6,7 @@ const Value = @import("value.zig").Value;...@@ -6,7 +6,7 @@ const Value = @import("value.zig").Value;
6const Type = @import("type.zig").Type;6const Type = @import("type.zig").Type;
7const TypedValue = @import("TypedValue.zig");7const TypedValue = @import("TypedValue.zig");
8const assert = std.debug.assert;8const assert = std.debug.assert;
9const log = std.log;9const log = std.log.scoped(.module);
10const BigIntConst = std.math.big.int.Const;10const BigIntConst = std.math.big.int.Const;
11const BigIntMutable = std.math.big.int.Mutable;11const BigIntMutable = std.math.big.int.Mutable;
12const Target = std.Target;12const Target = std.Target;
...@@ -1055,7 +1055,7 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {...@@ -1055,7 +1055,7 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {
1055 // lifetime annotations in the ZIR.1055 // lifetime annotations in the ZIR.
1056 var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.gpa);1056 var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.gpa);
1057 defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;1057 defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
1058 std.log.debug(.module, "analyze liveness of {}\n", .{decl.name});1058 log.debug("analyze liveness of {}\n", .{decl.name});
1059 try liveness.analyze(self.gpa, &decl_arena.allocator, payload.func.analysis.success);1059 try liveness.analyze(self.gpa, &decl_arena.allocator, payload.func.analysis.success);
1060 }1060 }
10611061
...@@ -1117,7 +1117,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {...@@ -1117,7 +1117,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
1117 .complete => return,1117 .complete => return,
11181118
1119 .outdated => blk: {1119 .outdated => blk: {
1120 log.debug(.module, "re-analyzing {}\n", .{decl.name});1120 log.debug("re-analyzing {}\n", .{decl.name});
11211121
1122 // The exports this Decl performs will be re-discovered, so we remove them here1122 // The exports this Decl performs will be re-discovered, so we remove them here
1123 // prior to re-analysis.1123 // prior to re-analysis.
...@@ -1563,7 +1563,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void {...@@ -1563,7 +1563,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void {
1563 // Handle explicitly deleted decls from the source code. Not to be confused1563 // Handle explicitly deleted decls from the source code. Not to be confused
1564 // with when we delete decls because they are no longer referenced.1564 // with when we delete decls because they are no longer referenced.
1565 for (deleted_decls.items()) |entry| {1565 for (deleted_decls.items()) |entry| {
1566 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});1566 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
1567 try self.deleteDecl(entry.key);1567 try self.deleteDecl(entry.key);
1568 }1568 }
1569}1569}
...@@ -1616,7 +1616,7 @@ fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void {...@@ -1616,7 +1616,7 @@ fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void {
1616 // Handle explicitly deleted decls from the source code. Not to be confused1616 // Handle explicitly deleted decls from the source code. Not to be confused
1617 // with when we delete decls because they are no longer referenced.1617 // with when we delete decls because they are no longer referenced.
1618 for (deleted_decls.items()) |entry| {1618 for (deleted_decls.items()) |entry| {
1619 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});1619 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
1620 try self.deleteDecl(entry.key);1620 try self.deleteDecl(entry.key);
1621 }1621 }
1622}1622}
...@@ -1628,7 +1628,7 @@ fn deleteDecl(self: *Module, decl: *Decl) !void {...@@ -1628,7 +1628,7 @@ fn deleteDecl(self: *Module, decl: *Decl) !void {
1628 // not be present in the set, and this does nothing.1628 // not be present in the set, and this does nothing.
1629 decl.scope.removeDecl(decl);1629 decl.scope.removeDecl(decl);
16301630
1631 log.debug(.module, "deleting decl '{}'\n", .{decl.name});1631 log.debug("deleting decl '{}'\n", .{decl.name});
1632 const name_hash = decl.fullyQualifiedNameHash();1632 const name_hash = decl.fullyQualifiedNameHash();
1633 self.decl_table.removeAssertDiscard(name_hash);1633 self.decl_table.removeAssertDiscard(name_hash);
1634 // Remove itself from its dependencies, because we are about to destroy the decl pointer.1634 // Remove itself from its dependencies, because we are about to destroy the decl pointer.
...@@ -1715,17 +1715,17 @@ fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void {...@@ -1715,17 +1715,17 @@ fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void {
1715 const fn_zir = func.analysis.queued;1715 const fn_zir = func.analysis.queued;
1716 defer fn_zir.arena.promote(self.gpa).deinit();1716 defer fn_zir.arena.promote(self.gpa).deinit();
1717 func.analysis = .{ .in_progress = {} };1717 func.analysis = .{ .in_progress = {} };
1718 log.debug(.module, "set {} to in_progress\n", .{decl.name});1718 log.debug("set {} to in_progress\n", .{decl.name});
17191719
1720 try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body);1720 try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body);
17211721
1722 const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items);1722 const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items);
1723 func.analysis = .{ .success = .{ .instructions = instructions } };1723 func.analysis = .{ .success = .{ .instructions = instructions } };
1724 log.debug(.module, "set {} to success\n", .{decl.name});1724 log.debug("set {} to success\n", .{decl.name});
1725}1725}
17261726
1727fn markOutdatedDecl(self: *Module, decl: *Decl) !void {1727fn markOutdatedDecl(self: *Module, decl: *Decl) !void {
1728 log.debug(.module, "mark {} outdated\n", .{decl.name});1728 log.debug("mark {} outdated\n", .{decl.name});
1729 try self.work_queue.writeItem(.{ .analyze_decl = decl });1729 try self.work_queue.writeItem(.{ .analyze_decl = decl });
1730 if (self.failed_decls.remove(decl)) |entry| {1730 if (self.failed_decls.remove(decl)) |entry| {
1731 entry.value.destroy(self.gpa);1731 entry.value.destroy(self.gpa);
src-self-hosted/link.zig+25-25
...@@ -8,7 +8,7 @@ const fs = std.fs;...@@ -8,7 +8,7 @@ const fs = std.fs;
8const elf = std.elf;8const elf = std.elf;
9const codegen = @import("codegen.zig");9const codegen = @import("codegen.zig");
10const c_codegen = @import("codegen/c.zig");10const c_codegen = @import("codegen/c.zig");
11const log = std.log;11const log = std.log.scoped(.link);
12const DW = std.dwarf;12const DW = std.dwarf;
13const trace = @import("tracy.zig").trace;13const trace = @import("tracy.zig").trace;
14const leb128 = std.debug.leb;14const leb128 = std.debug.leb;
...@@ -726,7 +726,7 @@ pub const File = struct {...@@ -726,7 +726,7 @@ pub const File = struct {
726 const file_size = self.base.options.program_code_size_hint;726 const file_size = self.base.options.program_code_size_hint;
727 const p_align = 0x1000;727 const p_align = 0x1000;
728 const off = self.findFreeSpace(file_size, p_align);728 const off = self.findFreeSpace(file_size, p_align);
729 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });729 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
730 try self.program_headers.append(self.base.allocator, .{730 try self.program_headers.append(self.base.allocator, .{
731 .p_type = elf.PT_LOAD,731 .p_type = elf.PT_LOAD,
732 .p_offset = off,732 .p_offset = off,
...@@ -747,7 +747,7 @@ pub const File = struct {...@@ -747,7 +747,7 @@ pub const File = struct {
747 // page align.747 // page align.
748 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);748 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);
749 const off = self.findFreeSpace(file_size, p_align);749 const off = self.findFreeSpace(file_size, p_align);
750 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });750 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
751 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.751 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.
752 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something752 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something
753 // else in virtual memory.753 // else in virtual memory.
...@@ -769,7 +769,7 @@ pub const File = struct {...@@ -769,7 +769,7 @@ pub const File = struct {
769 assert(self.shstrtab.items.len == 0);769 assert(self.shstrtab.items.len == 0);
770 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0770 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0
771 const off = self.findFreeSpace(self.shstrtab.items.len, 1);771 const off = self.findFreeSpace(self.shstrtab.items.len, 1);
772 log.debug(.link, "found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });772 log.debug("found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });
773 try self.sections.append(self.base.allocator, .{773 try self.sections.append(self.base.allocator, .{
774 .sh_name = try self.makeString(".shstrtab"),774 .sh_name = try self.makeString(".shstrtab"),
775 .sh_type = elf.SHT_STRTAB,775 .sh_type = elf.SHT_STRTAB,
...@@ -827,7 +827,7 @@ pub const File = struct {...@@ -827,7 +827,7 @@ pub const File = struct {
827 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);827 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);
828 const file_size = self.base.options.symbol_count_hint * each_size;828 const file_size = self.base.options.symbol_count_hint * each_size;
829 const off = self.findFreeSpace(file_size, min_align);829 const off = self.findFreeSpace(file_size, min_align);
830 log.debug(.link, "found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });830 log.debug("found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
831831
832 try self.sections.append(self.base.allocator, .{832 try self.sections.append(self.base.allocator, .{
833 .sh_name = try self.makeString(".symtab"),833 .sh_name = try self.makeString(".symtab"),
...@@ -869,7 +869,7 @@ pub const File = struct {...@@ -869,7 +869,7 @@ pub const File = struct {
869 const file_size_hint = 200;869 const file_size_hint = 200;
870 const p_align = 1;870 const p_align = 1;
871 const off = self.findFreeSpace(file_size_hint, p_align);871 const off = self.findFreeSpace(file_size_hint, p_align);
872 log.debug(.link, "found .debug_info free space 0x{x} to 0x{x}\n", .{872 log.debug("found .debug_info free space 0x{x} to 0x{x}\n", .{
873 off,873 off,
874 off + file_size_hint,874 off + file_size_hint,
875 });875 });
...@@ -894,7 +894,7 @@ pub const File = struct {...@@ -894,7 +894,7 @@ pub const File = struct {
894 const file_size_hint = 128;894 const file_size_hint = 128;
895 const p_align = 1;895 const p_align = 1;
896 const off = self.findFreeSpace(file_size_hint, p_align);896 const off = self.findFreeSpace(file_size_hint, p_align);
897 log.debug(.link, "found .debug_abbrev free space 0x{x} to 0x{x}\n", .{897 log.debug("found .debug_abbrev free space 0x{x} to 0x{x}\n", .{
898 off,898 off,
899 off + file_size_hint,899 off + file_size_hint,
900 });900 });
...@@ -919,7 +919,7 @@ pub const File = struct {...@@ -919,7 +919,7 @@ pub const File = struct {
919 const file_size_hint = 160;919 const file_size_hint = 160;
920 const p_align = 16;920 const p_align = 16;
921 const off = self.findFreeSpace(file_size_hint, p_align);921 const off = self.findFreeSpace(file_size_hint, p_align);
922 log.debug(.link, "found .debug_aranges free space 0x{x} to 0x{x}\n", .{922 log.debug("found .debug_aranges free space 0x{x} to 0x{x}\n", .{
923 off,923 off,
924 off + file_size_hint,924 off + file_size_hint,
925 });925 });
...@@ -944,7 +944,7 @@ pub const File = struct {...@@ -944,7 +944,7 @@ pub const File = struct {
944 const file_size_hint = 250;944 const file_size_hint = 250;
945 const p_align = 1;945 const p_align = 1;
946 const off = self.findFreeSpace(file_size_hint, p_align);946 const off = self.findFreeSpace(file_size_hint, p_align);
947 log.debug(.link, "found .debug_line free space 0x{x} to 0x{x}\n", .{947 log.debug("found .debug_line free space 0x{x} to 0x{x}\n", .{
948 off,948 off,
949 off + file_size_hint,949 off + file_size_hint,
950 });950 });
...@@ -1071,7 +1071,7 @@ pub const File = struct {...@@ -1071,7 +1071,7 @@ pub const File = struct {
1071 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);1071 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1072 }1072 }
1073 debug_abbrev_sect.sh_size = needed_size;1073 debug_abbrev_sect.sh_size = needed_size;
1074 log.debug(.link, ".debug_abbrev start=0x{x} end=0x{x}\n", .{1074 log.debug(".debug_abbrev start=0x{x} end=0x{x}\n", .{
1075 debug_abbrev_sect.sh_offset,1075 debug_abbrev_sect.sh_offset,
1076 debug_abbrev_sect.sh_offset + needed_size,1076 debug_abbrev_sect.sh_offset + needed_size,
1077 });1077 });
...@@ -1218,7 +1218,7 @@ pub const File = struct {...@@ -1218,7 +1218,7 @@ pub const File = struct {
1218 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);1218 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);
1219 }1219 }
1220 debug_aranges_sect.sh_size = needed_size;1220 debug_aranges_sect.sh_size = needed_size;
1221 log.debug(.link, ".debug_aranges start=0x{x} end=0x{x}\n", .{1221 log.debug(".debug_aranges start=0x{x} end=0x{x}\n", .{
1222 debug_aranges_sect.sh_offset,1222 debug_aranges_sect.sh_offset,
1223 debug_aranges_sect.sh_offset + needed_size,1223 debug_aranges_sect.sh_offset + needed_size,
1224 });1224 });
...@@ -1386,7 +1386,7 @@ pub const File = struct {...@@ -1386,7 +1386,7 @@ pub const File = struct {
1386 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);1386 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1387 }1387 }
1388 shstrtab_sect.sh_size = needed_size;1388 shstrtab_sect.sh_size = needed_size;
1389 log.debug(.link, "writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });1389 log.debug("writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
13901390
1391 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);1391 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
1392 if (!self.shdr_table_dirty) {1392 if (!self.shdr_table_dirty) {
...@@ -1407,7 +1407,7 @@ pub const File = struct {...@@ -1407,7 +1407,7 @@ pub const File = struct {
1407 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);1407 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1408 }1408 }
1409 debug_strtab_sect.sh_size = needed_size;1409 debug_strtab_sect.sh_size = needed_size;
1410 log.debug(.link, "debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });1410 log.debug("debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
14111411
1412 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);1412 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);
1413 if (!self.shdr_table_dirty) {1413 if (!self.shdr_table_dirty) {
...@@ -1441,7 +1441,7 @@ pub const File = struct {...@@ -1441,7 +1441,7 @@ pub const File = struct {
14411441
1442 for (buf) |*shdr, i| {1442 for (buf) |*shdr, i| {
1443 shdr.* = sectHeaderTo32(self.sections.items[i]);1443 shdr.* = sectHeaderTo32(self.sections.items[i]);
1444 std.log.debug(.link, "writing section {}\n", .{shdr.*});1444 log.debug("writing section {}\n", .{shdr.*});
1445 if (foreign_endian) {1445 if (foreign_endian) {
1446 bswapAllFields(elf.Elf32_Shdr, shdr);1446 bswapAllFields(elf.Elf32_Shdr, shdr);
1447 }1447 }
...@@ -1454,7 +1454,7 @@ pub const File = struct {...@@ -1454,7 +1454,7 @@ pub const File = struct {
14541454
1455 for (buf) |*shdr, i| {1455 for (buf) |*shdr, i| {
1456 shdr.* = self.sections.items[i];1456 shdr.* = self.sections.items[i];
1457 log.debug(.link, "writing section {}\n", .{shdr.*});1457 log.debug("writing section {}\n", .{shdr.*});
1458 if (foreign_endian) {1458 if (foreign_endian) {
1459 bswapAllFields(elf.Elf64_Shdr, shdr);1459 bswapAllFields(elf.Elf64_Shdr, shdr);
1460 }1460 }
...@@ -1465,10 +1465,10 @@ pub const File = struct {...@@ -1465,10 +1465,10 @@ pub const File = struct {
1465 self.shdr_table_dirty = false;1465 self.shdr_table_dirty = false;
1466 }1466 }
1467 if (self.entry_addr == null and self.base.options.output_mode == .Exe) {1467 if (self.entry_addr == null and self.base.options.output_mode == .Exe) {
1468 log.debug(.link, "flushing. no_entry_point_found = true\n", .{});1468 log.debug("flushing. no_entry_point_found = true\n", .{});
1469 self.error_flags.no_entry_point_found = true;1469 self.error_flags.no_entry_point_found = true;
1470 } else {1470 } else {
1471 log.debug(.link, "flushing. no_entry_point_found = false\n", .{});1471 log.debug("flushing. no_entry_point_found = false\n", .{});
1472 self.error_flags.no_entry_point_found = false;1472 self.error_flags.no_entry_point_found = false;
1473 try self.writeElfHeader();1473 try self.writeElfHeader();
1474 }1474 }
...@@ -1797,10 +1797,10 @@ pub const File = struct {...@@ -1797,10 +1797,10 @@ pub const File = struct {
1797 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);1797 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
17981798
1799 if (self.local_symbol_free_list.popOrNull()) |i| {1799 if (self.local_symbol_free_list.popOrNull()) |i| {
1800 log.debug(.link, "reusing symbol index {} for {}\n", .{ i, decl.name });1800 log.debug("reusing symbol index {} for {}\n", .{ i, decl.name });
1801 decl.link.elf.local_sym_index = i;1801 decl.link.elf.local_sym_index = i;
1802 } else {1802 } else {
1803 log.debug(.link, "allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });1803 log.debug("allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
1804 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);1804 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
1805 _ = self.local_symbols.addOneAssumeCapacity();1805 _ = self.local_symbols.addOneAssumeCapacity();
1806 }1806 }
...@@ -1993,11 +1993,11 @@ pub const File = struct {...@@ -1993,11 +1993,11 @@ pub const File = struct {
1993 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);1993 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);
1994 if (need_realloc) {1994 if (need_realloc) {
1995 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);1995 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);
1996 log.debug(.link, "growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });1996 log.debug("growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
1997 if (vaddr != local_sym.st_value) {1997 if (vaddr != local_sym.st_value) {
1998 local_sym.st_value = vaddr;1998 local_sym.st_value = vaddr;
19991999
2000 log.debug(.link, " (writing new offset table entry)\n", .{});2000 log.debug(" (writing new offset table entry)\n", .{});
2001 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;2001 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;
2002 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);2002 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);
2003 }2003 }
...@@ -2015,7 +2015,7 @@ pub const File = struct {...@@ -2015,7 +2015,7 @@ pub const File = struct {
2015 const decl_name = mem.spanZ(decl.name);2015 const decl_name = mem.spanZ(decl.name);
2016 const name_str_index = try self.makeString(decl_name);2016 const name_str_index = try self.makeString(decl_name);
2017 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);2017 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);
2018 log.debug(.link, "allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });2018 log.debug("allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
2019 errdefer self.freeTextBlock(&decl.link.elf);2019 errdefer self.freeTextBlock(&decl.link.elf);
20202020
2021 local_sym.* = .{2021 local_sym.* = .{
...@@ -2125,7 +2125,7 @@ pub const File = struct {...@@ -2125,7 +2125,7 @@ pub const File = struct {
2125 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {2125 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
2126 const new_offset = self.findFreeSpace(needed_size, 1);2126 const new_offset = self.findFreeSpace(needed_size, 1);
2127 const existing_size = last_src_fn.off;2127 const existing_size = last_src_fn.off;
2128 log.debug(.link, "moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{2128 log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
2129 existing_size,2129 existing_size,
2130 debug_line_sect.sh_offset,2130 debug_line_sect.sh_offset,
2131 new_offset,2131 new_offset,
...@@ -2204,7 +2204,7 @@ pub const File = struct {...@@ -2204,7 +2204,7 @@ pub const File = struct {
2204 try dbg_info_buffer.writer().print("{}\x00", .{ty});2204 try dbg_info_buffer.writer().print("{}\x00", .{ty});
2205 },2205 },
2206 else => {2206 else => {
2207 log.err(.compiler, "TODO implement .debug_info for type '{}'", .{ty});2207 std.log.scoped(.compiler).err("TODO implement .debug_info for type '{}'", .{ty});
2208 try dbg_info_buffer.append(abbrev_pad1);2208 try dbg_info_buffer.append(abbrev_pad1);
2209 },2209 },
2210 }2210 }
...@@ -2276,7 +2276,7 @@ pub const File = struct {...@@ -2276,7 +2276,7 @@ pub const File = struct {
2276 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {2276 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {
2277 const new_offset = self.findFreeSpace(needed_size, 1);2277 const new_offset = self.findFreeSpace(needed_size, 1);
2278 const existing_size = last_decl.dbg_info_off;2278 const existing_size = last_decl.dbg_info_off;
2279 log.debug(.link, "moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{2279 log.debug("moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{
2280 existing_size,2280 existing_size,
2281 debug_info_sect.sh_offset,2281 debug_info_sect.sh_offset,
2282 new_offset,2282 new_offset,
src-self-hosted/liveness.zig+1-1
...@@ -114,5 +114,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void...@@ -114,5 +114,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void
114 @panic("Handle liveness analysis for instructions with many parameters");114 @panic("Handle liveness analysis for instructions with many parameters");
115 }115 }
116116
117 std.log.debug(.liveness, "analyze {}: 0b{b}\n", .{ base.tag, base.deaths });117 std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
118}118}
src-self-hosted/main.zig+1-1
...@@ -560,7 +560,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo...@@ -560,7 +560,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo
560 });560 });
561 }561 }
562 } else {562 } else {
563 std.log.info(.compiler, "Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});563 std.log.scoped(.compiler).info("Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});
564 }564 }
565565
566 if (zir_out_path) |zop| {566 if (zir_out_path) |zop| {