authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-15 20:28:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:20-07:00
log48d5861f9256dfd1c5357dd6f2a023e700de16e4
tree72534a37dff36062ba16fc86be90997d3f16ef22
parent638db680f4c6380bb193da520f29a7c587bfb719

fix more compilation errors introduced by this branch


14 files changed, 113 insertions(+), 85 deletions(-)

src/Compilation.zig+36-8
......@@ -893,6 +893,12 @@ const CacheUse = union(CacheMode) {
893893 whole.lock = null;
894894 }
895895 }
896
897 fn moveLock(whole: *Whole) Cache.Lock {
898 const result = whole.lock.?;
899 whole.lock = null;
900 return result;
901 }
896902 };
897903
898904 const Incremental = struct {
......@@ -939,7 +945,9 @@ pub const InitOptions = struct {
939945 main_mod: ?*Package.Module = null,
940946 /// This is provided so that the API user has a chance to tweak the
941947 /// per-module settings of the standard library.
942 std_mod: *Package.Module,
948 /// When this is null, a default configuration of the std lib is created
949 /// based on the settings of root_mod.
950 std_mod: ?*Package.Module = null,
943951 root_name: []const u8,
944952 sysroot: ?[]const u8 = null,
945953 /// `null` means to not emit a binary file.
......@@ -1381,13 +1389,30 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
13811389 break :eh eh;
13821390 } else null;
13831391
1392 const std_mod = options.std_mod orelse try Package.Module.create(arena, .{
1393 .global_cache_directory = options.global_cache_directory,
1394 .paths = .{
1395 .root = .{
1396 .root_dir = options.zig_lib_directory,
1397 .sub_path = "std",
1398 },
1399 .root_src_path = "std.zig",
1400 },
1401 .fully_qualified_name = "std",
1402 .cc_argv = &.{},
1403 .inherited = .{},
1404 .global = options.config,
1405 .parent = options.root_mod,
1406 .builtin_mod = options.root_mod.deps.get("builtin").?,
1407 });
1408
13841409 const zcu = try arena.create(Module);
13851410 zcu.* = .{
13861411 .gpa = gpa,
13871412 .comp = comp,
13881413 .main_mod = options.main_mod orelse options.root_mod,
13891414 .root_mod = options.root_mod,
1390 .std_mod = options.std_mod,
1415 .std_mod = std_mod,
13911416 .global_zir_cache = global_zir_cache,
13921417 .local_zir_cache = local_zir_cache,
13931418 .emit_h = emit_h,
......@@ -6215,7 +6240,7 @@ fn buildOutputFromZig(
62156240 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(gpa, &.{
62166241 sub_compilation.bin_file.?.emit.sub_path,
62176242 }),
6218 .lock = sub_compilation.bin_file.toOwnedLock(),
6243 .lock = sub_compilation.bin_file.?.toOwnedLock(),
62196244 };
62206245}
62216246
......@@ -6317,13 +6342,16 @@ pub fn build_crt_file(
63176342 try comp.updateSubCompilation(sub_compilation, misc_task_tag, prog_node);
63186343
63196344 try comp.crt_files.ensureUnusedCapacity(gpa, 1);
6345 comp.crt_files.putAssumeCapacityNoClobber(basename, try sub_compilation.toCrtFile());
6346}
63206347
6321 comp.crt_files.putAssumeCapacityNoClobber(basename, .{
6322 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(gpa, &.{
6323 sub_compilation.bin_file.?.emit.sub_path,
6348pub fn toCrtFile(comp: *Compilation) Allocator.Error!CRTFile {
6349 return .{
6350 .full_object_path = try comp.local_cache_directory.join(comp.gpa, &.{
6351 comp.cache_use.whole.bin_sub_path.?,
63246352 }),
6325 .lock = sub_compilation.bin_file.toOwnedLock(),
6326 });
6353 .lock = comp.cache_use.whole.moveLock(),
6354 };
63276355}
63286356
63296357pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
src/arch/aarch64/CodeGen.zig+1-1
......@@ -6332,7 +6332,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
63326332
63336333/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
63346334fn wantSafety(self: *Self) bool {
6335 return switch (self.bin_file.options.optimize_mode) {
6335 return switch (self.bin_file.comp.root_mod.optimize_mode) {
63366336 .Debug => true,
63376337 .ReleaseSafe => true,
63386338 .ReleaseFast => false,
src/arch/arm/CodeGen.zig+1-1
......@@ -6281,7 +6281,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
62816281
62826282/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
62836283fn wantSafety(self: *Self) bool {
6284 return switch (self.bin_file.options.optimize_mode) {
6284 return switch (self.bin_file.comp.root_mod.optimize_mode) {
62856285 .Debug => true,
62866286 .ReleaseSafe => true,
62876287 .ReleaseFast => false,
src/arch/riscv64/CodeGen.zig+1-1
......@@ -2708,7 +2708,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
27082708
27092709/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
27102710fn wantSafety(self: *Self) bool {
2711 return switch (self.bin_file.options.optimize_mode) {
2711 return switch (self.bin_file.comp.root_mod.optimize_mode) {
27122712 .Debug => true,
27132713 .ReleaseSafe => true,
27142714 .ReleaseFast => false,
src/arch/sparc64/CodeGen.zig+1-1
......@@ -4857,7 +4857,7 @@ fn truncRegister(
48574857
48584858/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
48594859fn wantSafety(self: *Self) bool {
4860 return switch (self.bin_file.options.optimize_mode) {
4860 return switch (self.bin_file.comp.root_mod.optimize_mode) {
48614861 .Debug => true,
48624862 .ReleaseSafe => true,
48634863 .ReleaseFast => false,
src/arch/x86_64/CodeGen.zig+6-3
......@@ -25,7 +25,9 @@ const Emit = @import("Emit.zig");
2525const Liveness = @import("../../Liveness.zig");
2626const Lower = @import("Lower.zig");
2727const Mir = @import("Mir.zig");
28const Package = @import("../../Package.zig");
2829const Module = @import("../../Module.zig");
30const Zcu = Module;
2931const InternPool = @import("../../InternPool.zig");
3032const Alignment = InternPool.Alignment;
3133const Target = std.Target;
......@@ -56,6 +58,7 @@ bin_file: *link.File,
5658debug_output: DebugInfoOutput,
5759target: *const std.Target,
5860owner: Owner,
61mod: *Package.Module,
5962err_msg: ?*ErrorMsg,
6063args: []MCValue,
6164va_info: union {
......@@ -10906,7 +10909,7 @@ fn genCall(self: *Self, info: union(enum) {
1090610909 if (self.bin_file.cast(link.File.Elf)) |elf_file| {
1090710910 const sym_index = try elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, func.owner_decl);
1090810911 const sym = elf_file.symbol(sym_index);
10909 if (self.bin_file.options.pic) {
10912 if (self.mod.pic) {
1091010913 const callee_reg: Register = switch (resolved_cc) {
1091110914 .SysV => callee: {
1091210915 if (!fn_info.is_var_args) break :callee .rax;
......@@ -13819,7 +13822,7 @@ fn genLazySymbolRef(
1381913822 const sym_index = elf_file.zigObjectPtr().?.getOrCreateMetadataForLazySymbol(elf_file, lazy_sym) catch |err|
1382013823 return self.fail("{s} creating lazy symbol", .{@errorName(err)});
1382113824 const sym = elf_file.symbol(sym_index);
13822 if (self.bin_file.options.pic) {
13825 if (self.mod.pic) {
1382313826 switch (tag) {
1382413827 .lea, .call => try self.genSetReg(reg, Type.usize, .{
1382513828 .load_symbol = .{ .sym = sym.esym_index },
......@@ -16062,7 +16065,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
1606216065 const const_mcv = try self.genTypedValue(.{ .ty = ty, .val = Value.fromInterned(ip_index) });
1606316066 switch (const_mcv) {
1606416067 .lea_tlv => |tlv_sym| if (self.bin_file.cast(link.File.Elf)) |_| {
16065 if (self.bin_file.options.pic) {
16068 if (self.mod.pic) {
1606616069 try self.spillRegisters(&.{ .rdi, .rax });
1606716070 } else {
1606816071 try self.spillRegisters(&.{.rax});
src/arch/x86_64/Emit.zig+3-3
......@@ -103,10 +103,10 @@ pub fn emitMir(emit: *Emit) Error!void {
103103 });
104104 },
105105 .linker_reloc => |data| if (emit.lower.bin_file.cast(link.File.Elf)) |elf_file| {
106 const is_obj_or_static_lib = switch (emit.lower.bin_file.options.output_mode) {
106 const is_obj_or_static_lib = switch (emit.lower.output_mode) {
107107 .Exe => false,
108108 .Obj => true,
109 .Lib => emit.lower.bin_file.options.link_mode == .Static,
109 .Lib => emit.lower.link_mode == .Static,
110110 };
111111 const atom = elf_file.symbol(data.atom_index).atom(elf_file).?;
112112 const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index);
......@@ -114,7 +114,7 @@ pub fn emitMir(emit: *Emit) Error!void {
114114 if (sym.flags.needs_zig_got and !is_obj_or_static_lib) {
115115 _ = try sym.getOrCreateZigGotEntry(sym_index, elf_file);
116116 }
117 if (emit.lower.bin_file.options.pic) {
117 if (emit.lower.pic) {
118118 const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib)
119119 link.File.Elf.R_X86_64_ZIG_GOTPCREL
120120 else if (sym.flags.needs_got)
src/arch/x86_64/Lower.zig+7-4
......@@ -1,6 +1,9 @@
11//! This file contains the functionality for lowering x86_64 MIR to Instructions
22
33bin_file: *link.File,
4output_mode: std.builtin.OutputMode,
5link_mode: std.builtin.LinkMode,
6pic: bool,
47allocator: Allocator,
58mir: Mir,
69cc: std.builtin.CallingConvention,
......@@ -336,10 +339,10 @@ fn isTls(sym: bits.Symbol, ctx: *link.File) bool {
336339}
337340
338341fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) Error!void {
339 const is_obj_or_static_lib = switch (lower.bin_file.options.output_mode) {
342 const is_obj_or_static_lib = switch (lower.output_mode) {
340343 .Exe => false,
341344 .Obj => true,
342 .Lib => lower.bin_file.options.link_mode == .Static,
345 .Lib => lower.link_mode == .Static,
343346 };
344347
345348 const emit_prefix = prefix;
......@@ -358,7 +361,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
358361
359362 if (isTls(sym, lower.bin_file)) {
360363 // TODO handle extern TLS vars, i.e., emit GD model
361 if (lower.bin_file.options.pic) {
364 if (lower.pic) {
362365 // Here, we currently assume local dynamic TLS vars, and so
363366 // we emit LD model.
364367 _ = lower.reloc(.{ .linker_tlsld = sym });
......@@ -403,7 +406,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
403406 }
404407
405408 _ = lower.reloc(.{ .linker_reloc = sym });
406 break :op if (lower.bin_file.options.pic) switch (mnemonic) {
409 break :op if (lower.pic) switch (mnemonic) {
407410 .lea => {
408411 break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) };
409412 },
src/libcxx.zig+2-12
......@@ -299,12 +299,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
299299 try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node);
300300
301301 assert(comp.libcxx_static_lib == null);
302 comp.libcxx_static_lib = Compilation.CRTFile{
303 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{
304 sub_compilation.bin_file.?.emit.sub_path,
305 }),
306 .lock = sub_compilation.bin_file.toOwnedLock(),
307 };
302 comp.libcxx_static_lib = try sub_compilation.toCrtFile();
308303}
309304
310305pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
......@@ -489,10 +484,5 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
489484 try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node);
490485
491486 assert(comp.libcxxabi_static_lib == null);
492 comp.libcxxabi_static_lib = Compilation.CRTFile{
493 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
494 sub_compilation.bin_file.?.emit.sub_path,
495 }),
496 .lock = sub_compilation.bin_file.toOwnedLock(),
497 };
487 comp.libcxxabi_static_lib = try sub_compilation.toCrtFile();
498488}
src/libtsan.zig+1-6
......@@ -268,12 +268,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
268268 try comp.updateSubCompilation(sub_compilation, .libtsan, prog_node);
269269
270270 assert(comp.tsan_static_lib == null);
271 comp.tsan_static_lib = Compilation.CRTFile{
272 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
273 sub_compilation.bin_file.?.emit.sub_path,
274 }),
275 .lock = sub_compilation.bin_file.toOwnedLock(),
276 };
271 comp.tsan_static_lib = try sub_compilation.toCrtFile();
277272}
278273
279274const tsan_sources = [_][]const u8{
src/libunwind.zig+1-6
......@@ -151,12 +151,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
151151
152152 assert(comp.libunwind_static_lib == null);
153153
154 comp.libunwind_static_lib = Compilation.CRTFile{
155 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
156 sub_compilation.bin_file.?.emit.sub_path,
157 }),
158 .lock = sub_compilation.bin_file.toOwnedLock(),
159 };
154 comp.libunwind_static_lib = try sub_compilation.toOwnedLock();
160155}
161156
162157const unwind_src_list = [_][]const u8{
src/link/Elf/synthetic_sections.zig+52-21
......@@ -8,14 +8,16 @@ pub const DynamicSection = struct {
88 }
99
1010 pub fn addNeeded(dt: *DynamicSection, shared: *SharedObject, elf_file: *Elf) !void {
11 const gpa = elf_file.base.allocator;
11 const comp = elf_file.base.comp;
12 const gpa = comp.gpa;
1213 const off = try elf_file.insertDynString(shared.soname());
1314 try dt.needed.append(gpa, off);
1415 }
1516
1617 pub fn setRpath(dt: *DynamicSection, rpath_list: []const []const u8, elf_file: *Elf) !void {
1718 if (rpath_list.len == 0) return;
18 const gpa = elf_file.base.allocator;
19 const comp = elf_file.base.comp;
20 const gpa = comp.gpa;
1921 var rpath = std.ArrayList(u8).init(gpa);
2022 defer rpath.deinit();
2123 for (rpath_list, 0..) |path, i| {
......@@ -248,7 +250,8 @@ pub const ZigGotSection = struct {
248250
249251 pub fn addSymbol(zig_got: *ZigGotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index {
250252 const comp = elf_file.base.comp;
251 const index = try zig_got.allocateEntry(elf_file.base.allocator);
253 const gpa = comp.gpa;
254 const index = try zig_got.allocateEntry(gpa);
252255 const entry = &zig_got.entries.items[index];
253256 entry.* = sym_index;
254257 const symbol = elf_file.symbol(sym_index);
......@@ -349,7 +352,9 @@ pub const ZigGotSection = struct {
349352 }
350353
351354 pub fn addRela(zig_got: ZigGotSection, elf_file: *Elf) !void {
352 try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, zig_got.numRela());
355 const comp = elf_file.base.comp;
356 const gpa = comp.gpa;
357 try elf_file.rela_dyn.ensureUnusedCapacity(gpa, zig_got.numRela());
353358 for (zig_got.entries.items) |entry| {
354359 const symbol = elf_file.symbol(entry);
355360 const offset = symbol.zigGotAddress(elf_file);
......@@ -481,7 +486,8 @@ pub const GotSection = struct {
481486
482487 pub fn addGotSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index {
483488 const comp = elf_file.base.comp;
484 const index = try got.allocateEntry(elf_file.base.allocator);
489 const gpa = comp.gpa;
490 const index = try got.allocateEntry(gpa);
485491 const entry = &got.entries.items[index];
486492 entry.tag = .got;
487493 entry.symbol_index = sym_index;
......@@ -501,8 +507,10 @@ pub const GotSection = struct {
501507 }
502508
503509 pub fn addTlsLdSymbol(got: *GotSection, elf_file: *Elf) !void {
510 const comp = elf_file.base.comp;
511 const gpa = comp.gpa;
504512 assert(got.flags.needs_tlsld);
505 const index = try got.allocateEntry(elf_file.base.allocator);
513 const index = try got.allocateEntry(gpa);
506514 const entry = &got.entries.items[index];
507515 entry.tag = .tlsld;
508516 entry.symbol_index = undefined; // unused
......@@ -511,7 +519,9 @@ pub const GotSection = struct {
511519 }
512520
513521 pub fn addTlsGdSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
514 const index = try got.allocateEntry(elf_file.base.allocator);
522 const comp = elf_file.base.comp;
523 const gpa = comp.gpa;
524 const index = try got.allocateEntry(gpa);
515525 const entry = &got.entries.items[index];
516526 entry.tag = .tlsgd;
517527 entry.symbol_index = sym_index;
......@@ -526,7 +536,9 @@ pub const GotSection = struct {
526536 }
527537
528538 pub fn addGotTpSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
529 const index = try got.allocateEntry(elf_file.base.allocator);
539 const comp = elf_file.base.comp;
540 const gpa = comp.gpa;
541 const index = try got.allocateEntry(gpa);
530542 const entry = &got.entries.items[index];
531543 entry.tag = .gottp;
532544 entry.symbol_index = sym_index;
......@@ -541,7 +553,9 @@ pub const GotSection = struct {
541553 }
542554
543555 pub fn addTlsDescSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
544 const index = try got.allocateEntry(elf_file.base.allocator);
556 const comp = elf_file.base.comp;
557 const gpa = comp.gpa;
558 const index = try got.allocateEntry(gpa);
545559 const entry = &got.entries.items[index];
546560 entry.tag = .tlsdesc;
547561 entry.symbol_index = sym_index;
......@@ -628,8 +642,9 @@ pub const GotSection = struct {
628642
629643 pub fn addRela(got: GotSection, elf_file: *Elf) !void {
630644 const comp = elf_file.base.comp;
645 const gpa = comp.gpa;
631646 const is_dyn_lib = elf_file.isDynLib();
632 try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, got.numRela(elf_file));
647 try elf_file.rela_dyn.ensureUnusedCapacity(gpa, got.numRela(elf_file));
633648
634649 for (got.entries.items) |entry| {
635650 const symbol = switch (entry.tag) {
......@@ -847,6 +862,8 @@ pub const PltSection = struct {
847862 }
848863
849864 pub fn addSymbol(plt: *PltSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
865 const comp = elf_file.base.comp;
866 const gpa = comp.gpa;
850867 const index = @as(u32, @intCast(plt.symbols.items.len));
851868 const symbol = elf_file.symbol(sym_index);
852869 symbol.flags.has_plt = true;
......@@ -855,7 +872,7 @@ pub const PltSection = struct {
855872 new_extra.plt = index;
856873 symbol.setExtra(new_extra, elf_file);
857874 } else try symbol.addExtra(.{ .plt = index }, elf_file);
858 try plt.symbols.append(elf_file.base.allocator, sym_index);
875 try plt.symbols.append(gpa, sym_index);
859876 }
860877
861878 pub fn size(plt: PltSection) usize {
......@@ -895,7 +912,9 @@ pub const PltSection = struct {
895912 }
896913
897914 pub fn addRela(plt: PltSection, elf_file: *Elf) !void {
898 try elf_file.rela_plt.ensureUnusedCapacity(elf_file.base.allocator, plt.numRela());
915 const comp = elf_file.base.comp;
916 const gpa = comp.gpa;
917 try elf_file.rela_plt.ensureUnusedCapacity(gpa, plt.numRela());
899918 for (plt.symbols.items) |sym_index| {
900919 const sym = elf_file.symbol(sym_index);
901920 assert(sym.flags.import);
......@@ -1010,6 +1029,8 @@ pub const PltGotSection = struct {
10101029 }
10111030
10121031 pub fn addSymbol(plt_got: *PltGotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
1032 const comp = elf_file.base.comp;
1033 const gpa = comp.gpa;
10131034 const index = @as(u32, @intCast(plt_got.symbols.items.len));
10141035 const symbol = elf_file.symbol(sym_index);
10151036 symbol.flags.has_plt = true;
......@@ -1019,7 +1040,7 @@ pub const PltGotSection = struct {
10191040 new_extra.plt_got = index;
10201041 symbol.setExtra(new_extra, elf_file);
10211042 } else try symbol.addExtra(.{ .plt_got = index }, elf_file);
1022 try plt_got.symbols.append(elf_file.base.allocator, sym_index);
1043 try plt_got.symbols.append(gpa, sym_index);
10231044 }
10241045
10251046 pub fn size(plt_got: PltGotSection) usize {
......@@ -1077,6 +1098,8 @@ pub const CopyRelSection = struct {
10771098 }
10781099
10791100 pub fn addSymbol(copy_rel: *CopyRelSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
1101 const comp = elf_file.base.comp;
1102 const gpa = comp.gpa;
10801103 const index = @as(u32, @intCast(copy_rel.symbols.items.len));
10811104 const symbol = elf_file.symbol(sym_index);
10821105 symbol.flags.import = true;
......@@ -1089,7 +1112,7 @@ pub const CopyRelSection = struct {
10891112 new_extra.copy_rel = index;
10901113 symbol.setExtra(new_extra, elf_file);
10911114 } else try symbol.addExtra(.{ .copy_rel = index }, elf_file);
1092 try copy_rel.symbols.append(elf_file.base.allocator, sym_index);
1115 try copy_rel.symbols.append(gpa, sym_index);
10931116
10941117 const shared_object = symbol.file(elf_file).?.shared_object;
10951118 if (shared_object.aliases == null) {
......@@ -1129,7 +1152,9 @@ pub const CopyRelSection = struct {
11291152 }
11301153
11311154 pub fn addRela(copy_rel: CopyRelSection, elf_file: *Elf) !void {
1132 try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, copy_rel.numRela());
1155 const comp = elf_file.base.comp;
1156 const gpa = comp.gpa;
1157 try elf_file.rela_dyn.ensureUnusedCapacity(gpa, copy_rel.numRela());
11331158 for (copy_rel.symbols.items) |sym_index| {
11341159 const sym = elf_file.symbol(sym_index);
11351160 assert(sym.flags.import and sym.flags.has_copy_rel);
......@@ -1162,7 +1187,8 @@ pub const DynsymSection = struct {
11621187 }
11631188
11641189 pub fn addSymbol(dynsym: *DynsymSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
1165 const gpa = elf_file.base.allocator;
1190 const comp = elf_file.base.comp;
1191 const gpa = comp.gpa;
11661192 const index = @as(u32, @intCast(dynsym.entries.items.len + 1));
11671193 const sym = elf_file.symbol(sym_index);
11681194 sym.flags.has_dynamic = true;
......@@ -1244,7 +1270,8 @@ pub const HashSection = struct {
12441270 pub fn generate(hs: *HashSection, elf_file: *Elf) !void {
12451271 if (elf_file.dynsym.count() == 1) return;
12461272
1247 const gpa = elf_file.base.allocator;
1273 const comp = elf_file.base.comp;
1274 const gpa = comp.gpa;
12481275 const nsyms = elf_file.dynsym.count();
12491276
12501277 var buckets = try gpa.alloc(u32, nsyms);
......@@ -1332,7 +1359,8 @@ pub const GnuHashSection = struct {
13321359 try cwriter.writeInt(u32, hash.num_bloom, .little);
13331360 try cwriter.writeInt(u32, bloom_shift, .little);
13341361
1335 const gpa = elf_file.base.allocator;
1362 const comp = elf_file.base.comp;
1363 const gpa = comp.gpa;
13361364 const hashes = try gpa.alloc(u32, exports.len);
13371365 defer gpa.free(hashes);
13381366 const indices = try gpa.alloc(u32, exports.len);
......@@ -1434,7 +1462,8 @@ pub const VerneedSection = struct {
14341462 }
14351463 };
14361464
1437 const gpa = elf_file.base.allocator;
1465 const comp = elf_file.base.comp;
1466 const gpa = comp.gpa;
14381467 var verneed = std.ArrayList(VersionedSymbol).init(gpa);
14391468 defer verneed.deinit();
14401469 try verneed.ensureTotalCapacity(dynsyms.len);
......@@ -1490,7 +1519,8 @@ pub const VerneedSection = struct {
14901519 }
14911520
14921521 fn addVerneed(vern: *VerneedSection, soname: []const u8, elf_file: *Elf) !*elf.Elf64_Verneed {
1493 const gpa = elf_file.base.allocator;
1522 const comp = elf_file.base.comp;
1523 const gpa = comp.gpa;
14941524 const sym = try vern.verneed.addOne(gpa);
14951525 sym.* = .{
14961526 .vn_version = 1,
......@@ -1508,7 +1538,8 @@ pub const VerneedSection = struct {
15081538 version: [:0]const u8,
15091539 elf_file: *Elf,
15101540 ) !elf.Elf64_Vernaux {
1511 const gpa = elf_file.base.allocator;
1541 const comp = elf_file.base.comp;
1542 const gpa = comp.gpa;
15121543 const sym = try vern.vernaux.addOne(gpa);
15131544 sym.* = .{
15141545 .vna_hash = HashSection.hasher(version),
src/main.zig-17
......@@ -5242,22 +5242,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
52425242 });
52435243
52445244 const builtin_mod = root_mod.getBuiltinDependency();
5245 const std_mod = try Package.Module.create(arena, .{
5246 .global_cache_directory = global_cache_directory,
5247 .paths = .{
5248 .root = .{
5249 .root_dir = zig_lib_directory,
5250 .sub_path = "std",
5251 },
5252 .root_src_path = "std.zig",
5253 },
5254 .fully_qualified_name = "std",
5255 .cc_argv = &.{},
5256 .inherited = .{},
5257 .global = config,
5258 .parent = root_mod,
5259 .builtin_mod = builtin_mod,
5260 });
52615245
52625246 const build_mod = try Package.Module.create(arena, .{
52635247 .global_cache_directory = global_cache_directory,
......@@ -5425,7 +5409,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
54255409 .config = config,
54265410 .root_mod = root_mod,
54275411 .main_mod = build_mod,
5428 .std_mod = std_mod,
54295412 .emit_bin = emit_bin,
54305413 .emit_h = null,
54315414 .self_exe_path = self_exe_path,
src/musl.zig+1-1
......@@ -280,7 +280,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
280280 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{
281281 sub_compilation.bin_file.?.emit.sub_path,
282282 }),
283 .lock = sub_compilation.bin_file.toOwnedLock(),
283 .lock = sub_compilation.bin_file.?.toOwnedLock(),
284284 });
285285 },
286286 }