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/libs | |
| 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/libs')
| -rw-r--r-- | src/libs/freebsd.zig | 4 | ||||
| -rw-r--r-- | src/libs/glibc.zig | 6 | ||||
| -rw-r--r-- | src/libs/libcxx.zig | 4 | ||||
| -rw-r--r-- | src/libs/libtsan.zig | 2 | ||||
| -rw-r--r-- | src/libs/libunwind.zig | 2 | ||||
| -rw-r--r-- | src/libs/mingw.zig | 6 | ||||
| -rw-r--r-- | src/libs/musl.zig | 2 | ||||
| -rw-r--r-- | src/libs/netbsd.zig | 4 |
8 files changed, 15 insertions, 15 deletions
diff --git a/src/libs/freebsd.zig b/src/libs/freebsd.zig index f6195ffa91..55d097b71b 100644 --- a/src/libs/freebsd.zig +++ b/src/libs/freebsd.zig @@ -66,7 +66,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre defer arena_allocator.deinit(); const arena = arena_allocator.allocator(); - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; // In all cases in this function, we add the C compiler flags to // cache_exempt_flags rather than extra_flags, because these arguments @@ -407,7 +407,7 @@ pub const BuiltSharedObjects = struct { const all_map_basename = "all.map"; -fn wordDirective(target: std.Target) []const u8 { +fn wordDirective(target: *const std.Target) []const u8 { // Based on its description in the GNU `as` manual, you might assume that `.word` is sized // according to the target word size. But no; that would just make too much sense. return if (target.ptrBitWidth() == 64) ".quad" else ".long"; diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig index 8031827a9d..da6ee74962 100644 --- a/src/libs/glibc.zig +++ b/src/libs/glibc.zig @@ -172,7 +172,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre defer arena_allocator.deinit(); const arena = arena_allocator.allocator(); - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const target_ver = target.os.versionRange().gnuLibCVersion().?; const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt; const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt; @@ -485,7 +485,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ fn add_include_dirs_arch( arena: Allocator, args: *std.ArrayList([]const u8), - target: std.Target, + target: *const std.Target, opt_nptl: ?[]const u8, dir: []const u8, ) error{OutOfMemory}!void { @@ -649,7 +649,7 @@ pub const BuiltSharedObjects = struct { const all_map_basename = "all.map"; -fn wordDirective(target: std.Target) []const u8 { +fn wordDirective(target: *const std.Target) []const u8 { // Based on its description in the GNU `as` manual, you might assume that `.word` is sized // according to the target word size. But no; that would just make too much sense. return if (target.ptrBitWidth() == 64) ".quad" else ".long"; diff --git a/src/libs/libcxx.zig b/src/libs/libcxx.zig index 0009bfe120..f26f27732b 100644 --- a/src/libs/libcxx.zig +++ b/src/libs/libcxx.zig @@ -121,7 +121,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError! const root_name = "c++"; const output_mode = .Lib; const link_mode = .static; - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const cxxabi_include_path = try comp.dirs.zig_lib.join(arena, &.{ "libcxxabi", "include" }); const cxx_include_path = try comp.dirs.zig_lib.join(arena, &.{ "libcxx", "include" }); @@ -314,7 +314,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr const root_name = "c++abi"; const output_mode = .Lib; const link_mode = .static; - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const cxxabi_include_path = try comp.dirs.zig_lib.join(arena, &.{ "libcxxabi", "include" }); const cxx_include_path = try comp.dirs.zig_lib.join(arena, &.{ "libcxx", "include" }); diff --git a/src/libs/libtsan.zig b/src/libs/libtsan.zig index f2cd6831f7..36ca5faa25 100644 --- a/src/libs/libtsan.zig +++ b/src/libs/libtsan.zig @@ -324,7 +324,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo comp.tsan_lib = crt_file; } -fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { +fn addCcArgs(target: *const std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { try args.appendSlice(&[_][]const u8{ "-nostdinc++", "-fvisibility=hidden", diff --git a/src/libs/libunwind.zig b/src/libs/libunwind.zig index 711d63ebbc..430ff59748 100644 --- a/src/libs/libunwind.zig +++ b/src/libs/libunwind.zig @@ -27,7 +27,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr const arena = arena_allocator.allocator(); const output_mode = .Lib; - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async"; const config = Compilation.Config.resolve(.{ diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 9454a9af25..c978a651a0 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -299,7 +299,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { var aro_comp = aro.Compilation.init(gpa, std.fs.cwd()); defer aro_comp.deinit(); - aro_comp.target = target; + aro_comp.target = target.*; const include_dir = try comp.dirs.zig_lib.join(arena, &.{ "libc", "mingw", "def-include" }); @@ -373,7 +373,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { pub fn libExists( allocator: Allocator, - target: std.Target, + target: *const std.Target, zig_lib_directory: Cache.Directory, lib_name: []const u8, ) !bool { @@ -389,7 +389,7 @@ pub fn libExists( /// see if a .def file exists. fn findDef( allocator: Allocator, - target: std.Target, + target: *const std.Target, zig_lib_directory: Cache.Directory, lib_name: []const u8, ) ![]u8 { diff --git a/src/libs/musl.zig b/src/libs/musl.zig index 7c4e71c974..b6ef84ac3b 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -193,7 +193,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro .link_libc = false, }); - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi); const time32 = for (time32_compat_arch_list) |time32_compat_arch| { if (mem.eql(u8, arch_name, time32_compat_arch)) break true; diff --git a/src/libs/netbsd.zig b/src/libs/netbsd.zig index fdab27f217..38570c43a6 100644 --- a/src/libs/netbsd.zig +++ b/src/libs/netbsd.zig @@ -58,7 +58,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre defer arena_allocator.deinit(); const arena = arena_allocator.allocator(); - const target = comp.root_mod.resolved_target.result; + const target = &comp.root_mod.resolved_target.result; const target_version = target.os.version_range.semver.min; // In all cases in this function, we add the C compiler flags to @@ -353,7 +353,7 @@ pub const BuiltSharedObjects = struct { } }; -fn wordDirective(target: std.Target) []const u8 { +fn wordDirective(target: *const std.Target) []const u8 { // Based on its description in the GNU `as` manual, you might assume that `.word` is sized // according to the target word size. But no; that would just make too much sense. return if (target.ptrBitWidth() == 64) ".quad" else ".long"; |
