diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-06-13 04:46:30 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-06-19 11:45:06 -0400 |
| commit | 917640810e7f3e18daff9e75b5ecefe761a1896c (patch) | |
| tree | 579e627d695f898d411a3cb1fbc0578d1a763cc2 /src/main.zig | |
| parent | 16d78bc0c024da307c7ab5f6b94622e6b4b37397 (diff) | |
| download | zig-917640810e7f3e18daff9e75b5ecefe761a1896c.tar.gz zig-917640810e7f3e18daff9e75b5ecefe761a1896c.zip | |
Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index 00954b2564..e974621e5e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -340,7 +340,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { dev.check(.targets_command); const host = std.zig.resolveTargetQueryOrFatal(.{}); const stdout = io.getStdOut().writer(); - return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, host); + return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, &host); } else if (mem.eql(u8, cmd, "version")) { dev.check(.version_command); try std.io.getStdOut().writeAll(build_options.version ++ "\n"); @@ -3086,7 +3086,7 @@ fn buildOutputType( else => main_mod, }; - const target = main_mod.resolved_target.result; + const target = &main_mod.resolved_target.result; if (target.cpu.arch == .arc or target.cpu.arch.isNvptx()) { if (emit_bin != .no and create_module.resolved_options.use_llvm) { @@ -3655,7 +3655,7 @@ fn buildOutputType( test_exec_args.items, self_exe_path, arg_mode, - &target, + target, &comp_destroyed, all_args, runtime_args_start, @@ -3800,12 +3800,12 @@ fn createModule( // This block is for initializing the fields of // `Compilation.Config.Options` that require knowledge of the // target (which was just now resolved for the root module above). - const resolved_target = cli_mod.inherited.resolved_target.?; - create_module.opts.resolved_target = resolved_target; + const resolved_target = &cli_mod.inherited.resolved_target.?; + create_module.opts.resolved_target = resolved_target.*; create_module.opts.root_optimize_mode = cli_mod.inherited.optimize_mode; create_module.opts.root_strip = cli_mod.inherited.strip; create_module.opts.root_error_tracing = cli_mod.inherited.error_tracing; - const target = resolved_target.result; + const target = &resolved_target.result; // First, remove libc, libc++, and compiler_rt libraries from the system libraries list. // We need to know whether the set of system libraries contains anything besides these @@ -6482,7 +6482,7 @@ fn warnAboutForeignBinaries( const host_query: std.Target.Query = .{}; const host_target = std.zig.resolveTargetQueryOrFatal(host_query); - switch (std.zig.system.getExternalExecutor(host_target, target, .{ .link_libc = link_libc })) { + switch (std.zig.system.getExternalExecutor(&host_target, target, .{ .link_libc = link_libc })) { .native => return, .rosetta => { const host_name = try host_target.zigTriple(arena); |
