| ... | @@ -190,7 +190,7 @@ pub fn updateFile( | ... | @@ -190,7 +190,7 @@ pub fn updateFile( |
| 190 | // failure was a race, or ENOENT, indicating deletion of the | 190 | // failure was a race, or ENOENT, indicating deletion of the |
| 191 | // directory of our open handle. | 191 | // directory of our open handle. |
| 192 | if (builtin.os.tag != .macos) { | 192 | if (builtin.os.tag != .macos) { |
| 193 | std.process.fatal("cache directory '{}' unexpectedly removed during compiler execution", .{ | 193 | std.process.fatal("cache directory '{f}' unexpectedly removed during compiler execution", .{ |
| 194 | cache_directory, | 194 | cache_directory, |
| 195 | }); | 195 | }); |
| 196 | } | 196 | } |
| ... | @@ -202,7 +202,7 @@ pub fn updateFile( | ... | @@ -202,7 +202,7 @@ pub fn updateFile( |
| 202 | }) catch |excl_err| switch (excl_err) { | 202 | }) catch |excl_err| switch (excl_err) { |
| 203 | error.PathAlreadyExists => continue, | 203 | error.PathAlreadyExists => continue, |
| 204 | error.FileNotFound => { | 204 | error.FileNotFound => { |
| 205 | std.process.fatal("cache directory '{}' unexpectedly removed during compiler execution", .{ | 205 | std.process.fatal("cache directory '{f}' unexpectedly removed during compiler execution", .{ |
| 206 | cache_directory, | 206 | cache_directory, |
| 207 | }); | 207 | }); |
| 208 | }, | 208 | }, |
| ... | @@ -249,11 +249,14 @@ pub fn updateFile( | ... | @@ -249,11 +249,14 @@ pub fn updateFile( |
| 249 | if (stat.size > std.math.maxInt(u32)) | 249 | if (stat.size > std.math.maxInt(u32)) |
| 250 | return error.FileTooBig; | 250 | return error.FileTooBig; |
| 251 | | 251 | |
| 252 | const source = try gpa.allocSentinel(u8, @as(usize, @intCast(stat.size)), 0); | 252 | const source = try gpa.allocSentinel(u8, @intCast(stat.size), 0); |
| 253 | defer if (file.source == null) gpa.free(source); | 253 | defer if (file.source == null) gpa.free(source); |
| 254 | const amt = try source_file.readAll(source); | 254 | var source_fr = source_file.reader(&.{}); |
| 255 | if (amt != stat.size) | 255 | source_fr.size = stat.size; |
| 256 | return error.UnexpectedEndOfFile; | 256 | source_fr.interface.readSliceAll(source) catch |err| switch (err) { |
| | 257 | error.ReadFailed => return source_fr.err.?, |
| | 258 | error.EndOfStream => return error.UnexpectedEndOfFile, |
| | 259 | }; |
| 257 | | 260 | |
| 258 | file.source = source; | 261 | file.source = source; |
| 259 | | 262 | |
| ... | @@ -265,7 +268,7 @@ pub fn updateFile( | ... | @@ -265,7 +268,7 @@ pub fn updateFile( |
| 265 | file.zir = try AstGen.generate(gpa, file.tree.?); | 268 | file.zir = try AstGen.generate(gpa, file.tree.?); |
| 266 | Zcu.saveZirCache(gpa, cache_file, stat, file.zir.?) catch |err| switch (err) { | 269 | Zcu.saveZirCache(gpa, cache_file, stat, file.zir.?) catch |err| switch (err) { |
| 267 | error.OutOfMemory => |e| return e, | 270 | error.OutOfMemory => |e| return e, |
| 268 | else => log.warn("unable to write cached ZIR code for {} to {}{s}: {s}", .{ | 271 | else => log.warn("unable to write cached ZIR code for {f} to {f}{s}: {s}", .{ |
| 269 | file.path.fmt(comp), cache_directory, &hex_digest, @errorName(err), | 272 | file.path.fmt(comp), cache_directory, &hex_digest, @errorName(err), |
| 270 | }), | 273 | }), |
| 271 | }; | 274 | }; |
| ... | @@ -273,7 +276,7 @@ pub fn updateFile( | ... | @@ -273,7 +276,7 @@ pub fn updateFile( |
| 273 | .zon => { | 276 | .zon => { |
| 274 | file.zoir = try ZonGen.generate(gpa, file.tree.?, .{}); | 277 | file.zoir = try ZonGen.generate(gpa, file.tree.?, .{}); |
| 275 | Zcu.saveZoirCache(cache_file, stat, file.zoir.?) catch |err| { | 278 | Zcu.saveZoirCache(cache_file, stat, file.zoir.?) catch |err| { |
| 276 | log.warn("unable to write cached ZOIR code for {} to {}{s}: {s}", .{ | 279 | log.warn("unable to write cached ZOIR code for {f} to {f}{s}: {s}", .{ |
| 277 | file.path.fmt(comp), cache_directory, &hex_digest, @errorName(err), | 280 | file.path.fmt(comp), cache_directory, &hex_digest, @errorName(err), |
| 278 | }); | 281 | }); |
| 279 | }; | 282 | }; |
| ... | @@ -340,13 +343,19 @@ fn loadZirZoirCache( | ... | @@ -340,13 +343,19 @@ fn loadZirZoirCache( |
| 340 | .zon => Zoir.Header, | 343 | .zon => Zoir.Header, |
| 341 | }; | 344 | }; |
| 342 | | 345 | |
| | 346 | var buffer: [@sizeOf(Header)]u8 = undefined; |
| | 347 | var cache_fr = cache_file.reader(&buffer); |
| | 348 | cache_fr.size = stat.size; |
| | 349 | const cache_br = &cache_fr.interface; |
| | 350 | |
| 343 | // First we read the header to determine the lengths of arrays. | 351 | // First we read the header to determine the lengths of arrays. |
| 344 | const header = cache_file.deprecatedReader().readStruct(Header) catch |err| switch (err) { | 352 | const header = (cache_br.takeStruct(Header) catch |err| switch (err) { |
| | 353 | error.ReadFailed => return cache_fr.err.?, |
| 345 | // This can happen if Zig bails out of this function between creating | 354 | // This can happen if Zig bails out of this function between creating |
| 346 | // the cached file and writing it. | 355 | // the cached file and writing it. |
| 347 | error.EndOfStream => return .invalid, | 356 | error.EndOfStream => return .invalid, |
| 348 | else => |e| return e, | 357 | else => |e| return e, |
| 349 | }; | 358 | }).*; |
| 350 | | 359 | |
| 351 | const unchanged_metadata = | 360 | const unchanged_metadata = |
| 352 | stat.size == header.stat_size and | 361 | stat.size == header.stat_size and |
| ... | @@ -358,17 +367,15 @@ fn loadZirZoirCache( | ... | @@ -358,17 +367,15 @@ fn loadZirZoirCache( |
| 358 | } | 367 | } |
| 359 | | 368 | |
| 360 | switch (mode) { | 369 | switch (mode) { |
| 361 | .zig => { | 370 | .zig => file.zir = Zcu.loadZirCacheBody(gpa, header, cache_br) catch |err| switch (err) { |
| 362 | file.zir = Zcu.loadZirCacheBody(gpa, header, cache_file) catch |err| switch (err) { | 371 | error.ReadFailed => return cache_fr.err.?, |
| 363 | error.UnexpectedFileSize => return .truncated, | 372 | error.EndOfStream => return .truncated, |
| 364 | else => |e| return e, | 373 | else => |e| return e, |
| 365 | }; | | |
| 366 | }, | 374 | }, |
| 367 | .zon => { | 375 | .zon => file.zoir = Zcu.loadZoirCacheBody(gpa, header, cache_br) catch |err| switch (err) { |
| 368 | file.zoir = Zcu.loadZoirCacheBody(gpa, header, cache_file) catch |err| switch (err) { | 376 | error.ReadFailed => return cache_fr.err.?, |
| 369 | error.UnexpectedFileSize => return .truncated, | 377 | error.EndOfStream => return .truncated, |
| 370 | else => |e| return e, | 378 | else => |e| return e, |
| 371 | }; | | |
| 372 | }, | 379 | }, |
| 373 | } | 380 | } |
| 374 | | 381 | |
| ... | @@ -478,10 +485,7 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void { | ... | @@ -478,10 +485,7 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void { |
| 478 | break :hash_changed; | 485 | break :hash_changed; |
| 479 | } | 486 | } |
| 480 | log.debug("hash for (%{d} -> %{d}) changed: {x} -> {x}", .{ | 487 | log.debug("hash for (%{d} -> %{d}) changed: {x} -> {x}", .{ |
| 481 | old_inst, | 488 | old_inst, new_inst, &old_hash, &new_hash, |
| 482 | new_inst, | | |
| 483 | &old_hash, | | |
| 484 | &new_hash, | | |
| 485 | }); | 489 | }); |
| 486 | } | 490 | } |
| 487 | // The source hash associated with this instruction changed - invalidate relevant dependencies. | 491 | // The source hash associated with this instruction changed - invalidate relevant dependencies. |
| ... | @@ -649,7 +653,7 @@ pub fn ensureMemoizedStateUpToDate(pt: Zcu.PerThread, stage: InternPool.Memoized | ... | @@ -649,7 +653,7 @@ pub fn ensureMemoizedStateUpToDate(pt: Zcu.PerThread, stage: InternPool.Memoized |
| 649 | // If this unit caused the error, it would have an entry in `failed_analysis`. | 653 | // If this unit caused the error, it would have an entry in `failed_analysis`. |
| 650 | // Since it does not, this must be a transitive failure. | 654 | // Since it does not, this must be a transitive failure. |
| 651 | try zcu.transitive_failed_analysis.put(gpa, unit, {}); | 655 | try zcu.transitive_failed_analysis.put(gpa, unit, {}); |
| 652 | log.debug("mark transitive analysis failure for {}", .{zcu.fmtAnalUnit(unit)}); | 656 | log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(unit)}); |
| 653 | } | 657 | } |
| 654 | break :res .{ !prev_failed, true }; | 658 | break :res .{ !prev_failed, true }; |
| 655 | }, | 659 | }, |
| ... | @@ -754,7 +758,7 @@ pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeU | ... | @@ -754,7 +758,7 @@ pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeU |
| 754 | | 758 | |
| 755 | const anal_unit: AnalUnit = .wrap(.{ .@"comptime" = cu_id }); | 759 | const anal_unit: AnalUnit = .wrap(.{ .@"comptime" = cu_id }); |
| 756 | | 760 | |
| 757 | log.debug("ensureComptimeUnitUpToDate {}", .{zcu.fmtAnalUnit(anal_unit)}); | 761 | log.debug("ensureComptimeUnitUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 758 | | 762 | |
| 759 | assert(!zcu.analysis_in_progress.contains(anal_unit)); | 763 | assert(!zcu.analysis_in_progress.contains(anal_unit)); |
| 760 | | 764 | |
| ... | @@ -805,7 +809,7 @@ pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeU | ... | @@ -805,7 +809,7 @@ pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeU |
| 805 | // If this unit caused the error, it would have an entry in `failed_analysis`. | 809 | // If this unit caused the error, it would have an entry in `failed_analysis`. |
| 806 | // Since it does not, this must be a transitive failure. | 810 | // Since it does not, this must be a transitive failure. |
| 807 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); | 811 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); |
| 808 | log.debug("mark transitive analysis failure for {}", .{zcu.fmtAnalUnit(anal_unit)}); | 812 | log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 809 | } | 813 | } |
| 810 | return error.AnalysisFail; | 814 | return error.AnalysisFail; |
| 811 | }, | 815 | }, |
| ... | @@ -835,7 +839,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu | ... | @@ -835,7 +839,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu |
| 835 | const anal_unit: AnalUnit = .wrap(.{ .@"comptime" = cu_id }); | 839 | const anal_unit: AnalUnit = .wrap(.{ .@"comptime" = cu_id }); |
| 836 | const comptime_unit = ip.getComptimeUnit(cu_id); | 840 | const comptime_unit = ip.getComptimeUnit(cu_id); |
| 837 | | 841 | |
| 838 | log.debug("analyzeComptimeUnit {}", .{zcu.fmtAnalUnit(anal_unit)}); | 842 | log.debug("analyzeComptimeUnit {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 839 | | 843 | |
| 840 | const inst_resolved = comptime_unit.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 844 | const inst_resolved = comptime_unit.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 841 | const file = zcu.fileByIndex(inst_resolved.file); | 845 | const file = zcu.fileByIndex(inst_resolved.file); |
| ... | @@ -881,7 +885,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu | ... | @@ -881,7 +885,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu |
| 881 | .r = .{ .simple = .comptime_keyword }, | 885 | .r = .{ .simple = .comptime_keyword }, |
| 882 | } }, | 886 | } }, |
| 883 | .src_base_inst = comptime_unit.zir_index, | 887 | .src_base_inst = comptime_unit.zir_index, |
| 884 | .type_name_ctx = try ip.getOrPutStringFmt(gpa, pt.tid, "{}.comptime", .{ | 888 | .type_name_ctx = try ip.getOrPutStringFmt(gpa, pt.tid, "{f}.comptime", .{ |
| 885 | Type.fromInterned(zcu.namespacePtr(comptime_unit.namespace).owner_type).containerTypeName(ip).fmt(ip), | 889 | Type.fromInterned(zcu.namespacePtr(comptime_unit.namespace).owner_type).containerTypeName(ip).fmt(ip), |
| 886 | }, .no_embedded_nulls), | 890 | }, .no_embedded_nulls), |
| 887 | }; | 891 | }; |
| ... | @@ -933,7 +937,7 @@ pub fn ensureNavValUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu | ... | @@ -933,7 +937,7 @@ pub fn ensureNavValUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu |
| 933 | const anal_unit: AnalUnit = .wrap(.{ .nav_val = nav_id }); | 937 | const anal_unit: AnalUnit = .wrap(.{ .nav_val = nav_id }); |
| 934 | const nav = ip.getNav(nav_id); | 938 | const nav = ip.getNav(nav_id); |
| 935 | | 939 | |
| 936 | log.debug("ensureNavValUpToDate {}", .{zcu.fmtAnalUnit(anal_unit)}); | 940 | log.debug("ensureNavValUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 937 | | 941 | |
| 938 | // Determine whether or not this `Nav`'s value is outdated. This also includes checking if the | 942 | // Determine whether or not this `Nav`'s value is outdated. This also includes checking if the |
| 939 | // status is `.unresolved`, which indicates that the value is outdated because it has *never* | 943 | // status is `.unresolved`, which indicates that the value is outdated because it has *never* |
| ... | @@ -991,7 +995,7 @@ pub fn ensureNavValUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu | ... | @@ -991,7 +995,7 @@ pub fn ensureNavValUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu |
| 991 | // If this unit caused the error, it would have an entry in `failed_analysis`. | 995 | // If this unit caused the error, it would have an entry in `failed_analysis`. |
| 992 | // Since it does not, this must be a transitive failure. | 996 | // Since it does not, this must be a transitive failure. |
| 993 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); | 997 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); |
| 994 | log.debug("mark transitive analysis failure for {}", .{zcu.fmtAnalUnit(anal_unit)}); | 998 | log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 995 | } | 999 | } |
| 996 | break :res .{ !prev_failed, true }; | 1000 | break :res .{ !prev_failed, true }; |
| 997 | }, | 1001 | }, |
| ... | @@ -1062,7 +1066,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr | ... | @@ -1062,7 +1066,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr |
| 1062 | const anal_unit: AnalUnit = .wrap(.{ .nav_val = nav_id }); | 1066 | const anal_unit: AnalUnit = .wrap(.{ .nav_val = nav_id }); |
| 1063 | const old_nav = ip.getNav(nav_id); | 1067 | const old_nav = ip.getNav(nav_id); |
| 1064 | | 1068 | |
| 1065 | log.debug("analyzeNavVal {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1069 | log.debug("analyzeNavVal {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1066 | | 1070 | |
| 1067 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 1071 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1068 | const file = zcu.fileByIndex(inst_resolved.file); | 1072 | const file = zcu.fileByIndex(inst_resolved.file); |
| ... | @@ -1321,7 +1325,7 @@ pub fn ensureNavTypeUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zc | ... | @@ -1321,7 +1325,7 @@ pub fn ensureNavTypeUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zc |
| 1321 | const anal_unit: AnalUnit = .wrap(.{ .nav_ty = nav_id }); | 1325 | const anal_unit: AnalUnit = .wrap(.{ .nav_ty = nav_id }); |
| 1322 | const nav = ip.getNav(nav_id); | 1326 | const nav = ip.getNav(nav_id); |
| 1323 | | 1327 | |
| 1324 | log.debug("ensureNavTypeUpToDate {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1328 | log.debug("ensureNavTypeUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1325 | | 1329 | |
| 1326 | const type_resolved_by_value: bool = from_val: { | 1330 | const type_resolved_by_value: bool = from_val: { |
| 1327 | const analysis = nav.analysis orelse break :from_val false; | 1331 | const analysis = nav.analysis orelse break :from_val false; |
| ... | @@ -1391,7 +1395,7 @@ pub fn ensureNavTypeUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zc | ... | @@ -1391,7 +1395,7 @@ pub fn ensureNavTypeUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zc |
| 1391 | // If this unit caused the error, it would have an entry in `failed_analysis`. | 1395 | // If this unit caused the error, it would have an entry in `failed_analysis`. |
| 1392 | // Since it does not, this must be a transitive failure. | 1396 | // Since it does not, this must be a transitive failure. |
| 1393 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); | 1397 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); |
| 1394 | log.debug("mark transitive analysis failure for {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1398 | log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1395 | } | 1399 | } |
| 1396 | break :res .{ !prev_failed, true }; | 1400 | break :res .{ !prev_failed, true }; |
| 1397 | }, | 1401 | }, |
| ... | @@ -1433,7 +1437,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr | ... | @@ -1433,7 +1437,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr |
| 1433 | const anal_unit: AnalUnit = .wrap(.{ .nav_ty = nav_id }); | 1437 | const anal_unit: AnalUnit = .wrap(.{ .nav_ty = nav_id }); |
| 1434 | const old_nav = ip.getNav(nav_id); | 1438 | const old_nav = ip.getNav(nav_id); |
| 1435 | | 1439 | |
| 1436 | log.debug("analyzeNavType {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1440 | log.debug("analyzeNavType {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1437 | | 1441 | |
| 1438 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 1442 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1439 | const file = zcu.fileByIndex(inst_resolved.file); | 1443 | const file = zcu.fileByIndex(inst_resolved.file); |
| ... | @@ -1563,7 +1567,7 @@ pub fn ensureFuncBodyUpToDate(pt: Zcu.PerThread, maybe_coerced_func_index: Inter | ... | @@ -1563,7 +1567,7 @@ pub fn ensureFuncBodyUpToDate(pt: Zcu.PerThread, maybe_coerced_func_index: Inter |
| 1563 | const func_index = ip.unwrapCoercedFunc(maybe_coerced_func_index); | 1567 | const func_index = ip.unwrapCoercedFunc(maybe_coerced_func_index); |
| 1564 | const anal_unit: AnalUnit = .wrap(.{ .func = func_index }); | 1568 | const anal_unit: AnalUnit = .wrap(.{ .func = func_index }); |
| 1565 | | 1569 | |
| 1566 | log.debug("ensureFuncBodyUpToDate {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1570 | log.debug("ensureFuncBodyUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1567 | | 1571 | |
| 1568 | const func = zcu.funcInfo(maybe_coerced_func_index); | 1572 | const func = zcu.funcInfo(maybe_coerced_func_index); |
| 1569 | | 1573 | |
| ... | @@ -1607,7 +1611,7 @@ pub fn ensureFuncBodyUpToDate(pt: Zcu.PerThread, maybe_coerced_func_index: Inter | ... | @@ -1607,7 +1611,7 @@ pub fn ensureFuncBodyUpToDate(pt: Zcu.PerThread, maybe_coerced_func_index: Inter |
| 1607 | // If this function caused the error, it would have an entry in `failed_analysis`. | 1611 | // If this function caused the error, it would have an entry in `failed_analysis`. |
| 1608 | // Since it does not, this must be a transitive failure. | 1612 | // Since it does not, this must be a transitive failure. |
| 1609 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); | 1613 | try zcu.transitive_failed_analysis.put(gpa, anal_unit, {}); |
| 1610 | log.debug("mark transitive analysis failure for {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1614 | log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1611 | } | 1615 | } |
| 1612 | // We consider the IES to be outdated if the function previously succeeded analysis; in this case, | 1616 | // We consider the IES to be outdated if the function previously succeeded analysis; in this case, |
| 1613 | // we need to re-analyze dependants to ensure they hit a transitive error here, rather than reporting | 1617 | // we need to re-analyze dependants to ensure they hit a transitive error here, rather than reporting |
| ... | @@ -1677,7 +1681,7 @@ fn analyzeFuncBody( | ... | @@ -1677,7 +1681,7 @@ fn analyzeFuncBody( |
| 1677 | else | 1681 | else |
| 1678 | .none; | 1682 | .none; |
| 1679 | | 1683 | |
| 1680 | log.debug("analyze and generate fn body {}", .{zcu.fmtAnalUnit(anal_unit)}); | 1684 | log.debug("analyze and generate fn body {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1681 | | 1685 | |
| 1682 | var air = try pt.analyzeFnBodyInner(func_index); | 1686 | var air = try pt.analyzeFnBodyInner(func_index); |
| 1683 | errdefer air.deinit(gpa); | 1687 | errdefer air.deinit(gpa); |
| ... | @@ -2414,8 +2418,12 @@ fn updateEmbedFileInner( | ... | @@ -2414,8 +2418,12 @@ fn updateEmbedFileInner( |
| 2414 | const old_len = strings.mutate.len; | 2418 | const old_len = strings.mutate.len; |
| 2415 | errdefer strings.shrinkRetainingCapacity(old_len); | 2419 | errdefer strings.shrinkRetainingCapacity(old_len); |
| 2416 | const bytes = (try strings.addManyAsSlice(size_plus_one))[0]; | 2420 | const bytes = (try strings.addManyAsSlice(size_plus_one))[0]; |
| 2417 | const actual_read = try file.readAll(bytes[0..size]); | 2421 | var fr = file.reader(&.{}); |
| 2418 | if (actual_read != size) return error.UnexpectedEof; | 2422 | fr.size = stat.size; |
| | 2423 | fr.interface.readSliceAll(bytes[0..size]) catch |err| switch (err) { |
| | 2424 | error.ReadFailed => return fr.err.?, |
| | 2425 | error.EndOfStream => return error.UnexpectedEof, |
| | 2426 | }; |
| 2419 | bytes[size] = 0; | 2427 | bytes[size] = 0; |
| 2420 | break :str try ip.getOrPutTrailingString(gpa, tid, @intCast(bytes.len), .maybe_embedded_nulls); | 2428 | break :str try ip.getOrPutTrailingString(gpa, tid, @intCast(bytes.len), .maybe_embedded_nulls); |
| 2421 | }; | 2429 | }; |
| ... | @@ -2584,7 +2592,7 @@ const ScanDeclIter = struct { | ... | @@ -2584,7 +2592,7 @@ const ScanDeclIter = struct { |
| 2584 | var gop = try iter.seen_decls.getOrPut(gpa, name); | 2592 | var gop = try iter.seen_decls.getOrPut(gpa, name); |
| 2585 | var next_suffix: u32 = 0; | 2593 | var next_suffix: u32 = 0; |
| 2586 | while (gop.found_existing) { | 2594 | while (gop.found_existing) { |
| 2587 | name = try ip.getOrPutStringFmt(gpa, pt.tid, "{}_{d}", .{ name.fmt(ip), next_suffix }, .no_embedded_nulls); | 2595 | name = try ip.getOrPutStringFmt(gpa, pt.tid, "{f}_{d}", .{ name.fmt(ip), next_suffix }, .no_embedded_nulls); |
| 2588 | gop = try iter.seen_decls.getOrPut(gpa, name); | 2596 | gop = try iter.seen_decls.getOrPut(gpa, name); |
| 2589 | next_suffix += 1; | 2597 | next_suffix += 1; |
| 2590 | } | 2598 | } |
| ... | @@ -2716,7 +2724,7 @@ const ScanDeclIter = struct { | ... | @@ -2716,7 +2724,7 @@ const ScanDeclIter = struct { |
| 2716 | | 2724 | |
| 2717 | if (existing_unit == null and (want_analysis or decl.linkage == .@"export")) { | 2725 | if (existing_unit == null and (want_analysis or decl.linkage == .@"export")) { |
| 2718 | log.debug( | 2726 | log.debug( |
| 2719 | "scanDecl queue analyze_comptime_unit file='{s}' unit={}", | 2727 | "scanDecl queue analyze_comptime_unit file='{s}' unit={f}", |
| 2720 | .{ namespace.fileScope(zcu).sub_file_path, zcu.fmtAnalUnit(unit) }, | 2728 | .{ namespace.fileScope(zcu).sub_file_path, zcu.fmtAnalUnit(unit) }, |
| 2721 | ); | 2729 | ); |
| 2722 | try comp.queueJob(.{ .analyze_comptime_unit = unit }); | 2730 | try comp.queueJob(.{ .analyze_comptime_unit = unit }); |
| ... | @@ -3134,7 +3142,7 @@ fn processExportsInner( | ... | @@ -3134,7 +3142,7 @@ fn processExportsInner( |
| 3134 | if (gop.found_existing) { | 3142 | if (gop.found_existing) { |
| 3135 | new_export.status = .failed_retryable; | 3143 | new_export.status = .failed_retryable; |
| 3136 | try zcu.failed_exports.ensureUnusedCapacity(gpa, 1); | 3144 | try zcu.failed_exports.ensureUnusedCapacity(gpa, 1); |
| 3137 | const msg = try Zcu.ErrorMsg.create(gpa, new_export.src, "exported symbol collision: {}", .{ | 3145 | const msg = try Zcu.ErrorMsg.create(gpa, new_export.src, "exported symbol collision: {f}", .{ |
| 3138 | new_export.opts.name.fmt(ip), | 3146 | new_export.opts.name.fmt(ip), |
| 3139 | }); | 3147 | }); |
| 3140 | errdefer msg.destroy(gpa); | 3148 | errdefer msg.destroy(gpa); |
| ... | @@ -4376,12 +4384,11 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e | ... | @@ -4376,12 +4384,11 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4376 | defer liveness.deinit(gpa); | 4384 | defer liveness.deinit(gpa); |
| 4377 | | 4385 | |
| 4378 | if (build_options.enable_debug_extensions and comp.verbose_air) { | 4386 | if (build_options.enable_debug_extensions and comp.verbose_air) { |
| 4379 | std.debug.lockStdErr(); | 4387 | const stderr = std.debug.lockStderrWriter(&.{}); |
| 4380 | defer std.debug.unlockStdErr(); | 4388 | defer std.debug.unlockStderrWriter(); |
| 4381 | const stderr = std.fs.File.stderr().deprecatedWriter(); | 4389 | stderr.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}) catch {}; |
| 4382 | stderr.print("# Begin Function AIR: {}:\n", .{fqn.fmt(ip)}) catch {}; | | |
| 4383 | air.write(stderr, pt, liveness); | 4390 | air.write(stderr, pt, liveness); |
| 4384 | stderr.print("# End Function AIR: {}\n\n", .{fqn.fmt(ip)}) catch {}; | 4391 | stderr.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}) catch {}; |
| 4385 | } | 4392 | } |
| 4386 | | 4393 | |
| 4387 | if (std.debug.runtime_safety) { | 4394 | if (std.debug.runtime_safety) { |