authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-03-17 19:12:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:34-07:00
loge436d9c4ad623d8facefb8e1637b26e63e900277
tree9b3ef08620cd9392b91f68c8958a4ef429880bd1
parentc6d37f389591e722f59ca7f2b719ec8cfc0a9984

configurer: back out the string interning from prev commit

partial revert of 2d3fbb687fba1ed52b42998ac4dcbf2a042644ea - see its commit message for reasoning

2 files changed, 8 insertions(+), 14 deletions(-)

lib/std/Build.zig+7-13
...@@ -122,22 +122,16 @@ pub const Graph = struct {...@@ -122,22 +122,16 @@ pub const Graph = struct {
122 return @enumFromInt(graph.generated_files.items.len - 1);122 return @enumFromInt(graph.generated_files.items.len - 1);
123 }123 }
124124
125 pub fn dupeString(graph: *Graph, bytes: []const u8) [:0]const u8 {125 pub fn dupeString(graph: *Graph, bytes: []const u8) []const u8 {
126 // This code assumes the `Configuration.Wip` uses arena allocation such126 return graph.arena.dupe(u8, bytes) catch @panic("OOM");
127 // that references to string_bytes never die even when the ArrayList is
128 // reallocated.
129 const wc = &graph.wip_configuration;
130 const i = wc.addString(bytes) catch @panic("OOM");
131 return wc.string_bytes.items[@intFromEnum(i)..][0..bytes.len :0];
132 }127 }
133128
134 pub fn dupePath(graph: *Graph, bytes: []const u8) [:0]const u8 {129 pub fn dupePath(graph: *Graph, bytes: []const u8) []const u8 {
135 if (builtin.os.tag != .windows) return dupeString(graph, bytes);
136 const arena = graph.arena;130 const arena = graph.arena;
131 if (builtin.os.tag != .windows) return graph.arena.dupe(u8, bytes) catch @panic("OOM");
137 const the_copy = arena.dupe(u8, bytes) catch @panic("OOM");132 const the_copy = arena.dupe(u8, bytes) catch @panic("OOM");
138 defer arena.free(the_copy);
139 mem.replaceScalar(u8, the_copy, '/', '\\');133 mem.replaceScalar(u8, the_copy, '/', '\\');
140 return dupeString(graph, the_copy);134 return the_copy;
141 }135 }
142136
143 pub fn dupeStrings(graph: *Graph, strings: []const []const u8) []const []const u8 {137 pub fn dupeStrings(graph: *Graph, strings: []const []const u8) []const []const u8 {
...@@ -895,7 +889,7 @@ pub fn addConfigHeader(...@@ -895,7 +889,7 @@ pub fn addConfigHeader(
895 return config_header_step;889 return config_header_step;
896}890}
897891
898pub fn dupe(b: *Build, bytes: []const u8) [:0]const u8 {892pub fn dupe(b: *Build, bytes: []const u8) []const u8 {
899 return b.graph.dupeString(bytes);893 return b.graph.dupeString(bytes);
900}894}
901895
...@@ -905,7 +899,7 @@ pub fn dupeStrings(b: *Build, strings: []const []const u8) []const []const u8 {...@@ -905,7 +899,7 @@ pub fn dupeStrings(b: *Build, strings: []const []const u8) []const []const u8 {
905}899}
906900
907/// Duplicates a path, canonicalizing path separators.901/// Duplicates a path, canonicalizing path separators.
908pub fn dupePath(b: *Build, bytes: []const u8) [:0]const u8 {902pub fn dupePath(b: *Build, bytes: []const u8) []const u8 {
909 return b.graph.dupePath(bytes);903 return b.graph.dupePath(bytes);
910}904}
911905
lib/std/Build/Step/Run.zig+1-1
...@@ -139,7 +139,7 @@ pub const Arg = union(enum) {...@@ -139,7 +139,7 @@ pub const Arg = union(enum) {
139 lazy_path: PrefixedLazyPath,139 lazy_path: PrefixedLazyPath,
140 decorated_directory: DecoratedLazyPath,140 decorated_directory: DecoratedLazyPath,
141 file_content: PrefixedLazyPath,141 file_content: PrefixedLazyPath,
142 bytes: [:0]const u8,142 bytes: []const u8,
143 output_file: *Output,143 output_file: *Output,
144 output_directory: *Output,144 output_directory: *Output,
145 /// The arguments passed after "--" on the "zig build" CLI.145 /// The arguments passed after "--" on the "zig build" CLI.