| author | |
| committer | |
| log | f0d3b7abb8e96aede796c80ab73a0f82ecced722 |
| tree | c30830c47e465bee6ccf4eedbeee4b261ed2819f |
| parent | 9e979e5a9dbee39d45ac7dc4fbedb63ddcae8e99 |
also add ability to omit main source file from dep file as it messes up
caching strategy9 files changed, 45 insertions(+), 36 deletions(-)
lib/compiler/aro/aro/Compilation.zig+7-2| ... | @@ -934,7 +934,7 @@ pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefi | ... | @@ -934,7 +934,7 @@ pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefi |
| 934 | error.WriteFailed, error.OutOfMemory => return error.OutOfMemory, | 934 | error.WriteFailed, error.OutOfMemory => return error.OutOfMemory, |
| 935 | }; | 935 | }; |
| 936 | 936 | ||
| 937 | if (allocating.getWritten().len > std.math.maxInt(u32)) return error.FileTooBig; | 937 | if (allocating.written().len > std.math.maxInt(u32)) return error.FileTooBig; |
| 938 | 938 | ||
| 939 | const contents = try allocating.toOwnedSlice(); | 939 | const contents = try allocating.toOwnedSlice(); |
| 940 | errdefer comp.gpa.free(contents); | 940 | errdefer comp.gpa.free(contents); |
| ... | @@ -1589,6 +1589,7 @@ pub fn hasInclude( | ... | @@ -1589,6 +1589,7 @@ pub fn hasInclude( |
| 1589 | include_type: IncludeType, | 1589 | include_type: IncludeType, |
| 1590 | /// __has_include vs __has_include_next | 1590 | /// __has_include vs __has_include_next |
| 1591 | which: WhichInclude, | 1591 | which: WhichInclude, |
| 1592 | opt_dep_file: ?*DepFile, | ||
| 1592 | ) Compilation.Error!bool { | 1593 | ) Compilation.Error!bool { |
| 1593 | if (try FindInclude.run(comp, filename, switch (which) { | 1594 | if (try FindInclude.run(comp, filename, switch (which) { |
| 1594 | .next => .{ .only_search_after_dir = comp.getSource(includer_token_source).path }, | 1595 | .next => .{ .only_search_after_dir = comp.getSource(includer_token_source).path }, |
| ... | @@ -1596,7 +1597,11 @@ pub fn hasInclude( | ... | @@ -1596,7 +1597,11 @@ pub fn hasInclude( |
| 1596 | .quotes => .{ .allow_same_dir = comp.getSource(includer_token_source).path }, | 1597 | .quotes => .{ .allow_same_dir = comp.getSource(includer_token_source).path }, |
| 1597 | .angle_brackets => .only_search, | 1598 | .angle_brackets => .only_search, |
| 1598 | }, | 1599 | }, |
| 1599 | })) |_| { | 1600 | })) |found| { |
| 1601 | if (opt_dep_file) |dep_file| { | ||
| 1602 | const source = comp.getSource(found.source); | ||
| 1603 | try dep_file.addDependency(comp.gpa, source.path); | ||
| 1604 | } | ||
| 1600 | return true; | 1605 | return true; |
| 1601 | } else { | 1606 | } else { |
| 1602 | return false; | 1607 | return false; |
lib/compiler/aro/aro/Driver.zig+11-6| ... | @@ -831,7 +831,7 @@ pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { | ... | @@ -831,7 +831,7 @@ pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { |
| 831 | defer allocating.deinit(); | 831 | defer allocating.deinit(); |
| 832 | 832 | ||
| 833 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; | 833 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; |
| 834 | try d.diagnostics.add(.{ .kind = .@"error", .text = allocating.getWritten(), .location = null }); | 834 | try d.diagnostics.add(.{ .kind = .@"error", .text = allocating.written(), .location = null }); |
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { | 837 | pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { |
| ... | @@ -840,7 +840,7 @@ pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { | ... | @@ -840,7 +840,7 @@ pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void { |
| 840 | defer allocating.deinit(); | 840 | defer allocating.deinit(); |
| 841 | 841 | ||
| 842 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; | 842 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; |
| 843 | try d.diagnostics.add(.{ .kind = .warning, .text = allocating.getWritten(), .location = null }); | 843 | try d.diagnostics.add(.{ .kind = .warning, .text = allocating.written(), .location = null }); |
| 844 | } | 844 | } |
| 845 | 845 | ||
| 846 | pub fn unsupportedOptionForTarget(d: *Driver, target: std.Target, opt: []const u8) Compilation.Error!void { | 846 | pub fn unsupportedOptionForTarget(d: *Driver, target: std.Target, opt: []const u8) Compilation.Error!void { |
| ... | @@ -856,7 +856,7 @@ pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalEr | ... | @@ -856,7 +856,7 @@ pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalEr |
| 856 | defer allocating.deinit(); | 856 | defer allocating.deinit(); |
| 857 | 857 | ||
| 858 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; | 858 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; |
| 859 | try d.diagnostics.add(.{ .kind = .@"fatal error", .text = allocating.getWritten(), .location = null }); | 859 | try d.diagnostics.add(.{ .kind = .@"fatal error", .text = allocating.written(), .location = null }); |
| 860 | unreachable; | 860 | unreachable; |
| 861 | } | 861 | } |
| 862 | 862 | ||
| ... | @@ -986,7 +986,12 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_ | ... | @@ -986,7 +986,12 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_ |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | /// Initializes a DepFile if requested by driver options. | 988 | /// Initializes a DepFile if requested by driver options. |
| 989 | pub fn initDepFile(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) Compilation.Error!?DepFile { | 989 | pub fn initDepFile( |
| 990 | d: *Driver, | ||
| 991 | source: Source, | ||
| 992 | buf: *[std.fs.max_name_bytes]u8, | ||
| 993 | omit_source: bool, | ||
| 994 | ) Compilation.Error!?DepFile { | ||
| 990 | if (!d.dependencies.m and !d.dependencies.md) return null; | 995 | if (!d.dependencies.m and !d.dependencies.md) return null; |
| 991 | var dep_file: DepFile = .{ | 996 | var dep_file: DepFile = .{ |
| 992 | .target = undefined, | 997 | .target = undefined, |
| ... | @@ -1004,7 +1009,7 @@ pub fn initDepFile(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) | ... | @@ -1004,7 +1009,7 @@ pub fn initDepFile(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) |
| 1004 | return d.fatal("dependency file name too long for filesystem '{s}{s}'", args); | 1009 | return d.fatal("dependency file name too long for filesystem '{s}{s}'", args); |
| 1005 | } | 1010 | } |
| 1006 | 1011 | ||
| 1007 | try dep_file.addDependency(d.comp.gpa, source.path); | 1012 | if (!omit_source) try dep_file.addDependency(d.comp.gpa, source.path); |
| 1008 | errdefer comptime unreachable; | 1013 | errdefer comptime unreachable; |
| 1009 | 1014 | ||
| 1010 | return dep_file; | 1015 | return dep_file; |
| ... | @@ -1101,7 +1106,7 @@ fn processSource( | ... | @@ -1101,7 +1106,7 @@ fn processSource( |
| 1101 | defer pp.deinit(); | 1106 | defer pp.deinit(); |
| 1102 | 1107 | ||
| 1103 | var name_buf: [std.fs.max_name_bytes]u8 = undefined; | 1108 | var name_buf: [std.fs.max_name_bytes]u8 = undefined; |
| 1104 | var opt_dep_file = try d.initDepFile(source, &name_buf); | 1109 | var opt_dep_file = try d.initDepFile(source, &name_buf, false); |
| 1105 | defer if (opt_dep_file) |*dep_file| dep_file.deinit(pp.gpa); | 1110 | defer if (opt_dep_file) |*dep_file| dep_file.deinit(pp.gpa); |
| 1106 | 1111 | ||
| 1107 | if (opt_dep_file) |*dep_file| pp.dep_file = dep_file; | 1112 | if (opt_dep_file) |*dep_file| pp.dep_file = dep_file; |
lib/compiler/aro/aro/Parser.zig+6-6| ... | @@ -232,7 +232,7 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca | ... | @@ -232,7 +232,7 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca |
| 232 | 232 | ||
| 233 | try p.diagnostics.add(.{ | 233 | try p.diagnostics.add(.{ |
| 234 | .kind = diagnostic.kind, | 234 | .kind = diagnostic.kind, |
| 235 | .text = allocating.getWritten(), | 235 | .text = allocating.written(), |
| 236 | .extension = diagnostic.extension, | 236 | .extension = diagnostic.extension, |
| 237 | .opt = diagnostic.opt, | 237 | .opt = diagnostic.opt, |
| 238 | .location = loc.expand(p.comp), | 238 | .location = loc.expand(p.comp), |
| ... | @@ -244,7 +244,7 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca | ... | @@ -244,7 +244,7 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca |
| 244 | 244 | ||
| 245 | try p.diagnostics.add(.{ | 245 | try p.diagnostics.add(.{ |
| 246 | .kind = diagnostic.kind, | 246 | .kind = diagnostic.kind, |
| 247 | .text = allocating.getWritten(), | 247 | .text = allocating.written(), |
| 248 | .extension = diagnostic.extension, | 248 | .extension = diagnostic.extension, |
| 249 | .opt = diagnostic.opt, | 249 | .opt = diagnostic.opt, |
| 250 | .location = loc.expand(p.comp), | 250 | .location = loc.expand(p.comp), |
| ... | @@ -441,7 +441,7 @@ pub fn err(p: *Parser, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype) | ... | @@ -441,7 +441,7 @@ pub fn err(p: *Parser, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype) |
| 441 | } | 441 | } |
| 442 | try p.diagnostics.addWithLocation(p.comp, .{ | 442 | try p.diagnostics.addWithLocation(p.comp, .{ |
| 443 | .kind = diagnostic.kind, | 443 | .kind = diagnostic.kind, |
| 444 | .text = allocating.getWritten(), | 444 | .text = allocating.written(), |
| 445 | .opt = diagnostic.opt, | 445 | .opt = diagnostic.opt, |
| 446 | .extension = diagnostic.extension, | 446 | .extension = diagnostic.extension, |
| 447 | .location = loc.expand(p.comp), | 447 | .location = loc.expand(p.comp), |
| ... | @@ -1487,13 +1487,13 @@ fn staticAssertMessage(p: *Parser, cond_node: Node.Index, maybe_message: ?Result | ... | @@ -1487,13 +1487,13 @@ fn staticAssertMessage(p: *Parser, cond_node: Node.Index, maybe_message: ?Result |
| 1487 | 1487 | ||
| 1488 | if (maybe_message) |message| { | 1488 | if (maybe_message) |message| { |
| 1489 | assert(message.node.get(&p.tree) == .string_literal_expr); | 1489 | assert(message.node.get(&p.tree) == .string_literal_expr); |
| 1490 | if (allocating.getWritten().len > 0) { | 1490 | if (allocating.written().len > 0) { |
| 1491 | try w.writeByte(' '); | 1491 | try w.writeByte(' '); |
| 1492 | } | 1492 | } |
| 1493 | const bytes = p.comp.interner.get(message.val.ref()).bytes; | 1493 | const bytes = p.comp.interner.get(message.val.ref()).bytes; |
| 1494 | try Value.printString(bytes, message.qt, p.comp, w); | 1494 | try Value.printString(bytes, message.qt, p.comp, w); |
| 1495 | } | 1495 | } |
| 1496 | return allocating.getWritten(); | 1496 | return allocating.written(); |
| 1497 | } | 1497 | } |
| 1498 | 1498 | ||
| 1499 | /// staticAssert | 1499 | /// staticAssert |
| ... | @@ -9248,7 +9248,7 @@ fn primaryExpr(p: *Parser) Error!?Result { | ... | @@ -9248,7 +9248,7 @@ fn primaryExpr(p: *Parser) Error!?Result { |
| 9248 | func_qt.printNamed(p.tokSlice(p.func.name), p.comp, &allocating.writer) catch return error.OutOfMemory; | 9248 | func_qt.printNamed(p.tokSlice(p.func.name), p.comp, &allocating.writer) catch return error.OutOfMemory; |
| 9249 | allocating.writer.writeByte(0) catch return error.OutOfMemory; | 9249 | allocating.writer.writeByte(0) catch return error.OutOfMemory; |
| 9250 | 9250 | ||
| 9251 | const predef = try p.makePredefinedIdentifier(allocating.getWritten()); | 9251 | const predef = try p.makePredefinedIdentifier(allocating.written()); |
| 9252 | qt = predef.qt; | 9252 | qt = predef.qt; |
| 9253 | p.func.pretty_ident = predef; | 9253 | p.func.pretty_ident = predef; |
| 9254 | } else { | 9254 | } else { |
lib/compiler/aro/aro/Pragma.zig+1-1| ... | @@ -203,7 +203,7 @@ pub fn err(pp: *Preprocessor, tok_i: TokenIndex, diagnostic: Diagnostic, args: a | ... | @@ -203,7 +203,7 @@ pub fn err(pp: *Preprocessor, tok_i: TokenIndex, diagnostic: Diagnostic, args: a |
| 203 | try pp.diagnostics.addWithLocation(pp.comp, .{ | 203 | try pp.diagnostics.addWithLocation(pp.comp, .{ |
| 204 | .kind = diagnostic.kind, | 204 | .kind = diagnostic.kind, |
| 205 | .opt = diagnostic.opt, | 205 | .opt = diagnostic.opt, |
| 206 | .text = allocating.getWritten(), | 206 | .text = allocating.written(), |
| 207 | .location = pp.tokens.items(.loc)[tok_i].expand(pp.comp), | 207 | .location = pp.tokens.items(.loc)[tok_i].expand(pp.comp), |
| 208 | .extension = diagnostic.extension, | 208 | .extension = diagnostic.extension, |
| 209 | }, pp.expansionSlice(tok_i), true); | 209 | }, pp.expansionSlice(tok_i), true); |
lib/compiler/aro/aro/Preprocessor.zig+8-13| ... | @@ -769,7 +769,7 @@ fn err(pp: *Preprocessor, loc: anytype, diagnostic: Diagnostic, args: anytype) C | ... | @@ -769,7 +769,7 @@ fn err(pp: *Preprocessor, loc: anytype, diagnostic: Diagnostic, args: anytype) C |
| 769 | Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory; | 769 | Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory; |
| 770 | try pp.diagnostics.addWithLocation(pp.comp, .{ | 770 | try pp.diagnostics.addWithLocation(pp.comp, .{ |
| 771 | .kind = diagnostic.kind, | 771 | .kind = diagnostic.kind, |
| 772 | .text = allocating.getWritten(), | 772 | .text = allocating.written(), |
| 773 | .opt = diagnostic.opt, | 773 | .opt = diagnostic.opt, |
| 774 | .extension = diagnostic.extension, | 774 | .extension = diagnostic.extension, |
| 775 | .location = switch (@TypeOf(loc)) { | 775 | .location = switch (@TypeOf(loc)) { |
| ... | @@ -798,7 +798,7 @@ fn fatal(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: anyty | ... | @@ -798,7 +798,7 @@ fn fatal(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: anyty |
| 798 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; | 798 | Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory; |
| 799 | try pp.diagnostics.add(.{ | 799 | try pp.diagnostics.add(.{ |
| 800 | .kind = .@"fatal error", | 800 | .kind = .@"fatal error", |
| 801 | .text = allocating.getWritten(), | 801 | .text = allocating.written(), |
| 802 | .location = (Source.Location{ | 802 | .location = (Source.Location{ |
| 803 | .id = raw.source, | 803 | .id = raw.source, |
| 804 | .byte_offset = raw.start, | 804 | .byte_offset = raw.start, |
| ... | @@ -1618,18 +1618,13 @@ fn handleBuiltinMacro(pp: *Preprocessor, builtin: RawToken.Id, param_toks: []con | ... | @@ -1618,18 +1618,13 @@ fn handleBuiltinMacro(pp: *Preprocessor, builtin: RawToken.Id, param_toks: []con |
| 1618 | else => unreachable, | 1618 | else => unreachable, |
| 1619 | }; | 1619 | }; |
| 1620 | const filename = include_str[1 .. include_str.len - 1]; | 1620 | const filename = include_str[1 .. include_str.len - 1]; |
| 1621 | const res = res: { | 1621 | if (builtin == .macro_param_has_include or pp.include_depth == 0) { |
| 1622 | if (builtin == .macro_param_has_include or pp.include_depth == 0) { | 1622 | if (builtin == .macro_param_has_include_next) { |
| 1623 | if (builtin == .macro_param_has_include_next) { | 1623 | try pp.err(src_loc, .include_next_outside_header, .{}); |
| 1624 | try pp.err(src_loc, .include_next_outside_header, .{}); | ||
| 1625 | } | ||
| 1626 | break :res try pp.comp.hasInclude(filename, src_loc.id, include_type, .first); | ||
| 1627 | } | 1624 | } |
| 1628 | break :res try pp.comp.hasInclude(filename, src_loc.id, include_type, .next); | 1625 | return pp.comp.hasInclude(filename, src_loc.id, include_type, .first, pp.dep_file); |
| 1629 | }; | 1626 | } |
| 1630 | 1627 | return pp.comp.hasInclude(filename, src_loc.id, include_type, .next, pp.dep_file); | |
| 1631 | if (res) if (pp.dep_file) |dep_file| try dep_file.addDependencyDupe(pp.gpa, pp.comp.arena, filename); | ||
| 1632 | return res; | ||
| 1633 | }, | 1628 | }, |
| 1634 | else => unreachable, | 1629 | else => unreachable, |
| 1635 | } | 1630 | } |
lib/compiler/aro/aro/pragmas/message.zig+1-1| ... | @@ -51,7 +51,7 @@ fn preprocessorHandler(_: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pra | ... | @@ -51,7 +51,7 @@ fn preprocessorHandler(_: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pra |
| 51 | Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, .{str}) catch return error.OutOfMemory; | 51 | Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, .{str}) catch return error.OutOfMemory; |
| 52 | 52 | ||
| 53 | try pp.diagnostics.add(.{ | 53 | try pp.diagnostics.add(.{ |
| 54 | .text = allocating.getWritten(), | 54 | .text = allocating.written(), |
| 55 | .kind = diagnostic.kind, | 55 | .kind = diagnostic.kind, |
| 56 | .opt = diagnostic.opt, | 56 | .opt = diagnostic.opt, |
| 57 | .location = loc.expand(pp.comp), | 57 | .location = loc.expand(pp.comp), |
lib/compiler/aro/aro/text_literal.zig+1-1| ... | @@ -328,7 +328,7 @@ pub const Parser = struct { | ... | @@ -328,7 +328,7 @@ pub const Parser = struct { |
| 328 | offset_location.byte_offset += p.offset; | 328 | offset_location.byte_offset += p.offset; |
| 329 | try p.comp.diagnostics.addWithLocation(p.comp, .{ | 329 | try p.comp.diagnostics.addWithLocation(p.comp, .{ |
| 330 | .kind = diagnostic.kind, | 330 | .kind = diagnostic.kind, |
| 331 | .text = allocating.getWritten(), | 331 | .text = allocating.written(), |
| 332 | .opt = diagnostic.opt, | 332 | .opt = diagnostic.opt, |
| 333 | .extension = diagnostic.extension, | 333 | .extension = diagnostic.extension, |
| 334 | .location = offset_location.expand(p.comp), | 334 | .location = offset_location.expand(p.comp), |
lib/compiler/translate-c/Translator.zig+5-5| ... | @@ -1005,7 +1005,7 @@ fn transStaticAssert(t: *Translator, scope: *Scope, static_assert: Node.StaticAs | ... | @@ -1005,7 +1005,7 @@ fn transStaticAssert(t: *Translator, scope: *Scope, static_assert: Node.StaticAs |
| 1005 | allocating.writer.end -= 1; // printString adds a terminating " so we need to remove it | 1005 | allocating.writer.end -= 1; // printString adds a terminating " so we need to remove it |
| 1006 | allocating.writer.writeAll("\\\"\"") catch return error.OutOfMemory; | 1006 | allocating.writer.writeAll("\\\"\"") catch return error.OutOfMemory; |
| 1007 | 1007 | ||
| 1008 | break :str try ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.getWritten())); | 1008 | break :str try ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.written())); |
| 1009 | } else try ZigTag.string_literal.create(t.arena, "\"static assertion failed\""); | 1009 | } else try ZigTag.string_literal.create(t.arena, "\"static assertion failed\""); |
| 1010 | 1010 | ||
| 1011 | const assert_node = try ZigTag.static_assert.create(t.arena, .{ .lhs = condition, .rhs = diagnostic }); | 1011 | const assert_node = try ZigTag.static_assert.create(t.arena, .{ .lhs = condition, .rhs = diagnostic }); |
| ... | @@ -1020,7 +1020,7 @@ fn transGlobalAsm(t: *Translator, scope: *Scope, global_asm: Node.SimpleAsm) Err | ... | @@ -1020,7 +1020,7 @@ fn transGlobalAsm(t: *Translator, scope: *Scope, global_asm: Node.SimpleAsm) Err |
| 1020 | defer allocating.deinit(); | 1020 | defer allocating.deinit(); |
| 1021 | aro.Value.printString(bytes, global_asm.asm_str.qt(t.tree), t.comp, &allocating.writer) catch return error.OutOfMemory; | 1021 | aro.Value.printString(bytes, global_asm.asm_str.qt(t.tree), t.comp, &allocating.writer) catch return error.OutOfMemory; |
| 1022 | 1022 | ||
| 1023 | const str_node = try ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.getWritten())); | 1023 | const str_node = try ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.written())); |
| 1024 | 1024 | ||
| 1025 | const asm_node = try ZigTag.asm_simple.create(t.arena, str_node); | 1025 | const asm_node = try ZigTag.asm_simple.create(t.arena, str_node); |
| 1026 | const block = try ZigTag.block_single.create(t.arena, asm_node); | 1026 | const block = try ZigTag.block_single.create(t.arena, asm_node); |
| ... | @@ -1037,7 +1037,7 @@ fn getTypeStr(t: *Translator, qt: QualType) ![]const u8 { | ... | @@ -1037,7 +1037,7 @@ fn getTypeStr(t: *Translator, qt: QualType) ![]const u8 { |
| 1037 | var allocating: std.Io.Writer.Allocating = .init(t.gpa); | 1037 | var allocating: std.Io.Writer.Allocating = .init(t.gpa); |
| 1038 | defer allocating.deinit(); | 1038 | defer allocating.deinit(); |
| 1039 | qt.print(t.comp, &allocating.writer) catch return error.OutOfMemory; | 1039 | qt.print(t.comp, &allocating.writer) catch return error.OutOfMemory; |
| 1040 | return t.arena.dupe(u8, allocating.getWritten()); | 1040 | return t.arena.dupe(u8, allocating.written()); |
| 1041 | } | 1041 | } |
| 1042 | 1042 | ||
| 1043 | fn transType(t: *Translator, scope: *Scope, qt: QualType, source_loc: TokenIndex) TypeError!ZigNode { | 1043 | fn transType(t: *Translator, scope: *Scope, qt: QualType, source_loc: TokenIndex) TypeError!ZigNode { |
| ... | @@ -3345,7 +3345,7 @@ fn transFloatLiteral( | ... | @@ -3345,7 +3345,7 @@ fn transFloatLiteral( |
| 3345 | defer allocating.deinit(); | 3345 | defer allocating.deinit(); |
| 3346 | _ = val.print(float_literal.qt, t.comp, &allocating.writer) catch return error.OutOfMemory; | 3346 | _ = val.print(float_literal.qt, t.comp, &allocating.writer) catch return error.OutOfMemory; |
| 3347 | 3347 | ||
| 3348 | const float_lit_node = try ZigTag.float_literal.create(t.arena, try t.arena.dupe(u8, allocating.getWritten())); | 3348 | const float_lit_node = try ZigTag.float_literal.create(t.arena, try t.arena.dupe(u8, allocating.written())); |
| 3349 | if (suppress_as == .no_as) { | 3349 | if (suppress_as == .no_as) { |
| 3350 | return t.maybeSuppressResult(used, float_lit_node); | 3350 | return t.maybeSuppressResult(used, float_lit_node); |
| 3351 | } | 3351 | } |
| ... | @@ -3390,7 +3390,7 @@ fn transNarrowStringLiteral( | ... | @@ -3390,7 +3390,7 @@ fn transNarrowStringLiteral( |
| 3390 | 3390 | ||
| 3391 | aro.Value.printString(bytes, literal.qt, t.comp, &allocating.writer) catch return error.OutOfMemory; | 3391 | aro.Value.printString(bytes, literal.qt, t.comp, &allocating.writer) catch return error.OutOfMemory; |
| 3392 | 3392 | ||
| 3393 | return ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.getWritten())); | 3393 | return ZigTag.string_literal.create(t.arena, try t.arena.dupe(u8, allocating.written())); |
| 3394 | } | 3394 | } |
| 3395 | 3395 | ||
| 3396 | /// Translate a string literal that is initializing an array. In general narrow string | 3396 | /// Translate a string literal that is initializing an array. In general narrow string |
lib/compiler/translate-c/main.zig+5-1| ... | @@ -145,7 +145,11 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8) !void { | ... | @@ -145,7 +145,11 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8) !void { |
| 145 | defer pp.deinit(); | 145 | defer pp.deinit(); |
| 146 | 146 | ||
| 147 | var name_buf: [std.fs.max_name_bytes]u8 = undefined; | 147 | var name_buf: [std.fs.max_name_bytes]u8 = undefined; |
| 148 | var opt_dep_file = try d.initDepFile(source, &name_buf); | 148 | // Omit the source file from the dep file so that it can be tracked separately. |
| 149 | // In the Zig compiler we want to omit it from the cache hash since it will | ||
| 150 | // be written to a tmp file then renamed into place, meaning the path will be | ||
| 151 | // wrong as soon as the work is done. | ||
| 152 | var opt_dep_file = try d.initDepFile(source, &name_buf, true); | ||
| 149 | defer if (opt_dep_file) |*dep_file| dep_file.deinit(pp.gpa); | 153 | defer if (opt_dep_file) |*dep_file| dep_file.deinit(pp.gpa); |
| 150 | 154 | ||
| 151 | if (opt_dep_file) |*dep_file| pp.dep_file = dep_file; | 155 | if (opt_dep_file) |*dep_file| pp.dep_file = dep_file; |