authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-18 15:21:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:20-07:00
log38f2172b0a31ec09a39c3222fd7cde2f2802ae8e
treecf0530603688d3269e168b0231444d36b5e17f7c
parenta3ff4d9b4584b872289f67e94ffa2f0aba9c4257

fix memory leak in addModuleTableToCacheHash


1 files changed, 7 insertions(+), 4 deletions(-)

src/Compilation.zig+7-4
...@@ -1104,6 +1104,7 @@ fn addModuleTableToCacheHash(...@@ -1104,6 +1104,7 @@ fn addModuleTableToCacheHash(
1104 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },1104 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },
1105) (error{OutOfMemory} || std.os.GetCwdError)!void {1105) (error{OutOfMemory} || std.os.GetCwdError)!void {
1106 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};1106 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
1107 defer seen_table.deinit(gpa);
1107 try seen_table.put(gpa, root_mod, {});1108 try seen_table.put(gpa, root_mod, {});
11081109
1109 const SortByName = struct {1110 const SortByName = struct {
...@@ -6172,6 +6173,8 @@ fn buildOutputFromZig(...@@ -6172,6 +6173,8 @@ fn buildOutputFromZig(
61726173
6173 const lf = comp.bin_file.?;6174 const lf = comp.bin_file.?;
6174 const unwind_tables = if (lf.cast(link.File.Elf)) |elf| elf.eh_frame_hdr else false;6175 const unwind_tables = if (lf.cast(link.File.Elf)) |elf| elf.eh_frame_hdr else false;
6176 const strip = comp.compilerRtStrip();
6177 const optimize_mode = comp.compilerRtOptMode();
61756178
6176 const config = try Config.resolve(.{6179 const config = try Config.resolve(.{
6177 .output_mode = output_mode,6180 .output_mode = output_mode,
...@@ -6180,8 +6183,8 @@ fn buildOutputFromZig(...@@ -6180,8 +6183,8 @@ fn buildOutputFromZig(
6180 .is_test = false,6183 .is_test = false,
6181 .have_zcu = true,6184 .have_zcu = true,
6182 .emit_bin = true,6185 .emit_bin = true,
6183 .root_optimize_mode = comp.compilerRtOptMode(),6186 .root_optimize_mode = optimize_mode,
6184 .root_strip = comp.compilerRtStrip(),6187 .root_strip = strip,
6185 .link_libc = comp.config.link_libc,6188 .link_libc = comp.config.link_libc,
6186 .any_unwind_tables = unwind_tables,6189 .any_unwind_tables = unwind_tables,
6187 });6190 });
...@@ -6195,14 +6198,14 @@ fn buildOutputFromZig(...@@ -6195,14 +6198,14 @@ fn buildOutputFromZig(
6195 .fully_qualified_name = "root",6198 .fully_qualified_name = "root",
6196 .inherited = .{6199 .inherited = .{
6197 .resolved_target = comp.root_mod.resolved_target,6200 .resolved_target = comp.root_mod.resolved_target,
6198 .strip = comp.compilerRtStrip(),6201 .strip = strip,
6199 .stack_check = false,6202 .stack_check = false,
6200 .stack_protector = 0,6203 .stack_protector = 0,
6201 .red_zone = comp.root_mod.red_zone,6204 .red_zone = comp.root_mod.red_zone,
6202 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,6205 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
6203 .unwind_tables = unwind_tables,6206 .unwind_tables = unwind_tables,
6204 .pic = comp.root_mod.pic,6207 .pic = comp.root_mod.pic,
6205 .optimize_mode = comp.compilerRtOptMode(),6208 .optimize_mode = optimize_mode,
6206 .structured_cfg = comp.root_mod.structured_cfg,6209 .structured_cfg = comp.root_mod.structured_cfg,
6207 },6210 },
6208 .global = config,6211 .global = config,