| author | |
| committer | |
| log | 0959167e8161b5b19c1ad836aa35778dc9357c17 |
| tree | 1d9fc9ef028f72ebdbacad6b9549fbd356b52053 |
| parent | 34d3bcb353ef34b3e87b12d6d3acd09110ea6d51 |
11 files changed, 136 insertions(+), 165 deletions(-)
lib/compiler/Maker.zig+23-32| ... | @@ -21,7 +21,6 @@ const process = std.process; | ... | @@ -21,7 +21,6 @@ const process = std.process; |
| 21 | const Color = std.zig.Color; | 21 | const Color = std.zig.Color; |
| 22 | const EnvVar = std.zig.EnvVar; | 22 | const EnvVar = std.zig.EnvVar; |
| 23 | const default_local_zig_cache_basename = std.zig.default_local_zig_cache_basename; | 23 | const default_local_zig_cache_basename = std.zig.default_local_zig_cache_basename; |
| 24 | const allocPrint = std.fmt.allocPrint; | ||
| 25 | const stringToEnum = std.meta.stringToEnum; | 24 | const stringToEnum = std.meta.stringToEnum; |
| 26 | 25 | ||
| 27 | const Fuzz = @import("Maker/Fuzz.zig"); | 26 | const Fuzz = @import("Maker/Fuzz.zig"); |
| ... | @@ -125,10 +124,10 @@ pub const CliModule = struct { | ... | @@ -125,10 +124,10 @@ pub const CliModule = struct { |
| 125 | if (mem.eql(u8, name, dep.name)) { | 124 | if (mem.eql(u8, name, dep.name)) { |
| 126 | argv.appendAssumeCapacity(dep.name); | 125 | argv.appendAssumeCapacity(dep.name); |
| 127 | } else { | 126 | } else { |
| 128 | argv.appendAssumeCapacity(try allocPrint(arena, "{s}={s}", .{ name, dep.name })); | 127 | argv.appendAssumeCapacity(try arena.print("{s}={s}", .{ name, dep.name })); |
| 129 | } | 128 | } |
| 130 | } | 129 | } |
| 131 | argv.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ cm.name, cm.root_path })); | 130 | argv.appendAssumeCapacity(try arena.print("-M{s}={s}", .{ cm.name, cm.root_path })); |
| 132 | } | 131 | } |
| 133 | }; | 132 | }; |
| 134 | 133 | ||
| ... | @@ -278,7 +277,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -278,7 +277,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 278 | fatalWithHint("expected [auto|on|off] found {q}", .{next_arg}); | 277 | fatalWithHint("expected [auto|on|off] found {q}", .{next_arg}); |
| 279 | 278 | ||
| 280 | try cached_passthru_configure.append(arena, @intCast(configure_argv.items.len)); | 279 | try cached_passthru_configure.append(arena, @intCast(configure_argv.items.len)); |
| 281 | configure_argv.appendAssumeCapacity(try allocPrint(arena, "--color={t}", .{color})); | 280 | configure_argv.appendAssumeCapacity(try arena.print("--color={t}", .{color})); |
| 282 | } else if (mem.eql(u8, arg, "--cache-poison")) { | 281 | } else if (mem.eql(u8, arg, "--cache-poison")) { |
| 283 | cache_poison = .poisoned; | 282 | cache_poison = .poisoned; |
| 284 | configure_argv.appendAssumeCapacity("--cache-poison=poisoned"); | 283 | configure_argv.appendAssumeCapacity("--cache-poison=poisoned"); |
| ... | @@ -965,7 +964,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -965,7 +964,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 965 | try build_configurer_argv.appendSlice(gpa, &.{ "--libc", libc_file }); | 964 | try build_configurer_argv.appendSlice(gpa, &.{ "--libc", libc_file }); |
| 966 | } | 965 | } |
| 967 | if (graph.reference_trace) |n| { | 966 | if (graph.reference_trace) |n| { |
| 968 | try build_configurer_argv.append(gpa, try allocPrint(arena, "-freference-trace={d}", .{n})); | 967 | try build_configurer_argv.append(gpa, try arena.print("-freference-trace={d}", .{n})); |
| 969 | } | 968 | } |
| 970 | if (graph.debug_compile_errors) { | 969 | if (graph.debug_compile_errors) { |
| 971 | try build_configurer_argv.append(gpa, "--debug-compile-errors"); | 970 | try build_configurer_argv.append(gpa, "--debug-compile-errors"); |
| ... | @@ -973,7 +972,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -973,7 +972,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 973 | try build_configurer_argv.appendSlice(gpa, &.{ | 972 | try build_configurer_argv.appendSlice(gpa, &.{ |
| 974 | "--dep", "@build", // | 973 | "--dep", "@build", // |
| 975 | "--dep", "@dependencies", // | 974 | "--dep", "@dependencies", // |
| 976 | try allocPrint(arena, "-Mroot={f}", .{configurer_root_src_path}), // | 975 | try arena.print("-Mroot={f}", .{configurer_root_src_path}), // |
| 977 | }); | 976 | }); |
| 978 | 977 | ||
| 979 | // In the loop below, after doing the fetch operation, the argv will be | 978 | // In the loop below, after doing the fetch operation, the argv will be |
| ... | @@ -1126,7 +1125,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1126,7 +1125,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1126 | const hex_digest = hh.final(); | 1125 | const hex_digest = hh.final(); |
| 1127 | const dependencies_zig_path: Path = .{ | 1126 | const dependencies_zig_path: Path = .{ |
| 1128 | .root_dir = graph.local_cache_root, | 1127 | .root_dir = graph.local_cache_root, |
| 1129 | .sub_path = try allocPrint(arena, "o/{s}/dependencies.zig", .{&hex_digest}), | 1128 | .sub_path = try arena.print("o/{s}/dependencies.zig", .{&hex_digest}), |
| 1130 | }; | 1129 | }; |
| 1131 | var atomic_file = try dependencies_zig_path.root_dir.handle.createFileAtomic( | 1130 | var atomic_file = try dependencies_zig_path.root_dir.handle.createFileAtomic( |
| 1132 | io, | 1131 | io, |
| ... | @@ -1195,12 +1194,12 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1195,12 +1194,12 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1195 | if (mem.eql(u8, name, sub.name)) { | 1194 | if (mem.eql(u8, name, sub.name)) { |
| 1196 | build_configurer_argv.appendAssumeCapacity(sub.name); | 1195 | build_configurer_argv.appendAssumeCapacity(sub.name); |
| 1197 | } else { | 1196 | } else { |
| 1198 | build_configurer_argv.appendAssumeCapacity(try allocPrint(arena, "{s}={s}", .{ | 1197 | build_configurer_argv.appendAssumeCapacity(try arena.print("{s}={s}", .{ |
| 1199 | name, sub.name, | 1198 | name, sub.name, |
| 1200 | })); | 1199 | })); |
| 1201 | } | 1200 | } |
| 1202 | } | 1201 | } |
| 1203 | build_configurer_argv.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}/{s}", .{ | 1202 | build_configurer_argv.appendAssumeCapacity(try arena.print("-M{s}={s}/{s}", .{ |
| 1204 | dep.name, dep.root_path, std.zig.build_zig_basename, | 1203 | dep.name, dep.root_path, std.zig.build_zig_basename, |
| 1205 | })); | 1204 | })); |
| 1206 | } | 1205 | } |
| ... | @@ -1219,7 +1218,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1219,7 +1218,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1219 | break :cp .{ | 1218 | break :cp .{ |
| 1220 | .{ | 1219 | .{ |
| 1221 | .root_dir = graph.local_cache_root, | 1220 | .root_dir = graph.local_cache_root, |
| 1222 | .sub_path = try allocPrint(arena, "c/{s}", .{&digest}), | 1221 | .sub_path = try arena.print("c/{s}", .{&digest}), |
| 1223 | }, | 1222 | }, |
| 1224 | false, | 1223 | false, |
| 1225 | }; | 1224 | }; |
| ... | @@ -1326,7 +1325,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1326,7 +1325,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1326 | const digest = config_man.final(); | 1325 | const digest = config_man.final(); |
| 1327 | const final_path: Path = .{ | 1326 | const final_path: Path = .{ |
| 1328 | .root_dir = graph.local_cache_root, | 1327 | .root_dir = graph.local_cache_root, |
| 1329 | .sub_path = try allocPrint(arena, "c/{s}", .{&digest}), | 1328 | .sub_path = try arena.print("c/{s}", .{&digest}), |
| 1330 | }; | 1329 | }; |
| 1331 | Io.Dir.rename( | 1330 | Io.Dir.rename( |
| 1332 | config_tmp_path.root_dir.handle, | 1331 | config_tmp_path.root_dir.handle, |
| ... | @@ -1597,7 +1596,7 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1597,7 +1596,7 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1597 | var saved_path_or_url = path_or_url; | 1596 | var saved_path_or_url = path_or_url; |
| 1598 | 1597 | ||
| 1599 | if (fetch.latest_commit) |latest_commit| resolved: { | 1598 | if (fetch.latest_commit) |latest_commit| resolved: { |
| 1600 | const latest_commit_hex = try allocPrint(arena, "{f}", .{latest_commit}); | 1599 | const latest_commit_hex = try arena.print("{f}", .{latest_commit}); |
| 1601 | 1600 | ||
| 1602 | var uri = try std.Uri.parse(path_or_url); | 1601 | var uri = try std.Uri.parse(path_or_url); |
| 1603 | 1602 | ||
| ... | @@ -1610,7 +1609,7 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1610,7 +1609,7 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1610 | log.info("resolved ref {q} to commit {s}", .{ target_ref, latest_commit_hex }); | 1609 | log.info("resolved ref {q} to commit {s}", .{ target_ref, latest_commit_hex }); |
| 1611 | 1610 | ||
| 1612 | // include the original refspec in a query parameter, could be used to check for updates | 1611 | // include the original refspec in a query parameter, could be used to check for updates |
| 1613 | uri.query = .{ .percent_encoded = try allocPrint(arena, "ref={f}", .{ | 1612 | uri.query = .{ .percent_encoded = try arena.print("ref={f}", .{ |
| 1614 | std.fmt.alt(fragment, .formatEscaped), | 1613 | std.fmt.alt(fragment, .formatEscaped), |
| 1615 | }) }; | 1614 | }) }; |
| 1616 | } else { | 1615 | } else { |
| ... | @@ -1621,12 +1620,12 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1621,12 +1620,12 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1621 | uri.fragment = .{ .raw = latest_commit_hex }; | 1620 | uri.fragment = .{ .raw = latest_commit_hex }; |
| 1622 | 1621 | ||
| 1623 | switch (save) { | 1622 | switch (save) { |
| 1624 | .yes => saved_path_or_url = try allocPrint(arena, "{f}", .{uri}), | 1623 | .yes => saved_path_or_url = try arena.print("{f}", .{uri}), |
| 1625 | .no, .exact => {}, // keep the original URL | 1624 | .no, .exact => {}, // keep the original URL |
| 1626 | } | 1625 | } |
| 1627 | } | 1626 | } |
| 1628 | 1627 | ||
| 1629 | const new_node_init = try allocPrint(arena, | 1628 | const new_node_init = try arena.print( |
| 1630 | \\.{{ | 1629 | \\.{{ |
| 1631 | \\ .url = "{f}", | 1630 | \\ .url = "{f}", |
| 1632 | \\ .hash = "{f}", | 1631 | \\ .hash = "{f}", |
| ... | @@ -1636,15 +1635,15 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1636,15 +1635,15 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1636 | std.zig.fmtString(package_hash_slice), | 1635 | std.zig.fmtString(package_hash_slice), |
| 1637 | }); | 1636 | }); |
| 1638 | 1637 | ||
| 1639 | const new_node_text = try allocPrint(arena, ".{f} = {s},\n", .{ | 1638 | const new_node_text = try arena.print(".{f} = {s},\n", .{ |
| 1640 | std.zig.fmtIdPU(name), new_node_init, | 1639 | std.zig.fmtIdPU(name), new_node_init, |
| 1641 | }); | 1640 | }); |
| 1642 | 1641 | ||
| 1643 | const dependencies_init = try allocPrint(arena, ".{{\n {s} }}", .{ | 1642 | const dependencies_init = try arena.print(".{{\n {s} }}", .{ |
| 1644 | new_node_text, | 1643 | new_node_text, |
| 1645 | }); | 1644 | }); |
| 1646 | 1645 | ||
| 1647 | const dependencies_text = try allocPrint(arena, ".dependencies = {s},\n", .{ | 1646 | const dependencies_text = try arena.print(".dependencies = {s},\n", .{ |
| 1648 | dependencies_init, | 1647 | dependencies_init, |
| 1649 | }); | 1648 | }); |
| 1650 | 1649 | ||
| ... | @@ -1661,16 +1660,8 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1661,16 +1660,8 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1661 | } | 1660 | } |
| 1662 | } | 1661 | } |
| 1663 | 1662 | ||
| 1664 | const location_replace = try allocPrint( | 1663 | const location_replace = try arena.print("{q}", .{saved_path_or_url}); |
| 1665 | arena, | 1664 | const hash_replace = try arena.print("{q}", .{package_hash_slice}); |
| 1666 | "\"{f}\"", | ||
| 1667 | .{std.zig.fmtString(saved_path_or_url)}, | ||
| 1668 | ); | ||
| 1669 | const hash_replace = try allocPrint( | ||
| 1670 | arena, | ||
| 1671 | "\"{f}\"", | ||
| 1672 | .{std.zig.fmtString(package_hash_slice)}, | ||
| 1673 | ); | ||
| 1674 | 1665 | ||
| 1675 | log.warn("overwriting existing dependency named {q}", .{name}); | 1666 | log.warn("overwriting existing dependency named {q}", .{name}); |
| 1676 | try fixups.replace_nodes_with_string.put(gpa, dep.location_node, location_replace); | 1667 | try fixups.replace_nodes_with_string.put(gpa, dep.location_node, location_replace); |
| ... | @@ -3272,11 +3263,11 @@ pub fn installSymLinks( | ... | @@ -3272,11 +3263,11 @@ pub fn installSymLinks( |
| 3272 | const name = conf_comp.root_name.slice(c); | 3263 | const name = conf_comp.root_name.slice(c); |
| 3273 | 3264 | ||
| 3274 | const filename_major_only, const filename_name_only = if (os_tag.isDarwin()) .{ | 3265 | const filename_major_only, const filename_name_only = if (os_tag.isDarwin()) .{ |
| 3275 | try allocPrint(arena, "lib{s}.{d}.dylib", .{ name, version.major }), | 3266 | try arena.print("lib{s}.{d}.dylib", .{ name, version.major }), |
| 3276 | try allocPrint(arena, "lib{s}.dylib", .{name}), | 3267 | try arena.print("lib{s}.dylib", .{name}), |
| 3277 | } else .{ | 3268 | } else .{ |
| 3278 | try allocPrint(arena, "lib{s}.so.{d}", .{ name, version.major }), | 3269 | try arena.print("lib{s}.so.{d}", .{ name, version.major }), |
| 3279 | try allocPrint(arena, "lib{s}.so", .{name}), | 3270 | try arena.print("lib{s}.so", .{name}), |
| 3280 | }; | 3271 | }; |
| 3281 | 3272 | ||
| 3282 | return installSymLinksInner(maker, arena, output_path, asking_step_index, filename_major_only, filename_name_only); | 3273 | return installSymLinksInner(maker, arena, output_path, asking_step_index, filename_major_only, filename_name_only); |
lib/compiler/Maker/Step/Compile.zig+27-34| ... | @@ -10,7 +10,6 @@ const Module = std.Build.Configuration.Module; | ... | @@ -10,7 +10,6 @@ const Module = std.Build.Configuration.Module; |
| 10 | const Io = std.Io; | 10 | const Io = std.Io; |
| 11 | const Sha256 = std.crypto.hash.sha2.Sha256; | 11 | const Sha256 = std.crypto.hash.sha2.Sha256; |
| 12 | const assert = std.debug.assert; | 12 | const assert = std.debug.assert; |
| 13 | const allocPrint = std.fmt.allocPrint; | ||
| 14 | 13 | ||
| 15 | const Step = @import("../Step.zig"); | 14 | const Step = @import("../Step.zig"); |
| 16 | const Maker = @import("../../Maker.zig"); | 15 | const Maker = @import("../../Maker.zig"); |
| ... | @@ -179,7 +178,7 @@ fn lowerZigArgs( | ... | @@ -179,7 +178,7 @@ fn lowerZigArgs( |
| 179 | try zig_args.append(gpa, cmd); | 178 | try zig_args.append(gpa, cmd); |
| 180 | 179 | ||
| 181 | if (graph.reference_trace) |some| { | 180 | if (graph.reference_trace) |some| { |
| 182 | try zig_args.append(gpa, try allocPrint(arena, "-freference-trace={d}", .{some})); | 181 | try zig_args.append(gpa, try arena.print("-freference-trace={d}", .{some})); |
| 183 | } | 182 | } |
| 184 | try addFlag(gpa, zig_args, "allow-so-scripts", conf_comp.flags2.allow_so_scripts.toBool() orelse graph.allow_so_scripts); | 183 | try addFlag(gpa, zig_args, "allow-so-scripts", conf_comp.flags2.allow_so_scripts.toBool() orelse graph.allow_so_scripts); |
| 185 | 184 | ||
| ... | @@ -191,7 +190,7 @@ fn lowerZigArgs( | ... | @@ -191,7 +190,7 @@ fn lowerZigArgs( |
| 191 | 190 | ||
| 192 | if (root_module.resolved_target.get(conf).?.query.unwrap()) |query| { | 191 | if (root_module.resolved_target.get(conf).?.query.unwrap()) |query| { |
| 193 | if (query.get(conf).flags.object_format.unwrap()) |ofmt| { | 192 | if (query.get(conf).flags.object_format.unwrap()) |ofmt| { |
| 194 | try zig_args.append(gpa, try allocPrint(arena, "-ofmt={t}", .{ofmt})); | 193 | try zig_args.append(gpa, try arena.print("-ofmt={t}", .{ofmt})); |
| 195 | } | 194 | } |
| 196 | } | 195 | } |
| 197 | 196 | ||
| ... | @@ -201,7 +200,7 @@ fn lowerZigArgs( | ... | @@ -201,7 +200,7 @@ fn lowerZigArgs( |
| 201 | .enabled => try zig_args.append(gpa, "-fentry"), | 200 | .enabled => try zig_args.append(gpa, "-fentry"), |
| 202 | .symbol_name => { | 201 | .symbol_name => { |
| 203 | const symbol_name = conf_comp.entry.value.?.slice(conf); | 202 | const symbol_name = conf_comp.entry.value.?.slice(conf); |
| 204 | try zig_args.append(gpa, try allocPrint(arena, "-fentry={s}", .{symbol_name})); | 203 | try zig_args.append(gpa, try arena.print("-fentry={s}", .{symbol_name})); |
| 205 | }, | 204 | }, |
| 206 | } | 205 | } |
| 207 | 206 | ||
| ... | @@ -210,7 +209,7 @@ fn lowerZigArgs( | ... | @@ -210,7 +209,7 @@ fn lowerZigArgs( |
| 210 | } | 209 | } |
| 211 | 210 | ||
| 212 | if (conf_comp.stack_size.value) |stack_size| { | 211 | if (conf_comp.stack_size.value) |stack_size| { |
| 213 | try zig_args.appendSlice(gpa, &.{ "--stack", try allocPrint(arena, "{d}", .{stack_size}) }); | 212 | try zig_args.appendSlice(gpa, &.{ "--stack", try arena.print("{d}", .{stack_size}) }); |
| 214 | } | 213 | } |
| 215 | 214 | ||
| 216 | try addBool(gpa, zig_args, "-ffuzz", fuzz); | 215 | try addBool(gpa, zig_args, "-ffuzz", fuzz); |
| ... | @@ -346,7 +345,7 @@ fn lowerZigArgs( | ... | @@ -346,7 +345,7 @@ fn lowerZigArgs( |
| 346 | else => |e| return e, | 345 | else => |e| return e, |
| 347 | } | 346 | } |
| 348 | } | 347 | } |
| 349 | try zig_args.append(gpa, try allocPrint(arena, "{s}{s}", .{ | 348 | try zig_args.append(gpa, try arena.print("{s}{s}", .{ |
| 350 | prefix, system_lib_name, | 349 | prefix, system_lib_name, |
| 351 | })); | 350 | })); |
| 352 | } | 351 | } |
| ... | @@ -526,7 +525,7 @@ fn lowerZigArgs( | ... | @@ -526,7 +525,7 @@ fn lowerZigArgs( |
| 526 | if (mem.eql(u8, import_cli_name, name_slice)) { | 525 | if (mem.eql(u8, import_cli_name, name_slice)) { |
| 527 | zig_args.appendAssumeCapacity(import_cli_name); | 526 | zig_args.appendAssumeCapacity(import_cli_name); |
| 528 | } else { | 527 | } else { |
| 529 | zig_args.appendAssumeCapacity(try allocPrint(arena, "{s}={s}", .{ | 528 | zig_args.appendAssumeCapacity(try arena.print("{s}={s}", .{ |
| 530 | name_slice, import_cli_name, | 529 | name_slice, import_cli_name, |
| 531 | })); | 530 | })); |
| 532 | } | 531 | } |
| ... | @@ -542,9 +541,9 @@ fn lowerZigArgs( | ... | @@ -542,9 +541,9 @@ fn lowerZigArgs( |
| 542 | try zig_args.ensureUnusedCapacity(gpa, 1); | 541 | try zig_args.ensureUnusedCapacity(gpa, 1); |
| 543 | if (mod.root_source_file.unwrap()) |lp| { | 542 | if (mod.root_source_file.unwrap()) |lp| { |
| 544 | const src = try maker.resolveLazyPathIndexAbs(arena, lp, compile_index); | 543 | const src = try maker.resolveLazyPathIndexAbs(arena, lp, compile_index); |
| 545 | zig_args.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ module_cli_name, src })); | 544 | zig_args.appendAssumeCapacity(try arena.print("-M{s}={s}", .{ module_cli_name, src })); |
| 546 | } else if (moduleNeedsCliArg(&mod, conf)) { | 545 | } else if (moduleNeedsCliArg(&mod, conf)) { |
| 547 | zig_args.appendAssumeCapacity(try allocPrint(arena, "-M{s}", .{module_cli_name})); | 546 | zig_args.appendAssumeCapacity(try arena.print("-M{s}", .{module_cli_name})); |
| 548 | } | 547 | } |
| 549 | } | 548 | } |
| 550 | } | 549 | } |
| ... | @@ -583,7 +582,7 @@ fn lowerZigArgs( | ... | @@ -583,7 +582,7 @@ fn lowerZigArgs( |
| 583 | 582 | ||
| 584 | if (conf_comp.image_base.value) |image_base| { | 583 | if (conf_comp.image_base.value) |image_base| { |
| 585 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 584 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 586 | "--image-base", try allocPrint(arena, "0x{x}", .{image_base}), | 585 | "--image-base", try arena.print("0x{x}", .{image_base}), |
| 587 | }; | 586 | }; |
| 588 | } | 587 | } |
| 589 | 588 | ||
| ... | @@ -643,10 +642,10 @@ fn lowerZigArgs( | ... | @@ -643,10 +642,10 @@ fn lowerZigArgs( |
| 643 | if (!conf_comp.flags.link_z_relro) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "norelro" }; | 642 | if (!conf_comp.flags.link_z_relro) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "norelro" }; |
| 644 | if (conf_comp.flags.link_z_lazy) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "lazy" }; | 643 | if (conf_comp.flags.link_z_lazy) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "lazy" }; |
| 645 | if (conf_comp.link_z_common_page_size.value) |size| (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 644 | if (conf_comp.link_z_common_page_size.value) |size| (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 646 | "-z", try allocPrint(arena, "common-page-size={d}", .{size}), | 645 | "-z", try arena.print("common-page-size={d}", .{size}), |
| 647 | }; | 646 | }; |
| 648 | if (conf_comp.link_z_max_page_size.value) |size| (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 647 | if (conf_comp.link_z_max_page_size.value) |size| (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 649 | "-z", try allocPrint(arena, "max-page-size={d}", .{size}), | 648 | "-z", try arena.print("max-page-size={d}", .{size}), |
| 650 | }; | 649 | }; |
| 651 | if (conf_comp.flags.link_z_defs) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "defs" }; | 650 | if (conf_comp.flags.link_z_defs) (try zig_args.addManyAsArray(gpa, 2)).* = .{ "-z", "defs" }; |
| 652 | 651 | ||
| ... | @@ -667,7 +666,7 @@ fn lowerZigArgs( | ... | @@ -667,7 +666,7 @@ fn lowerZigArgs( |
| 667 | try zig_args.ensureUnusedCapacity(gpa, 1); | 666 | try zig_args.ensureUnusedCapacity(gpa, 1); |
| 668 | if (graph.debug_compiler_runtime_libs) |mode| switch (mode) { | 667 | if (graph.debug_compiler_runtime_libs) |mode| switch (mode) { |
| 669 | .Debug => zig_args.appendAssumeCapacity("--debug-rt"), | 668 | .Debug => zig_args.appendAssumeCapacity("--debug-rt"), |
| 670 | else => zig_args.appendAssumeCapacity(try allocPrint(arena, "--debug-rt={t}", .{mode})), | 669 | else => zig_args.appendAssumeCapacity(try arena.print("--debug-rt={t}", .{mode})), |
| 671 | }; | 670 | }; |
| 672 | 671 | ||
| 673 | { | 672 | { |
| ... | @@ -691,15 +690,9 @@ fn lowerZigArgs( | ... | @@ -691,15 +690,9 @@ fn lowerZigArgs( |
| 691 | const abi = root_module_target.flags.abi.unwrap().?; | 690 | const abi = root_module_target.flags.abi.unwrap().?; |
| 692 | zig_args.addManyAsArrayAssumeCapacity(2).* = .{ | 691 | zig_args.addManyAsArrayAssumeCapacity(2).* = .{ |
| 693 | "-install_name", | 692 | "-install_name", |
| 694 | if (conf_comp.install_name.value) |s| s.slice(conf) else try allocPrint( | 693 | if (conf_comp.install_name.value) |s| s.slice(conf) else try arena.print("@rpath/{s}{s}{s}", .{ |
| 695 | arena, | 694 | os_tag.libPrefix(abi), conf_comp.root_name.slice(conf), os_tag.dynamicLibSuffix(), |
| 696 | "@rpath/{s}{s}{s}", | 695 | }), |
| 697 | .{ | ||
| 698 | os_tag.libPrefix(abi), | ||
| 699 | conf_comp.root_name.slice(conf), | ||
| 700 | os_tag.dynamicLibSuffix(), | ||
| 701 | }, | ||
| 702 | ), | ||
| 703 | }; | 696 | }; |
| 704 | } | 697 | } |
| 705 | } | 698 | } |
| ... | @@ -712,12 +705,12 @@ fn lowerZigArgs( | ... | @@ -712,12 +705,12 @@ fn lowerZigArgs( |
| 712 | } | 705 | } |
| 713 | if (conf_comp.pagezero_size.value) |pagezero_size| { | 706 | if (conf_comp.pagezero_size.value) |pagezero_size| { |
| 714 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 707 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 715 | "-pagezero_size", try allocPrint(arena, "{x}", .{pagezero_size}), | 708 | "-pagezero_size", try arena.print("{x}", .{pagezero_size}), |
| 716 | }; | 709 | }; |
| 717 | } | 710 | } |
| 718 | if (conf_comp.headerpad_size.value) |headerpad_size| { | 711 | if (conf_comp.headerpad_size.value) |headerpad_size| { |
| 719 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 712 | (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 720 | "-headerpad", try allocPrint(arena, "{x}", .{headerpad_size}), | 713 | "-headerpad", try arena.print("{x}", .{headerpad_size}), |
| 721 | }; | 714 | }; |
| 722 | } | 715 | } |
| 723 | try addBool(gpa, zig_args, "-headerpad_max_install_names", conf_comp.flags.headerpad_max_install_names); | 716 | try addBool(gpa, zig_args, "-headerpad_max_install_names", conf_comp.flags.headerpad_max_install_names); |
| ... | @@ -740,13 +733,13 @@ fn lowerZigArgs( | ... | @@ -740,13 +733,13 @@ fn lowerZigArgs( |
| 740 | { | 733 | { |
| 741 | try zig_args.ensureUnusedCapacity(gpa, 4); | 734 | try zig_args.ensureUnusedCapacity(gpa, 4); |
| 742 | if (conf_comp.initial_memory.value) |initial_memory| { | 735 | if (conf_comp.initial_memory.value) |initial_memory| { |
| 743 | zig_args.appendAssumeCapacity(try allocPrint(arena, "--initial-memory={d}", .{initial_memory})); | 736 | zig_args.appendAssumeCapacity(try arena.print("--initial-memory={d}", .{initial_memory})); |
| 744 | } | 737 | } |
| 745 | if (conf_comp.max_memory.value) |max_memory| { | 738 | if (conf_comp.max_memory.value) |max_memory| { |
| 746 | zig_args.appendAssumeCapacity(try allocPrint(arena, "--max-memory={d}", .{max_memory})); | 739 | zig_args.appendAssumeCapacity(try arena.print("--max-memory={d}", .{max_memory})); |
| 747 | } | 740 | } |
| 748 | if (conf_comp.global_base.value) |global_base| { | 741 | if (conf_comp.global_base.value) |global_base| { |
| 749 | zig_args.appendAssumeCapacity(try allocPrint(arena, "--global-base={d}", .{global_base})); | 742 | zig_args.appendAssumeCapacity(try arena.print("--global-base={d}", .{global_base})); |
| 750 | } | 743 | } |
| 751 | switch (conf_comp.flags3.wasi_exec_model) { | 744 | switch (conf_comp.flags3.wasi_exec_model) { |
| 752 | .default => {}, | 745 | .default => {}, |
| ... | @@ -812,15 +805,15 @@ fn lowerZigArgs( | ... | @@ -812,15 +805,15 @@ fn lowerZigArgs( |
| 812 | 805 | ||
| 813 | if (conf_comp.flags3.build_id.unwrap(conf_comp.build_id.value, conf) orelse graph.build_id) |build_id| { | 806 | if (conf_comp.flags3.build_id.unwrap(conf_comp.build_id.value, conf) orelse graph.build_id) |build_id| { |
| 814 | try zig_args.append(gpa, switch (build_id) { | 807 | try zig_args.append(gpa, switch (build_id) { |
| 815 | .hexstring => |hs| try allocPrint(arena, "--build-id=0x{x}", .{hs.toSlice()}), | 808 | .hexstring => |hs| try arena.print("--build-id=0x{x}", .{hs.toSlice()}), |
| 816 | .none, .fast, .uuid, .sha1, .md5 => try allocPrint(arena, "--build-id={t}", .{build_id}), | 809 | .none, .fast, .uuid, .sha1, .md5 => try arena.print("--build-id={t}", .{build_id}), |
| 817 | }); | 810 | }); |
| 818 | } | 811 | } |
| 819 | 812 | ||
| 820 | const opt_zig_lib_dir: ?[]const u8 = if (conf_comp.zig_lib_dir.value) |dir| | 813 | const opt_zig_lib_dir: ?[]const u8 = if (conf_comp.zig_lib_dir.value) |dir| |
| 821 | try maker.resolveLazyPathIndexAbs(arena, dir, compile_index) | 814 | try maker.resolveLazyPathIndexAbs(arena, dir, compile_index) |
| 822 | else if (graph.zig_lib_directory.path) |_| | 815 | else if (graph.zig_lib_directory.path) |_| |
| 823 | try allocPrint(arena, "{f}", .{graph.zig_lib_directory}) | 816 | try arena.print("{f}", .{graph.zig_lib_directory}) |
| 824 | else | 817 | else |
| 825 | null; | 818 | null; |
| 826 | 819 | ||
| ... | @@ -848,7 +841,7 @@ fn lowerZigArgs( | ... | @@ -848,7 +841,7 @@ fn lowerZigArgs( |
| 848 | try addBool(gpa, zig_args, "-municode", conf_comp.flags.mingw_unicode_entry_point); | 841 | try addBool(gpa, zig_args, "-municode", conf_comp.flags.mingw_unicode_entry_point); |
| 849 | 842 | ||
| 850 | if (conf_comp.error_limit.value orelse graph.error_limit) |err_limit| (try zig_args.addManyAsArray(gpa, 2)).* = .{ | 843 | if (conf_comp.error_limit.value orelse graph.error_limit) |err_limit| (try zig_args.addManyAsArray(gpa, 2)).* = .{ |
| 851 | "--error-limit", try allocPrint(arena, "{d}", .{err_limit}), | 844 | "--error-limit", try arena.print("{d}", .{err_limit}), |
| 852 | }; | 845 | }; |
| 853 | 846 | ||
| 854 | try addFlag(gpa, zig_args, "incremental", conf_comp.flags4.incremental.toBool() orelse graph.incremental); | 847 | try addFlag(gpa, zig_args, "incremental", conf_comp.flags4.incremental.toBool() orelse graph.incremental); |
| ... | @@ -1152,7 +1145,7 @@ const CliNamedModules = struct { | ... | @@ -1152,7 +1145,7 @@ const CliNamedModules = struct { |
| 1152 | try result.modules.putNoClobber(arena, mod, {}); | 1145 | try result.modules.putNoClobber(arena, mod, {}); |
| 1153 | break; | 1146 | break; |
| 1154 | } | 1147 | } |
| 1155 | name = try allocPrint(arena, "{s}{d}", .{ orig_name_slice, n }); | 1148 | name = try arena.print("{s}{d}", .{ orig_name_slice, n }); |
| 1156 | n += 1; | 1149 | n += 1; |
| 1157 | } | 1150 | } |
| 1158 | } | 1151 | } |
| ... | @@ -1307,7 +1300,7 @@ fn appendModuleFlags( | ... | @@ -1307,7 +1300,7 @@ fn appendModuleFlags( |
| 1307 | } | 1300 | } |
| 1308 | 1301 | ||
| 1309 | for (m.export_symbol_names.slice) |symbol_name| { | 1302 | for (m.export_symbol_names.slice) |symbol_name| { |
| 1310 | try zig_args.append(gpa, try allocPrint(arena, "--export={s}", .{symbol_name.slice(conf)})); | 1303 | try zig_args.append(gpa, try arena.print("--export={s}", .{symbol_name.slice(conf)})); |
| 1311 | } | 1304 | } |
| 1312 | 1305 | ||
| 1313 | try zig_args.ensureUnusedCapacity(gpa, 2 * m.include_dirs.len); | 1306 | try zig_args.ensureUnusedCapacity(gpa, 2 * m.include_dirs.len); |
| ... | @@ -1375,7 +1368,7 @@ pub fn appendIncludeDirFlags( | ... | @@ -1375,7 +1368,7 @@ pub fn appendIncludeDirFlags( |
| 1375 | zig_args.appendAssumeCapacity(try path.toString(arena)); | 1368 | zig_args.appendAssumeCapacity(try path.toString(arena)); |
| 1376 | }, | 1369 | }, |
| 1377 | .embed_path => |lazy_path| { | 1370 | .embed_path => |lazy_path| { |
| 1378 | zig_args.appendAssumeCapacity(try allocPrint(arena, "--embed-dir={f}", .{ | 1371 | zig_args.appendAssumeCapacity(try arena.print("--embed-dir={f}", .{ |
| 1379 | try maker.resolveLazyPathIndex(arena, lazy_path, asking_step), | 1372 | try maker.resolveLazyPathIndex(arena, lazy_path, asking_step), |
| 1380 | })); | 1373 | })); |
| 1381 | }, | 1374 | }, |
lib/compiler/Maker/Step/ObjCopy.zig+9-10| ... | @@ -3,7 +3,6 @@ const ObjCopy = @This(); | ... | @@ -3,7 +3,6 @@ const ObjCopy = @This(); |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | 4 | const Io = std.Io; |
| 5 | const Path = std.Build.Cache.Path; | 5 | const Path = std.Build.Cache.Path; |
| 6 | const allocPrint = std.fmt.allocPrint; | ||
| 7 | const Configuration = std.Build.Configuration; | 6 | const Configuration = std.Build.Configuration; |
| 8 | 7 | ||
| 9 | const Step = @import("../Step.zig"); | 8 | const Step = @import("../Step.zig"); |
| ... | @@ -55,7 +54,7 @@ pub fn make( | ... | @@ -55,7 +54,7 @@ pub fn make( |
| 55 | .sub_path = try Io.Dir.path.join(arena, &.{ "o", &digest, basename }), | 54 | .sub_path = try Io.Dir.path.join(arena, &.{ "o", &digest, basename }), |
| 56 | }; | 55 | }; |
| 57 | if (conf_oc.debug_file.value) |debug_file| { | 56 | if (conf_oc.debug_file.value) |debug_file| { |
| 58 | const debug_basename = opt_debug_basename orelse try allocPrint(arena, "{s}.debug", .{ | 57 | const debug_basename = opt_debug_basename orelse try arena.print("{s}.debug", .{ |
| 59 | Io.Dir.path.basename(input_path.sub_path), | 58 | Io.Dir.path.basename(input_path.sub_path), |
| 60 | }); | 59 | }); |
| 61 | maker.generatedPath(debug_file).* = .{ | 60 | maker.generatedPath(debug_file).* = .{ |
| ... | @@ -92,7 +91,7 @@ pub fn make( | ... | @@ -92,7 +91,7 @@ pub fn make( |
| 92 | 91 | ||
| 93 | if (conf_oc.pad_to.value) |pad_to| { | 92 | if (conf_oc.pad_to.value) |pad_to| { |
| 94 | argv.addManyAsArrayAssumeCapacity(2).* = .{ | 93 | argv.addManyAsArrayAssumeCapacity(2).* = .{ |
| 95 | "--pad-to", try allocPrint(arena, "{d}", .{pad_to}), | 94 | "--pad-to", try arena.print("{d}", .{pad_to}), |
| 96 | }; | 95 | }; |
| 97 | } | 96 | } |
| 98 | 97 | ||
| ... | @@ -105,14 +104,14 @@ pub fn make( | ... | @@ -105,14 +104,14 @@ pub fn make( |
| 105 | argv.appendAssumeCapacity("--compress-debug-sections"); | 104 | argv.appendAssumeCapacity("--compress-debug-sections"); |
| 106 | 105 | ||
| 107 | if (conf_oc.debug_file.value) |debug_file| { | 106 | if (conf_oc.debug_file.value) |debug_file| { |
| 108 | const debug_basename = opt_debug_basename orelse try allocPrint(arena, "{s}.debug", .{ | 107 | const debug_basename = opt_debug_basename orelse try arena.print("{s}.debug", .{ |
| 109 | Io.Dir.path.basename(input_path.sub_path), | 108 | Io.Dir.path.basename(input_path.sub_path), |
| 110 | }); | 109 | }); |
| 111 | const debug_dest_path: Path = .{ | 110 | const debug_dest_path: Path = .{ |
| 112 | .root_dir = cache_root, | 111 | .root_dir = cache_root, |
| 113 | .sub_path = try Io.Dir.path.join(arena, &.{ "o", &digest, debug_basename }), | 112 | .sub_path = try Io.Dir.path.join(arena, &.{ "o", &digest, debug_basename }), |
| 114 | }; | 113 | }; |
| 115 | argv.appendAssumeCapacity(try allocPrint(arena, "--extract-to={f}", .{debug_dest_path})); | 114 | argv.appendAssumeCapacity(try arena.print("--extract-to={f}", .{debug_dest_path})); |
| 116 | maker.generatedPath(debug_file).* = debug_dest_path; | 115 | maker.generatedPath(debug_file).* = debug_dest_path; |
| 117 | } | 116 | } |
| 118 | 117 | ||
| ... | @@ -120,7 +119,7 @@ pub fn make( | ... | @@ -120,7 +119,7 @@ pub fn make( |
| 120 | 119 | ||
| 121 | for (conf_oc.add_section.slice) |section| { | 120 | for (conf_oc.add_section.slice) |section| { |
| 122 | argv.appendAssumeCapacity("--add-section"); | 121 | argv.appendAssumeCapacity("--add-section"); |
| 123 | argv.appendAssumeCapacity(try allocPrint(arena, "{s}={f}", .{ | 122 | argv.appendAssumeCapacity(try arena.print("{s}={f}", .{ |
| 124 | section.section_name.slice(conf), | 123 | section.section_name.slice(conf), |
| 125 | try maker.resolveLazyPathIndex(arena, section.file_path, step_index), | 124 | try maker.resolveLazyPathIndex(arena, section.file_path, step_index), |
| 126 | })); | 125 | })); |
| ... | @@ -133,14 +132,14 @@ pub fn make( | ... | @@ -133,14 +132,14 @@ pub fn make( |
| 133 | 132 | ||
| 134 | if (update.flags.alignment.toBytes()) |a| { | 133 | if (update.flags.alignment.toBytes()) |a| { |
| 135 | argv.appendAssumeCapacity("--set-section-alignment"); | 134 | argv.appendAssumeCapacity("--set-section-alignment"); |
| 136 | argv.appendAssumeCapacity(try allocPrint(arena, "{s}={d}", .{ name, a })); | 135 | argv.appendAssumeCapacity(try arena.print("{s}={d}", .{ name, a })); |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | const f = update.flags.section_flags; | 138 | const f = update.flags.section_flags; |
| 140 | if (f != Configuration.Step.ObjCopy.SectionFlags.default) { | 139 | if (f != Configuration.Step.ObjCopy.SectionFlags.default) { |
| 141 | // trailing comma is allowed | 140 | // trailing comma is allowed |
| 142 | argv.appendAssumeCapacity("--set-section-flags"); | 141 | argv.appendAssumeCapacity("--set-section-flags"); |
| 143 | argv.appendAssumeCapacity(try allocPrint(arena, "{s}={s}{s}{s}{s}{s}{s}{s}{s}{s}", .{ | 142 | argv.appendAssumeCapacity(try arena.print("{s}={s}{s}{s}{s}{s}{s}{s}{s}{s}", .{ |
| 144 | name, | 143 | name, |
| 145 | if (f.alloc) "alloc," else "", | 144 | if (f.alloc) "alloc," else "", |
| 146 | if (f.contents) "contents," else "", | 145 | if (f.contents) "contents," else "", |
| ... | @@ -155,8 +154,8 @@ pub fn make( | ... | @@ -155,8 +154,8 @@ pub fn make( |
| 155 | } | 154 | } |
| 156 | } | 155 | } |
| 157 | 156 | ||
| 158 | argv.appendAssumeCapacity(try allocPrint(arena, "{f}", .{input_path})); | 157 | argv.appendAssumeCapacity(try arena.print("{f}", .{input_path})); |
| 159 | argv.appendAssumeCapacity(try allocPrint(arena, "{f}", .{dest_path})); | 158 | argv.appendAssumeCapacity(try arena.print("{f}", .{dest_path})); |
| 160 | 159 | ||
| 161 | argv.appendAssumeCapacity("--listen=-"); | 160 | argv.appendAssumeCapacity("--listen=-"); |
| 162 | _ = Step.evalZigProcess(step_index, maker, argv.items, progress_node, false) catch |err| switch (err) { | 161 | _ = Step.evalZigProcess(step_index, maker, argv.items, progress_node, false) catch |err| switch (err) { |
lib/compiler/Maker/Step/Run.zig+6-7| ... | @@ -12,7 +12,6 @@ const Path = std.Build.Cache.Path; | ... | @@ -12,7 +12,6 @@ const Path = std.Build.Cache.Path; |
| 12 | const assert = std.debug.assert; | 12 | const assert = std.debug.assert; |
| 13 | const mem = std.mem; | 13 | const mem = std.mem; |
| 14 | const process = std.process; | 14 | const process = std.process; |
| 15 | const allocPrint = std.fmt.allocPrint; | ||
| 16 | const Allocator = std.mem.Allocator; | 15 | const Allocator = std.mem.Allocator; |
| 17 | 16 | ||
| 18 | const Step = @import("../Step.zig"); | 17 | const Step = @import("../Step.zig"); |
| ... | @@ -196,8 +195,8 @@ pub fn make( | ... | @@ -196,8 +195,8 @@ pub fn make( |
| 196 | const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root }, false); | 195 | const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root }, false); |
| 197 | 196 | ||
| 198 | try argv_list.ensureUnusedCapacity(gpa, 3); | 197 | try argv_list.ensureUnusedCapacity(gpa, 3); |
| 199 | argv_list.appendAssumeCapacity(try allocPrint(arena, "--cache-dir={s}", .{cache_dir_string})); | 198 | argv_list.appendAssumeCapacity(try arena.print("--cache-dir={s}", .{cache_dir_string})); |
| 200 | argv_list.appendAssumeCapacity(try allocPrint(arena, "--seed=0x{x}", .{graph.random_seed})); | 199 | argv_list.appendAssumeCapacity(try arena.print("--seed=0x{x}", .{graph.random_seed})); |
| 201 | argv_list.appendAssumeCapacity("--listen=-"); | 200 | argv_list.appendAssumeCapacity("--listen=-"); |
| 202 | } | 201 | } |
| 203 | 202 | ||
| ... | @@ -1627,8 +1626,8 @@ pub fn rerunInFuzzMode( | ... | @@ -1627,8 +1626,8 @@ pub fn rerunInFuzzMode( |
| 1627 | const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root }, false); | 1626 | const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root }, false); |
| 1628 | 1627 | ||
| 1629 | try argv_list.ensureUnusedCapacity(gpa, 3); | 1628 | try argv_list.ensureUnusedCapacity(gpa, 3); |
| 1630 | argv_list.appendAssumeCapacity(try allocPrint(arena, "--cache-dir={s}", .{cache_dir_string})); | 1629 | argv_list.appendAssumeCapacity(try arena.print("--cache-dir={s}", .{cache_dir_string})); |
| 1631 | argv_list.appendAssumeCapacity(try allocPrint(arena, "--seed=0x{x}", .{graph.random_seed})); | 1630 | argv_list.appendAssumeCapacity(try arena.print("--seed=0x{x}", .{graph.random_seed})); |
| 1632 | argv_list.appendAssumeCapacity("--listen=-"); | 1631 | argv_list.appendAssumeCapacity("--listen=-"); |
| 1633 | } | 1632 | } |
| 1634 | 1633 | ||
| ... | @@ -1925,7 +1924,7 @@ fn runCommand( | ... | @@ -1925,7 +1924,7 @@ fn runCommand( |
| 1925 | const path = try maker.resolveLazyPath(arena, lazy_path.get(conf), run_index); | 1924 | const path = try maker.resolveLazyPath(arena, lazy_path.get(conf), run_index); |
| 1926 | path.root_dir.handle.createDirPath(io, path.subPathOrDot()) catch |e| | 1925 | path.root_dir.handle.createDirPath(io, path.subPathOrDot()) catch |e| |
| 1927 | return step.fail(maker, "failed creating directory {f}: {t}", .{ path, e }); | 1926 | return step.fail(maker, "failed creating directory {f}: {t}", .{ path, e }); |
| 1928 | interp_argv.appendAssumeCapacity(try allocPrint(arena, "--dir={f}::{s}", .{ path, name.slice(conf) })); | 1927 | interp_argv.appendAssumeCapacity(try arena.print("--dir={f}::{s}", .{ path, name.slice(conf) })); |
| 1929 | } | 1928 | } |
| 1930 | // Wasmtime doeesn't inherit environment variables from the parent process | 1929 | // Wasmtime doeesn't inherit environment variables from the parent process |
| 1931 | // by default. '-S inherit-env' was added in Wasmtime version 20. | 1930 | // by default. '-S inherit-env' was added in Wasmtime version 20. |
| ... | @@ -2479,7 +2478,7 @@ fn addPathForDynLibs( | ... | @@ -2479,7 +2478,7 @@ fn addPathForDynLibs( |
| 2479 | const dll_path = try maker.generatedPath(conf_comp.generated_bin.value.?).toString(arena); | 2478 | const dll_path = try maker.generatedPath(conf_comp.generated_bin.value.?).toString(arena); |
| 2480 | const search_path = Dir.path.dirname(dll_path).?; | 2479 | const search_path = Dir.path.dirname(dll_path).?; |
| 2481 | if (environ_map.get(path_key)) |prev_path| { | 2480 | if (environ_map.get(path_key)) |prev_path| { |
| 2482 | const new_path = try allocPrint(arena, "{s}{c}{s}", .{ prev_path, path_delimiter, search_path }); | 2481 | const new_path = try arena.print("{s}{c}{s}", .{ prev_path, path_delimiter, search_path }); |
| 2483 | try environ_map.put(path_key, new_path); | 2482 | try environ_map.put(path_key, new_path); |
| 2484 | } else { | 2483 | } else { |
| 2485 | try environ_map.put(path_key, search_path); | 2484 | try environ_map.put(path_key, search_path); |
lib/compiler/Maker/Step/TranslateC.zig+3-4| ... | @@ -3,7 +3,6 @@ const TranslateC = @This(); | ... | @@ -3,7 +3,6 @@ const TranslateC = @This(); |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | 4 | const Io = std.Io; |
| 5 | const Configuration = std.Build.Configuration; | 5 | const Configuration = std.Build.Configuration; |
| 6 | const allocPrint = std.fmt.allocPrint; | ||
| 7 | const assert = std.debug.assert; | 6 | const assert = std.debug.assert; |
| 8 | const OptimizeMode = std.lang.OptimizeMode; | 7 | const OptimizeMode = std.lang.OptimizeMode; |
| 9 | 8 | ||
| ... | @@ -54,7 +53,7 @@ pub fn make( | ... | @@ -54,7 +53,7 @@ pub fn make( |
| 54 | .fast => .ReleaseFast, | 53 | .fast => .ReleaseFast, |
| 55 | .small => .ReleaseSmall, | 54 | .small => .ReleaseSmall, |
| 56 | }; | 55 | }; |
| 57 | if (opt) |o| argv.appendAssumeCapacity(try allocPrint(arena, "-O{t}", .{o})); | 56 | if (opt) |o| argv.appendAssumeCapacity(try arena.print("-O{t}", .{o})); |
| 58 | 57 | ||
| 59 | try argv.ensureUnusedCapacity(arena, conf_tc.include_dirs.len * 2); | 58 | try argv.ensureUnusedCapacity(arena, conf_tc.include_dirs.len * 2); |
| 60 | for (0..conf_tc.include_dirs.len) |i| | 59 | for (0..conf_tc.include_dirs.len) |i| |
| ... | @@ -133,7 +132,7 @@ pub fn make( | ... | @@ -133,7 +132,7 @@ pub fn make( |
| 133 | else => |e| return e, | 132 | else => |e| return e, |
| 134 | } | 133 | } |
| 135 | } | 134 | } |
| 136 | try argv.append(arena, try allocPrint(arena, "{s}{s}", .{ | 135 | try argv.append(arena, try arena.print("{s}{s}", .{ |
| 137 | prefix, system_lib_name, | 136 | prefix, system_lib_name, |
| 138 | })); | 137 | })); |
| 139 | } | 138 | } |
| ... | @@ -151,7 +150,7 @@ pub fn make( | ... | @@ -151,7 +150,7 @@ pub fn make( |
| 151 | }).?; | 150 | }).?; |
| 152 | 151 | ||
| 153 | const stem = Io.Dir.path.stem(Io.Dir.path.basename(c_source_path)); | 152 | const stem = Io.Dir.path.stem(Io.Dir.path.basename(c_source_path)); |
| 154 | const out_basename = try allocPrint(arena, "{s}.zig", .{stem}); | 153 | const out_basename = try arena.print("{s}.zig", .{stem}); |
| 155 | 154 | ||
| 156 | maker.generatedPath(conf_tc.output_file).* = try output_dir_path.join(arena, out_basename); | 155 | maker.generatedPath(conf_tc.output_file).* = try output_dir_path.join(arena, out_basename); |
| 157 | } | 156 | } |
lib/compiler/Maker/Step/UpdateSourceFiles.zig-1| ... | @@ -3,7 +3,6 @@ const UpdateSourceFiles = @This(); | ... | @@ -3,7 +3,6 @@ const UpdateSourceFiles = @This(); |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | 4 | const Io = std.Io; |
| 5 | const Path = std.Build.Cache.Path; | 5 | const Path = std.Build.Cache.Path; |
| 6 | const allocPrint = std.fmt.allocPrint; | ||
| 7 | const Configuration = std.Build.Configuration; | 6 | const Configuration = std.Build.Configuration; |
| 8 | 7 | ||
| 9 | const Step = @import("../Step.zig"); | 8 | const Step = @import("../Step.zig"); |
lib/compiler/Maker/Step/WriteFile.zig-1| ... | @@ -4,7 +4,6 @@ const std = @import("std"); | ... | @@ -4,7 +4,6 @@ const std = @import("std"); |
| 4 | const Io = std.Io; | 4 | const Io = std.Io; |
| 5 | const assert = std.debug.assert; | 5 | const assert = std.debug.assert; |
| 6 | const Path = std.Build.Cache.Path; | 6 | const Path = std.Build.Cache.Path; |
| 7 | const allocPrint = std.fmt.allocPrint; | ||
| 8 | const Configuration = std.Build.Configuration; | 7 | const Configuration = std.Build.Configuration; |
| 9 | 8 | ||
| 10 | const Step = @import("../Step.zig"); | 9 | const Step = @import("../Step.zig"); |
lib/std/Build/Step/ConfigHeader.zig+2-7| ... | @@ -5,7 +5,6 @@ const Io = std.Io; | ... | @@ -5,7 +5,6 @@ const Io = std.Io; |
| 5 | const Step = std.Build.Step; | 5 | const Step = std.Build.Step; |
| 6 | const Allocator = std.mem.Allocator; | 6 | const Allocator = std.mem.Allocator; |
| 7 | const Configuration = std.Build.Configuration; | 7 | const Configuration = std.Build.Configuration; |
| 8 | const allocPrint = std.fmt.allocPrint; | ||
| 9 | 8 | ||
| 10 | step: Step, | 9 | step: Step, |
| 11 | values: std.array_hash_map.String(Value) = .empty, | 10 | values: std.array_hash_map.String(Value) = .empty, |
| ... | @@ -84,13 +83,9 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader { | ... | @@ -84,13 +83,9 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader { |
| 84 | }; | 83 | }; |
| 85 | 84 | ||
| 86 | const name = if (options.style.getPath()) |s| | 85 | const name = if (options.style.getPath()) |s| |
| 87 | allocPrint(arena, "configure {t} header {f} to {s}", .{ | 86 | arena.print("configure {t} header {f} to {s}", .{ options.style, s, include_path }) catch @panic("OOM") |
| 88 | options.style, s, include_path, | ||
| 89 | }) catch @panic("OOM") | ||
| 90 | else | 87 | else |
| 91 | allocPrint(arena, "configure {t} header to {s}", .{ | 88 | arena.print("configure {t} header to {s}", .{ options.style, include_path }) catch @panic("OOM"); |
| 92 | options.style, include_path, | ||
| 93 | }) catch @panic("OOM"); | ||
| 94 | 89 | ||
| 95 | config_header.* = .{ | 90 | config_header.* = .{ |
| 96 | .step = .init(.{ | 91 | .step = .init(.{ |
lib/std/Build/Step/TranslateC.zig+1-2| ... | @@ -3,7 +3,6 @@ const TranslateC = @This(); | ... | @@ -3,7 +3,6 @@ const TranslateC = @This(); |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const fs = std.fs; | 4 | const fs = std.fs; |
| 5 | const mem = std.mem; | 5 | const mem = std.mem; |
| 6 | const allocPrint = std.fmt.allocPrint; | ||
| 7 | const Step = std.Build.Step; | 6 | const Step = std.Build.Step; |
| 8 | const LazyPath = std.Build.LazyPath; | 7 | const LazyPath = std.Build.LazyPath; |
| 9 | const Configuration = std.Build.Configuration; | 8 | const Configuration = std.Build.Configuration; |
| ... | @@ -158,7 +157,7 @@ pub fn defineCMacro(translate_c: *TranslateC, name: []const u8, value: ?[]const | ... | @@ -158,7 +157,7 @@ pub fn defineCMacro(translate_c: *TranslateC, name: []const u8, value: ?[]const |
| 158 | const graph = translate_c.step.owner.graph; | 157 | const graph = translate_c.step.owner.graph; |
| 159 | const arena = graph.arena; | 158 | const arena = graph.arena; |
| 160 | const wc = &graph.wip_configuration; | 159 | const wc = &graph.wip_configuration; |
| 161 | const macro = allocPrint(arena, "{s}={s}", .{ name, value orelse "1" }) catch @panic("OOM"); | 160 | const macro = arena.print("{s}={s}", .{ name, value orelse "1" }) catch @panic("OOM"); |
| 162 | const macro_string = wc.addString(macro) catch @panic("OOM"); | 161 | const macro_string = wc.addString(macro) catch @panic("OOM"); |
| 163 | translate_c.c_macros.append(arena, macro_string) catch @panic("OOM"); | 162 | translate_c.c_macros.append(arena, macro_string) catch @panic("OOM"); |
| 164 | } | 163 | } |
src/link/Lld.zig+45-46| ... | @@ -436,23 +436,23 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -436,23 +436,23 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 436 | try argv.append("-DEBUG"); | 436 | try argv.append("-DEBUG"); |
| 437 | 437 | ||
| 438 | const out_ext = std.fs.path.extension(full_out_path); | 438 | const out_ext = std.fs.path.extension(full_out_path); |
| 439 | const out_pdb = coff.pdb_out_path orelse try allocPrint(arena, "{s}.pdb", .{ | 439 | const out_pdb = coff.pdb_out_path orelse try arena.print("{s}.pdb", .{ |
| 440 | full_out_path[0 .. full_out_path.len - out_ext.len], | 440 | full_out_path[0 .. full_out_path.len - out_ext.len], |
| 441 | }); | 441 | }); |
| 442 | const out_pdb_basename = std.fs.path.basename(out_pdb); | 442 | const out_pdb_basename = std.fs.path.basename(out_pdb); |
| 443 | 443 | ||
| 444 | try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb})); | 444 | try argv.append(try arena.print("-PDB:{s}", .{out_pdb})); |
| 445 | try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename})); | 445 | try argv.append(try arena.print("-PDBALTPATH:{s}", .{out_pdb_basename})); |
| 446 | } | 446 | } |
| 447 | if (comp.version) |version| { | 447 | if (comp.version) |version| { |
| 448 | try argv.append(try allocPrint(arena, "-VERSION:{d}.{d}", .{ version.major, version.minor })); | 448 | try argv.append(try arena.print("-VERSION:{d}.{d}", .{ version.major, version.minor })); |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | if (target_util.llvmMachineAbi(target)) |mabi| { | 451 | if (target_util.llvmMachineAbi(target)) |mabi| { |
| 452 | try argv.append(try allocPrint(arena, "-MLLVM:-target-abi={s}", .{mabi})); | 452 | try argv.append(try arena.print("-MLLVM:-target-abi={s}", .{mabi})); |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"})); | 455 | try argv.append(try arena.print("-MLLVM:-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"})); |
| 456 | 456 | ||
| 457 | if (comp.config.lto != .none) { | 457 | if (comp.config.lto != .none) { |
| 458 | switch (optimize_mode) { | 458 | switch (optimize_mode) { |
| ... | @@ -462,9 +462,9 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -462,9 +462,9 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 462 | } | 462 | } |
| 463 | } | 463 | } |
| 464 | if (comp.config.output_mode == .Exe) { | 464 | if (comp.config.output_mode == .Exe) { |
| 465 | try argv.append(try allocPrint(arena, "-STACK:{d}", .{base.stack_size})); | 465 | try argv.append(try arena.print("-STACK:{d}", .{base.stack_size})); |
| 466 | } | 466 | } |
| 467 | try argv.append(try allocPrint(arena, "-BASE:{d}", .{coff.image_base})); | 467 | try argv.append(try arena.print("-BASE:{d}", .{coff.image_base})); |
| 468 | 468 | ||
| 469 | switch (base.build_id) { | 469 | switch (base.build_id) { |
| 470 | .none => try argv.append("-BUILD-ID:NO"), | 470 | .none => try argv.append("-BUILD-ID:NO"), |
| ... | @@ -483,7 +483,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -483,7 +483,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | for (comp.force_undefined_symbols.keys()) |symbol| { | 485 | for (comp.force_undefined_symbols.keys()) |symbol| { |
| 486 | try argv.append(try allocPrint(arena, "-INCLUDE:{s}", .{symbol})); | 486 | try argv.append(try arena.print("-INCLUDE:{s}", .{symbol})); |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | if (is_dyn_lib) { | 489 | if (is_dyn_lib) { |
| ... | @@ -491,7 +491,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -491,7 +491,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | if (entry_name) |name| { | 493 | if (entry_name) |name| { |
| 494 | try argv.append(try allocPrint(arena, "-ENTRY:{s}", .{name})); | 494 | try argv.append(try arena.print("-ENTRY:{s}", .{name})); |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | if (coff.repro) { | 497 | if (coff.repro) { |
| ... | @@ -511,26 +511,26 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -511,26 +511,26 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 511 | try argv.append("-FORCE:UNRESOLVED"); | 511 | try argv.append("-FORCE:UNRESOLVED"); |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | try argv.append(try allocPrint(arena, "-OUT:{s}", .{full_out_path})); | 514 | try argv.append(try arena.print("-OUT:{s}", .{full_out_path})); |
| 515 | 515 | ||
| 516 | if (comp.emit_implib) |raw_emit_path| { | 516 | if (comp.emit_implib) |raw_emit_path| { |
| 517 | const path = try comp.resolveEmitPathFlush(arena, .artifact, raw_emit_path); | 517 | const path = try comp.resolveEmitPathFlush(arena, .artifact, raw_emit_path); |
| 518 | try argv.append(try allocPrint(arena, "-IMPLIB:{f}", .{path})); | 518 | try argv.append(try arena.print("-IMPLIB:{f}", .{path})); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | if (comp.config.link_libc) { | 521 | if (comp.config.link_libc) { |
| 522 | if (comp.libc_installation) |libc_installation| { | 522 | if (comp.libc_installation) |libc_installation| { |
| 523 | try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.crt_dir.?})); | 523 | try argv.append(try arena.print("-LIBPATH:{s}", .{libc_installation.crt_dir.?})); |
| 524 | 524 | ||
| 525 | if (target.abi == .msvc or target.abi == .itanium) { | 525 | if (target.abi == .msvc or target.abi == .itanium) { |
| 526 | try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.msvc_lib_dir.?})); | 526 | try argv.append(try arena.print("-LIBPATH:{s}", .{libc_installation.msvc_lib_dir.?})); |
| 527 | try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.kernel32_lib_dir.?})); | 527 | try argv.append(try arena.print("-LIBPATH:{s}", .{libc_installation.kernel32_lib_dir.?})); |
| 528 | } | 528 | } |
| 529 | } | 529 | } |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | for (coff.lib_directories) |lib_directory| { | 532 | for (coff.lib_directories) |lib_directory| { |
| 533 | try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{lib_directory.path orelse "."})); | 533 | try argv.append(try arena.print("-LIBPATH:{s}", .{lib_directory.path orelse "."})); |
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | try argv.ensureUnusedCapacity(comp.link_inputs.len); | 536 | try argv.ensureUnusedCapacity(comp.link_inputs.len); |
| ... | @@ -541,7 +541,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -541,7 +541,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 541 | }, | 541 | }, |
| 542 | .object, .archive => |obj| { | 542 | .object, .archive => |obj| { |
| 543 | if (obj.must_link) { | 543 | if (obj.must_link) { |
| 544 | argv.appendAssumeCapacity(try allocPrint(arena, "-WHOLEARCHIVE:{f}", .{@as(Cache.Path, obj.path)})); | 544 | argv.appendAssumeCapacity(try arena.print("-WHOLEARCHIVE:{f}", .{@as(Cache.Path, obj.path)})); |
| 545 | } else { | 545 | } else { |
| 546 | argv.appendAssumeCapacity(try obj.path.toString(arena)); | 546 | argv.appendAssumeCapacity(try obj.path.toString(arena)); |
| 547 | } | 547 | } |
| ... | @@ -561,7 +561,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -561,7 +561,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | if (coff.module_definition_file) |def| { | 563 | if (coff.module_definition_file) |def| { |
| 564 | try argv.append(try allocPrint(arena, "-DEF:{s}", .{def})); | 564 | try argv.append(try arena.print("-DEF:{s}", .{def})); |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | const resolved_subsystem: ?std.zig.Subsystem = blk: { | 567 | const resolved_subsystem: ?std.zig.Subsystem = blk: { |
| ... | @@ -590,7 +590,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -590,7 +590,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 590 | const Mode = enum { uefi, win32 }; | 590 | const Mode = enum { uefi, win32 }; |
| 591 | const mode: Mode = mode: { | 591 | const mode: Mode = mode: { |
| 592 | if (resolved_subsystem) |subsystem| { | 592 | if (resolved_subsystem) |subsystem| { |
| 593 | try argv.append(try allocPrint(arena, "-SUBSYSTEM:{s},{d}.{d}", .{ | 593 | try argv.append(try arena.print("-SUBSYSTEM:{s},{d}.{d}", .{ |
| 594 | @tagName(subsystem), | 594 | @tagName(subsystem), |
| 595 | coff.major_subsystem_version, | 595 | coff.major_subsystem_version, |
| 596 | coff.minor_subsystem_version, | 596 | coff.minor_subsystem_version, |
| ... | @@ -645,8 +645,8 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -645,8 +645,8 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 645 | .static => "lib", | 645 | .static => "lib", |
| 646 | .dynamic => "", | 646 | .dynamic => "", |
| 647 | }; | 647 | }; |
| 648 | try argv.append(try allocPrint(arena, "{s}vcruntime.lib", .{lib_str})); | 648 | try argv.append(try arena.print("{s}vcruntime.lib", .{lib_str})); |
| 649 | try argv.append(try allocPrint(arena, "{s}ucrt.lib", .{lib_str})); | 649 | try argv.append(try arena.print("{s}ucrt.lib", .{lib_str})); |
| 650 | 650 | ||
| 651 | //Visual C++ 2015 Conformance Changes | 651 | //Visual C++ 2015 Conformance Changes |
| 652 | //https://msdn.microsoft.com/en-us/library/bb531344.aspx | 652 | //https://msdn.microsoft.com/en-us/library/bb531344.aspx |
| ... | @@ -712,7 +712,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -712,7 +712,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 712 | 712 | ||
| 713 | try argv.ensureUnusedCapacity(comp.windows_libs.count()); | 713 | try argv.ensureUnusedCapacity(comp.windows_libs.count()); |
| 714 | for (comp.windows_libs.keys()) |key| { | 714 | for (comp.windows_libs.keys()) |key| { |
| 715 | const lib_basename = try allocPrint(arena, "{s}.lib", .{key}); | 715 | const lib_basename = try arena.print("{s}.lib", .{key}); |
| 716 | if (comp.crt_files.get(lib_basename)) |crt_file| { | 716 | if (comp.crt_files.get(lib_basename)) |crt_file| { |
| 717 | argv.appendAssumeCapacity(try crt_file.full_object_path.toString(arena)); | 717 | argv.appendAssumeCapacity(try crt_file.full_object_path.toString(arena)); |
| 718 | continue; | 718 | continue; |
| ... | @@ -722,7 +722,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -722,7 +722,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 722 | continue; | 722 | continue; |
| 723 | } | 723 | } |
| 724 | if (target.abi.isGnu()) { | 724 | if (target.abi.isGnu()) { |
| 725 | const fallback_name = try allocPrint(arena, "lib{s}.dll.a", .{key}); | 725 | const fallback_name = try arena.print("lib{s}.dll.a", .{key}); |
| 726 | if (try findLib(arena, io, fallback_name, coff.lib_directories)) |full_path| { | 726 | if (try findLib(arena, io, fallback_name, coff.lib_directories)) |full_path| { |
| 727 | argv.appendAssumeCapacity(full_path); | 727 | argv.appendAssumeCapacity(full_path); |
| 728 | continue; | 728 | continue; |
| ... | @@ -843,19 +843,19 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -843,19 +843,19 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 843 | try argv.append("--error-limit=0"); | 843 | try argv.append("--error-limit=0"); |
| 844 | 844 | ||
| 845 | if (comp.sysroot) |sysroot| { | 845 | if (comp.sysroot) |sysroot| { |
| 846 | try argv.append(try std.fmt.allocPrint(arena, "--sysroot={s}", .{sysroot})); | 846 | try argv.append(try arena.print("--sysroot={s}", .{sysroot})); |
| 847 | } | 847 | } |
| 848 | 848 | ||
| 849 | if (target_util.llvmMachineAbi(target)) |mabi| { | 849 | if (target_util.llvmMachineAbi(target)) |mabi| { |
| 850 | try argv.appendSlice(&.{ | 850 | try argv.appendSlice(&.{ |
| 851 | "-mllvm", | 851 | "-mllvm", |
| 852 | try std.fmt.allocPrint(arena, "-target-abi={s}", .{mabi}), | 852 | try arena.print("-target-abi={s}", .{mabi}), |
| 853 | }); | 853 | }); |
| 854 | } | 854 | } |
| 855 | 855 | ||
| 856 | try argv.appendSlice(&.{ | 856 | try argv.appendSlice(&.{ |
| 857 | "-mllvm", | 857 | "-mllvm", |
| 858 | try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"}), | 858 | try arena.print("-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"}), |
| 859 | }); | 859 | }); |
| 860 | 860 | ||
| 861 | switch (target.cpu.arch) { | 861 | switch (target.cpu.arch) { |
| ... | @@ -894,19 +894,19 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -894,19 +894,19 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 894 | if (output_mode == .Exe) { | 894 | if (output_mode == .Exe) { |
| 895 | try argv.appendSlice(&.{ | 895 | try argv.appendSlice(&.{ |
| 896 | "-z", | 896 | "-z", |
| 897 | try std.fmt.allocPrint(arena, "stack-size={d}", .{base.stack_size}), | 897 | try arena.print("stack-size={d}", .{base.stack_size}), |
| 898 | }); | 898 | }); |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | switch (base.build_id) { | 901 | switch (base.build_id) { |
| 902 | .none => try argv.append("--build-id=none"), | 902 | .none => try argv.append("--build-id=none"), |
| 903 | .fast, .uuid, .sha1, .md5 => try argv.append(try std.fmt.allocPrint(arena, "--build-id={s}", .{ | 903 | .fast, .uuid, .sha1, .md5 => try argv.append(try arena.print("--build-id={s}", .{ |
| 904 | @tagName(base.build_id), | 904 | @tagName(base.build_id), |
| 905 | })), | 905 | })), |
| 906 | .hexstring => |hs| try argv.append(try std.fmt.allocPrint(arena, "--build-id=0x{x}", .{hs.toSlice()})), | 906 | .hexstring => |hs| try argv.append(try arena.print("--build-id=0x{x}", .{hs.toSlice()})), |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | try argv.append(try std.fmt.allocPrint(arena, "--image-base={d}", .{elf.image_base})); | 909 | try argv.append(try arena.print("--image-base={d}", .{elf.image_base})); |
| 910 | 910 | ||
| 911 | if (elf.linker_script) |linker_script| { | 911 | if (elf.linker_script) |linker_script| { |
| 912 | try argv.append("-T"); | 912 | try argv.append("-T"); |
| ... | @@ -914,7 +914,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -914,7 +914,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 914 | } | 914 | } |
| 915 | 915 | ||
| 916 | if (elf.sort_section) |how| { | 916 | if (elf.sort_section) |how| { |
| 917 | const arg = try std.fmt.allocPrint(arena, "--sort-section={s}", .{@tagName(how)}); | 917 | const arg = try arena.print("--sort-section={s}", .{@tagName(how)}); |
| 918 | try argv.append(arg); | 918 | try argv.append(arg); |
| 919 | } | 919 | } |
| 920 | 920 | ||
| ... | @@ -980,11 +980,11 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -980,11 +980,11 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 980 | } | 980 | } |
| 981 | if (elf.z_common_page_size) |size| { | 981 | if (elf.z_common_page_size) |size| { |
| 982 | try argv.append("-z"); | 982 | try argv.append("-z"); |
| 983 | try argv.append(try std.fmt.allocPrint(arena, "common-page-size={d}", .{size})); | 983 | try argv.append(try arena.print("common-page-size={d}", .{size})); |
| 984 | } | 984 | } |
| 985 | if (elf.z_max_page_size) |size| { | 985 | if (elf.z_max_page_size) |size| { |
| 986 | try argv.append("-z"); | 986 | try argv.append("-z"); |
| 987 | try argv.append(try std.fmt.allocPrint(arena, "max-page-size={d}", .{size})); | 987 | try argv.append(try arena.print("max-page-size={d}", .{size})); |
| 988 | } | 988 | } |
| 989 | 989 | ||
| 990 | if (getLDMOption(target)) |ldm| { | 990 | if (getLDMOption(target)) |ldm| { |
| ... | @@ -1190,7 +1190,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1190,7 +1190,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 1190 | if (target.os.versionRange().gnuLibCVersion().?.order(rem_in) != .lt) continue; | 1190 | if (target.os.versionRange().gnuLibCVersion().?.order(rem_in) != .lt) continue; |
| 1191 | } | 1191 | } |
| 1192 | 1192 | ||
| 1193 | const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{ | 1193 | const lib_path = try arena.print("{f}{c}lib{s}.so.{d}", .{ |
| 1194 | comp.glibc_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover, | 1194 | comp.glibc_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover, |
| 1195 | }); | 1195 | }); |
| 1196 | try argv.append(lib_path); | 1196 | try argv.append(lib_path); |
| ... | @@ -1207,21 +1207,21 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1207,21 +1207,21 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 1207 | if (target.os.version_range.semver.min.order(add_in) == .lt) continue; | 1207 | if (target.os.version_range.semver.min.order(add_in) == .lt) continue; |
| 1208 | } | 1208 | } |
| 1209 | 1209 | ||
| 1210 | const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{ | 1210 | const lib_path = try arena.print("{f}{c}lib{s}.so.{d}", .{ |
| 1211 | comp.freebsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.getSoVersion(&target.os), | 1211 | comp.freebsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.getSoVersion(&target.os), |
| 1212 | }); | 1212 | }); |
| 1213 | try argv.append(lib_path); | 1213 | try argv.append(lib_path); |
| 1214 | } | 1214 | } |
| 1215 | } else if (target.isNetBSDLibC()) { | 1215 | } else if (target.isNetBSDLibC()) { |
| 1216 | for (netbsd.libs) |lib| { | 1216 | for (netbsd.libs) |lib| { |
| 1217 | const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{ | 1217 | const lib_path = try arena.print("{f}{c}lib{s}.so.{d}", .{ |
| 1218 | comp.netbsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover, | 1218 | comp.netbsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover, |
| 1219 | }); | 1219 | }); |
| 1220 | try argv.append(lib_path); | 1220 | try argv.append(lib_path); |
| 1221 | } | 1221 | } |
| 1222 | } else if (target.isOpenBSDLibC()) { | 1222 | } else if (target.isOpenBSDLibC()) { |
| 1223 | for (openbsd.libs) |lib| { | 1223 | for (openbsd.libs) |lib| { |
| 1224 | const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so", .{ | 1224 | const lib_path = try arena.print("{f}{c}lib{s}.so", .{ |
| 1225 | comp.openbsd_so_files.?.dir_path, fs.path.sep, lib.name, | 1225 | comp.openbsd_so_files.?.dir_path, fs.path.sep, lib.name, |
| 1226 | }); | 1226 | }); |
| 1227 | try argv.append(lib_path); | 1227 | try argv.append(lib_path); |
| ... | @@ -1451,12 +1451,12 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1451,12 +1451,12 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1451 | } | 1451 | } |
| 1452 | 1452 | ||
| 1453 | if (wasm.initial_memory) |initial_memory| { | 1453 | if (wasm.initial_memory) |initial_memory| { |
| 1454 | const arg = try std.fmt.allocPrint(arena, "--initial-memory={d}", .{initial_memory}); | 1454 | const arg = try arena.print("--initial-memory={d}", .{initial_memory}); |
| 1455 | try argv.append(arg); | 1455 | try argv.append(arg); |
| 1456 | } | 1456 | } |
| 1457 | 1457 | ||
| 1458 | if (wasm.max_memory) |max_memory| { | 1458 | if (wasm.max_memory) |max_memory| { |
| 1459 | const arg = try std.fmt.allocPrint(arena, "--max-memory={d}", .{max_memory}); | 1459 | const arg = try arena.print("--max-memory={d}", .{max_memory}); |
| 1460 | try argv.append(arg); | 1460 | try argv.append(arg); |
| 1461 | } | 1461 | } |
| 1462 | 1462 | ||
| ... | @@ -1465,7 +1465,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1465,7 +1465,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1465 | } | 1465 | } |
| 1466 | 1466 | ||
| 1467 | if (wasm.global_base) |global_base| { | 1467 | if (wasm.global_base) |global_base| { |
| 1468 | const arg = try std.fmt.allocPrint(arena, "--global-base={d}", .{global_base}); | 1468 | const arg = try arena.print("--global-base={d}", .{global_base}); |
| 1469 | try argv.append(arg); | 1469 | try argv.append(arg); |
| 1470 | } else { | 1470 | } else { |
| 1471 | // We prepend it by default, so when a stack overflow happens the runtime will trap correctly, | 1471 | // We prepend it by default, so when a stack overflow happens the runtime will trap correctly, |
| ... | @@ -1477,7 +1477,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1477,7 +1477,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1477 | 1477 | ||
| 1478 | // Users are allowed to specify which symbols they want to export to the wasm host. | 1478 | // Users are allowed to specify which symbols they want to export to the wasm host. |
| 1479 | for (wasm.export_symbol_names) |symbol_name| { | 1479 | for (wasm.export_symbol_names) |symbol_name| { |
| 1480 | const arg = try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name}); | 1480 | const arg = try arena.print("--export={s}", .{symbol_name}); |
| 1481 | try argv.append(arg); | 1481 | try argv.append(arg); |
| 1482 | } | 1482 | } |
| 1483 | 1483 | ||
| ... | @@ -1493,15 +1493,15 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -1493,15 +1493,15 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1493 | 1493 | ||
| 1494 | try argv.appendSlice(&.{ | 1494 | try argv.appendSlice(&.{ |
| 1495 | "-z", | 1495 | "-z", |
| 1496 | try std.fmt.allocPrint(arena, "stack-size={d}", .{base.stack_size}), | 1496 | try arena.print("stack-size={d}", .{base.stack_size}), |
| 1497 | }); | 1497 | }); |
| 1498 | 1498 | ||
| 1499 | switch (base.build_id) { | 1499 | switch (base.build_id) { |
| 1500 | .none => try argv.append("--build-id=none"), | 1500 | .none => try argv.append("--build-id=none"), |
| 1501 | .fast, .uuid, .sha1 => try argv.append(try std.fmt.allocPrint(arena, "--build-id={s}", .{ | 1501 | .fast, .uuid, .sha1 => try argv.append(try arena.print("--build-id={s}", .{ |
| 1502 | @tagName(base.build_id), | 1502 | @tagName(base.build_id), |
| 1503 | })), | 1503 | })), |
| 1504 | .hexstring => |hs| try argv.append(try std.fmt.allocPrint(arena, "--build-id=0x{x}", .{hs.toSlice()})), | 1504 | .hexstring => |hs| try argv.append(try arena.print("--build-id=0x{x}", .{hs.toSlice()})), |
| 1505 | .md5 => {}, | 1505 | .md5 => {}, |
| 1506 | } | 1506 | } |
| 1507 | 1507 | ||
| ... | @@ -1685,7 +1685,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi | ... | @@ -1685,7 +1685,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1685 | .argv = &.{ | 1685 | .argv = &.{ |
| 1686 | argv[0], | 1686 | argv[0], |
| 1687 | argv[1], | 1687 | argv[1], |
| 1688 | try std.fmt.allocPrint(arena, "@{s}", .{ | 1688 | try arena.print("@{s}", .{ |
| 1689 | try comp.dirs.local_cache.join(arena, &.{rsp_path}), | 1689 | try comp.dirs.local_cache.join(arena, &.{rsp_path}), |
| 1690 | }), | 1690 | }), |
| 1691 | }, | 1691 | }, |
| ... | @@ -1740,7 +1740,6 @@ const std = @import("std"); | ... | @@ -1740,7 +1740,6 @@ const std = @import("std"); |
| 1740 | const Io = std.Io; | 1740 | const Io = std.Io; |
| 1741 | const Allocator = std.mem.Allocator; | 1741 | const Allocator = std.mem.Allocator; |
| 1742 | const Cache = std.Build.Cache; | 1742 | const Cache = std.Build.Cache; |
| 1743 | const allocPrint = std.fmt.allocPrint; | ||
| 1744 | const assert = std.debug.assert; | 1743 | const assert = std.debug.assert; |
| 1745 | const fs = std.fs; | 1744 | const fs = std.fs; |
| 1746 | const log = std.log.scoped(.link); | 1745 | const log = std.log.scoped(.link); |
src/main.zig+20-21| ... | @@ -21,7 +21,6 @@ const AstGen = std.zig.AstGen; | ... | @@ -21,7 +21,6 @@ const AstGen = std.zig.AstGen; |
| 21 | const ZonGen = std.zig.ZonGen; | 21 | const ZonGen = std.zig.ZonGen; |
| 22 | const Server = std.zig.Server; | 22 | const Server = std.zig.Server; |
| 23 | const stringToEnum = std.meta.stringToEnum; | 23 | const stringToEnum = std.meta.stringToEnum; |
| 24 | const allocPrint = std.fmt.allocPrint; | ||
| 25 | 24 | ||
| 26 | pub const tracy = @import("tracy.zig"); | 25 | pub const tracy = @import("tracy.zig"); |
| 27 | const Compilation = @import("Compilation.zig"); | 26 | const Compilation = @import("Compilation.zig"); |
| ... | @@ -2964,7 +2963,7 @@ fn buildOutputType( | ... | @@ -2964,7 +2963,7 @@ fn buildOutputType( |
| 2964 | while (preprocessor_args_it.next()) |arg| { | 2963 | while (preprocessor_args_it.next()) |arg| { |
| 2965 | if (mem.eql(u8, arg, "-MD") or mem.eql(u8, arg, "-MMD") or mem.eql(u8, arg, "-MT")) { | 2964 | if (mem.eql(u8, arg, "-MD") or mem.eql(u8, arg, "-MMD") or mem.eql(u8, arg, "-MT")) { |
| 2966 | disable_c_depfile = true; | 2965 | disable_c_depfile = true; |
| 2967 | const cc_arg = try allocPrint(arena, "-Wp,{s},{s}", .{ arg, preprocessor_args_it.nextOrFatal() }); | 2966 | const cc_arg = try arena.print("-Wp,{s},{s}", .{ arg, preprocessor_args_it.nextOrFatal() }); |
| 2968 | try cc_argv.append(arena, cc_arg); | 2967 | try cc_argv.append(arena, cc_arg); |
| 2969 | } else { | 2968 | } else { |
| 2970 | fatal("unsupported preprocessor arg: {s}", .{arg}); | 2969 | fatal("unsupported preprocessor arg: {s}", .{arg}); |
| ... | @@ -3408,9 +3407,9 @@ fn buildOutputType( | ... | @@ -3408,9 +3407,9 @@ fn buildOutputType( |
| 3408 | .yes_default_value => if (create_module.resolved_options.output_mode == .Lib and | 3407 | .yes_default_value => if (create_module.resolved_options.output_mode == .Lib and |
| 3409 | create_module.resolved_options.link_mode == .dynamic and target.ofmt == .elf) | 3408 | create_module.resolved_options.link_mode == .dynamic and target.ofmt == .elf) |
| 3410 | if (have_version) | 3409 | if (have_version) |
| 3411 | try allocPrint(arena, "lib{s}.so.{d}", .{ root_name, version.major }) | 3410 | try arena.print("lib{s}.so.{d}", .{ root_name, version.major }) |
| 3412 | else | 3411 | else |
| 3413 | try allocPrint(arena, "lib{s}.so", .{root_name}) | 3412 | try arena.print("lib{s}.so", .{root_name}) |
| 3414 | else | 3413 | else |
| 3415 | null, | 3414 | null, |
| 3416 | }; | 3415 | }; |
| ... | @@ -3420,7 +3419,7 @@ fn buildOutputType( | ... | @@ -3420,7 +3419,7 @@ fn buildOutputType( |
| 3420 | .yes_default_path => emit: { | 3419 | .yes_default_path => emit: { |
| 3421 | if (output_to_cache != null) break :emit .yes_cache; | 3420 | if (output_to_cache != null) break :emit .yes_cache; |
| 3422 | const name = switch (clang_preprocessor_mode) { | 3421 | const name = switch (clang_preprocessor_mode) { |
| 3423 | .pch => try allocPrint(arena, "{s}.pch", .{root_name}), | 3422 | .pch => try arena.print("{s}.pch", .{root_name}), |
| 3424 | else => try std.zig.binNameAlloc(arena, .{ | 3423 | else => try std.zig.binNameAlloc(arena, .{ |
| 3425 | .root_name = root_name, | 3424 | .root_name = root_name, |
| 3426 | .cpu_arch = target.cpu.arch, | 3425 | .cpu_arch = target.cpu.arch, |
| ... | @@ -3456,16 +3455,16 @@ fn buildOutputType( | ... | @@ -3456,16 +3455,16 @@ fn buildOutputType( |
| 3456 | }, | 3455 | }, |
| 3457 | }; | 3456 | }; |
| 3458 | 3457 | ||
| 3459 | const default_h_basename = try allocPrint(arena, "{s}.h", .{root_name}); | 3458 | const default_h_basename = try arena.print("{s}.h", .{root_name}); |
| 3460 | const emit_h_resolved = emit_h.resolve(io, default_h_basename, output_to_cache); | 3459 | const emit_h_resolved = emit_h.resolve(io, default_h_basename, output_to_cache); |
| 3461 | 3460 | ||
| 3462 | const default_asm_basename = try allocPrint(arena, "{s}.s", .{root_name}); | 3461 | const default_asm_basename = try arena.print("{s}.s", .{root_name}); |
| 3463 | const emit_asm_resolved = emit_asm.resolve(io, default_asm_basename, output_to_cache); | 3462 | const emit_asm_resolved = emit_asm.resolve(io, default_asm_basename, output_to_cache); |
| 3464 | 3463 | ||
| 3465 | const default_llvm_ir_basename = try allocPrint(arena, "{s}.ll", .{root_name}); | 3464 | const default_llvm_ir_basename = try arena.print("{s}.ll", .{root_name}); |
| 3466 | const emit_llvm_ir_resolved = emit_llvm_ir.resolve(io, default_llvm_ir_basename, output_to_cache); | 3465 | const emit_llvm_ir_resolved = emit_llvm_ir.resolve(io, default_llvm_ir_basename, output_to_cache); |
| 3467 | 3466 | ||
| 3468 | const default_llvm_bc_basename = try allocPrint(arena, "{s}.bc", .{root_name}); | 3467 | const default_llvm_bc_basename = try arena.print("{s}.bc", .{root_name}); |
| 3469 | const emit_llvm_bc_resolved = emit_llvm_bc.resolve(io, default_llvm_bc_basename, output_to_cache); | 3468 | const emit_llvm_bc_resolved = emit_llvm_bc.resolve(io, default_llvm_bc_basename, output_to_cache); |
| 3470 | 3469 | ||
| 3471 | const emit_docs_resolved = emit_docs.resolve(io, "docs", output_to_cache); | 3470 | const emit_docs_resolved = emit_docs.resolve(io, "docs", output_to_cache); |
| ... | @@ -3486,7 +3485,7 @@ fn buildOutputType( | ... | @@ -3486,7 +3485,7 @@ fn buildOutputType( |
| 3486 | fatal("the argument -femit-implib is allowed only when building a Windows DLL", .{}); | 3485 | fatal("the argument -femit-implib is allowed only when building a Windows DLL", .{}); |
| 3487 | } | 3486 | } |
| 3488 | } | 3487 | } |
| 3489 | const default_implib_basename = try allocPrint(arena, "{s}.lib", .{root_name}); | 3488 | const default_implib_basename = try arena.print("{s}.lib", .{root_name}); |
| 3490 | const emit_implib_resolved: Compilation.CreateOptions.Emit = switch (emit_implib) { | 3489 | const emit_implib_resolved: Compilation.CreateOptions.Emit = switch (emit_implib) { |
| 3491 | .no => .no, | 3490 | .no => .no, |
| 3492 | .yes => emit_implib.resolve(io, default_implib_basename, output_to_cache), | 3491 | .yes => emit_implib.resolve(io, default_implib_basename, output_to_cache), |
| ... | @@ -3515,7 +3514,7 @@ fn buildOutputType( | ... | @@ -3515,7 +3514,7 @@ fn buildOutputType( |
| 3515 | 3514 | ||
| 3516 | // "-" is stdin. Dump it to a real file. | 3515 | // "-" is stdin. Dump it to a real file. |
| 3517 | const sep = fs.path.sep_str; | 3516 | const sep = fs.path.sep_str; |
| 3518 | const dump_path = try allocPrint(arena, "tmp" ++ sep ++ "{x}-dump-stdin{s}", .{ | 3517 | const dump_path = try arena.print("tmp" ++ sep ++ "{x}-dump-stdin{s}", .{ |
| 3519 | randInt(io, u64), ext.canonicalName(target), | 3518 | randInt(io, u64), ext.canonicalName(target), |
| 3520 | }); | 3519 | }); |
| 3521 | try dirs.local_cache.handle.createDirPath(io, "tmp"); | 3520 | try dirs.local_cache.handle.createDirPath(io, "tmp"); |
| ... | @@ -3544,7 +3543,7 @@ fn buildOutputType( | ... | @@ -3544,7 +3543,7 @@ fn buildOutputType( |
| 3544 | 3543 | ||
| 3545 | const bin_digest: Cache.BinDigest = hasher.hasher.finalResult(); | 3544 | const bin_digest: Cache.BinDigest = hasher.hasher.finalResult(); |
| 3546 | 3545 | ||
| 3547 | const sub_path = try allocPrint(arena, "tmp" ++ sep ++ "{x}-stdin{s}", .{ | 3546 | const sub_path = try arena.print("tmp" ++ sep ++ "{x}-stdin{s}", .{ |
| 3548 | &bin_digest, ext.canonicalName(target), | 3547 | &bin_digest, ext.canonicalName(target), |
| 3549 | }); | 3548 | }); |
| 3550 | try dirs.local_cache.handle.rename(dump_path, dirs.local_cache.handle, sub_path, io); | 3549 | try dirs.local_cache.handle.rename(dump_path, dirs.local_cache.handle, sub_path, io); |
| ... | @@ -3876,9 +3875,9 @@ fn buildOutputType( | ... | @@ -3876,9 +3875,9 @@ fn buildOutputType( |
| 3876 | for (mod.cc_argv) |cc_arg| test_exec_args.appendAssumeCapacity(cc_arg); | 3875 | for (mod.cc_argv) |cc_arg| test_exec_args.appendAssumeCapacity(cc_arg); |
| 3877 | for (mod.deps) |dep| try test_exec_args.appendSlice(arena, &.{ | 3876 | for (mod.deps) |dep| try test_exec_args.appendSlice(arena, &.{ |
| 3878 | "--dep", | 3877 | "--dep", |
| 3879 | if (std.mem.eql(u8, dep.key, dep.value)) dep.value else try std.fmt.allocPrint(arena, "{s}={s}", .{ dep.key, dep.value }), | 3878 | if (std.mem.eql(u8, dep.key, dep.value)) dep.value else try arena.print("{s}={s}", .{ dep.key, dep.value }), |
| 3880 | }); | 3879 | }); |
| 3881 | try test_exec_args.append(arena, try std.fmt.allocPrint(arena, "-M{s}", .{mod_name})); | 3880 | try test_exec_args.append(arena, try arena.print("-M{s}", .{mod_name})); |
| 3882 | } | 3881 | } |
| 3883 | 3882 | ||
| 3884 | try test_exec_args.ensureUnusedCapacity(arena, comp.global_cc_argv.len); | 3883 | try test_exec_args.ensureUnusedCapacity(arena, comp.global_cc_argv.len); |
| ... | @@ -4573,7 +4572,7 @@ fn runOrTest( | ... | @@ -4573,7 +4572,7 @@ fn runOrTest( |
| 4573 | try argv.append(exe_path); | 4572 | try argv.append(exe_path); |
| 4574 | if (arg_mode == .zig_test) { | 4573 | if (arg_mode == .zig_test) { |
| 4575 | try argv.append( | 4574 | try argv.append( |
| 4576 | try allocPrint(arena, "--seed=0x{x}", .{randInt(io, u32)}), | 4575 | try arena.print("--seed=0x{x}", .{randInt(io, u32)}), |
| 4577 | ); | 4576 | ); |
| 4578 | } | 4577 | } |
| 4579 | } else { | 4578 | } else { |
| ... | @@ -4781,7 +4780,7 @@ fn cmdTranslateC( | ... | @@ -4781,7 +4780,7 @@ fn cmdTranslateC( |
| 4781 | assert(comp.c_source_files.len == 1); | 4780 | assert(comp.c_source_files.len == 1); |
| 4782 | const c_source_file = comp.c_source_files[0]; | 4781 | const c_source_file = comp.c_source_files[0]; |
| 4783 | 4782 | ||
| 4784 | const translated_basename = try allocPrint(arena, "{s}.zig", .{comp.root_name}); | 4783 | const translated_basename = try arena.print("{s}.zig", .{comp.root_name}); |
| 4785 | 4784 | ||
| 4786 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(comp.root_mod); | 4785 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(comp.root_mod); |
| 4787 | man.want_shared_lock = false; | 4786 | man.want_shared_lock = false; |
| ... | @@ -4890,7 +4889,7 @@ fn jitCmd( | ... | @@ -4890,7 +4889,7 @@ fn jitCmd( |
| 4890 | 4889 | ||
| 4891 | const root_prog_node = std.Progress.start(io, .{ | 4890 | const root_prog_node = std.Progress.start(io, .{ |
| 4892 | .disable_printing = (color == .off), | 4891 | .disable_printing = (color == .off), |
| 4893 | .root_name = try allocPrint(arena, "Compiling {s} (first time setup)", .{options.cmd_name}), | 4892 | .root_name = try arena.print("Compiling {s} (first time setup)", .{options.cmd_name}), |
| 4894 | }); | 4893 | }); |
| 4895 | defer root_prog_node.end(); | 4894 | defer root_prog_node.end(); |
| 4896 | 4895 | ||
| ... | @@ -5053,13 +5052,13 @@ fn jitCmdInner( | ... | @@ -5053,13 +5052,13 @@ fn jitCmdInner( |
| 5053 | if (options.prepend_cmd) |cmd| | 5052 | if (options.prepend_cmd) |cmd| |
| 5054 | child_argv.appendAssumeCapacity(cmd); | 5053 | child_argv.appendAssumeCapacity(cmd); |
| 5055 | if (options.prepend_zig_lib_dir_path) | 5054 | if (options.prepend_zig_lib_dir_path) |
| 5056 | child_argv.appendAssumeCapacity(try allocPrint(arena, "--zig-lib={s}", .{dirs.zig_lib.path.?})); | 5055 | child_argv.appendAssumeCapacity(try arena.print("--zig-lib={s}", .{dirs.zig_lib.path.?})); |
| 5057 | if (options.prepend_zig_exe_path) | 5056 | if (options.prepend_zig_exe_path) |
| 5058 | child_argv.appendAssumeCapacity(try allocPrint(arena, "--zig={s}", .{self_exe_path})); | 5057 | child_argv.appendAssumeCapacity(try arena.print("--zig={s}", .{self_exe_path})); |
| 5059 | if (options.prepend_global_cache_path) | 5058 | if (options.prepend_global_cache_path) |
| 5060 | child_argv.appendAssumeCapacity(try allocPrint(arena, "--global-cache={s}", .{dirs.global_cache.path.?})); | 5059 | child_argv.appendAssumeCapacity(try arena.print("--global-cache={s}", .{dirs.global_cache.path.?})); |
| 5061 | if (options.prepend_seed) | 5060 | if (options.prepend_seed) |
| 5062 | child_argv.appendAssumeCapacity(try allocPrint(arena, "--seed=0x{x}", .{randInt(io, u32)})); | 5061 | child_argv.appendAssumeCapacity(try arena.print("--seed=0x{x}", .{randInt(io, u32)})); |
| 5063 | 5062 | ||
| 5064 | child_argv.appendSliceAssumeCapacity(args); | 5063 | child_argv.appendSliceAssumeCapacity(args); |
| 5065 | 5064 |