| author | |
| committer | |
| log | 48d5861f9256dfd1c5357dd6f2a023e700de16e4 |
| tree | 72534a37dff36062ba16fc86be90997d3f16ef22 |
| parent | 638db680f4c6380bb193da520f29a7c587bfb719 |
14 files changed, 113 insertions(+), 85 deletions(-)
src/Compilation.zig+36-8| ... | ... | @@ -893,6 +893,12 @@ const CacheUse = union(CacheMode) { |
| 893 | 893 | whole.lock = null; |
| 894 | 894 | } |
| 895 | 895 | } |
| 896 | ||
| 897 | fn moveLock(whole: *Whole) Cache.Lock { | |
| 898 | const result = whole.lock.?; | |
| 899 | whole.lock = null; | |
| 900 | return result; | |
| 901 | } | |
| 896 | 902 | }; |
| 897 | 903 | |
| 898 | 904 | const Incremental = struct { |
| ... | ... | @@ -939,7 +945,9 @@ pub const InitOptions = struct { |
| 939 | 945 | main_mod: ?*Package.Module = null, |
| 940 | 946 | /// This is provided so that the API user has a chance to tweak the |
| 941 | 947 | /// 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, | |
| 943 | 951 | root_name: []const u8, |
| 944 | 952 | sysroot: ?[]const u8 = null, |
| 945 | 953 | /// `null` means to not emit a binary file. |
| ... | ... | @@ -1381,13 +1389,30 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1381 | 1389 | break :eh eh; |
| 1382 | 1390 | } else null; |
| 1383 | 1391 | |
| 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 | ||
| 1384 | 1409 | const zcu = try arena.create(Module); |
| 1385 | 1410 | zcu.* = .{ |
| 1386 | 1411 | .gpa = gpa, |
| 1387 | 1412 | .comp = comp, |
| 1388 | 1413 | .main_mod = options.main_mod orelse options.root_mod, |
| 1389 | 1414 | .root_mod = options.root_mod, |
| 1390 | .std_mod = options.std_mod, | |
| 1415 | .std_mod = std_mod, | |
| 1391 | 1416 | .global_zir_cache = global_zir_cache, |
| 1392 | 1417 | .local_zir_cache = local_zir_cache, |
| 1393 | 1418 | .emit_h = emit_h, |
| ... | ... | @@ -6215,7 +6240,7 @@ fn buildOutputFromZig( |
| 6215 | 6240 | .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(gpa, &.{ |
| 6216 | 6241 | sub_compilation.bin_file.?.emit.sub_path, |
| 6217 | 6242 | }), |
| 6218 | .lock = sub_compilation.bin_file.toOwnedLock(), | |
| 6243 | .lock = sub_compilation.bin_file.?.toOwnedLock(), | |
| 6219 | 6244 | }; |
| 6220 | 6245 | } |
| 6221 | 6246 | |
| ... | ... | @@ -6317,13 +6342,16 @@ pub fn build_crt_file( |
| 6317 | 6342 | try comp.updateSubCompilation(sub_compilation, misc_task_tag, prog_node); |
| 6318 | 6343 | |
| 6319 | 6344 | try comp.crt_files.ensureUnusedCapacity(gpa, 1); |
| 6345 | comp.crt_files.putAssumeCapacityNoClobber(basename, try sub_compilation.toCrtFile()); | |
| 6346 | } | |
| 6320 | 6347 | |
| 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, | |
| 6348 | pub 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.?, | |
| 6324 | 6352 | }), |
| 6325 | .lock = sub_compilation.bin_file.toOwnedLock(), | |
| 6326 | }); | |
| 6353 | .lock = comp.cache_use.whole.moveLock(), | |
| 6354 | }; | |
| 6327 | 6355 | } |
| 6328 | 6356 | |
| 6329 | 6357 | pub 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 { |
| 6332 | 6332 | |
| 6333 | 6333 | /// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`. |
| 6334 | 6334 | fn wantSafety(self: *Self) bool { |
| 6335 | return switch (self.bin_file.options.optimize_mode) { | |
| 6335 | return switch (self.bin_file.comp.root_mod.optimize_mode) { | |
| 6336 | 6336 | .Debug => true, |
| 6337 | 6337 | .ReleaseSafe => true, |
| 6338 | 6338 | .ReleaseFast => false, |
src/arch/arm/CodeGen.zig+1-1| ... | ... | @@ -6281,7 +6281,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 6281 | 6281 | |
| 6282 | 6282 | /// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`. |
| 6283 | 6283 | fn wantSafety(self: *Self) bool { |
| 6284 | return switch (self.bin_file.options.optimize_mode) { | |
| 6284 | return switch (self.bin_file.comp.root_mod.optimize_mode) { | |
| 6285 | 6285 | .Debug => true, |
| 6286 | 6286 | .ReleaseSafe => true, |
| 6287 | 6287 | .ReleaseFast => false, |
src/arch/riscv64/CodeGen.zig+1-1| ... | ... | @@ -2708,7 +2708,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues { |
| 2708 | 2708 | |
| 2709 | 2709 | /// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`. |
| 2710 | 2710 | fn wantSafety(self: *Self) bool { |
| 2711 | return switch (self.bin_file.options.optimize_mode) { | |
| 2711 | return switch (self.bin_file.comp.root_mod.optimize_mode) { | |
| 2712 | 2712 | .Debug => true, |
| 2713 | 2713 | .ReleaseSafe => true, |
| 2714 | 2714 | .ReleaseFast => false, |
src/arch/sparc64/CodeGen.zig+1-1| ... | ... | @@ -4857,7 +4857,7 @@ fn truncRegister( |
| 4857 | 4857 | |
| 4858 | 4858 | /// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`. |
| 4859 | 4859 | fn wantSafety(self: *Self) bool { |
| 4860 | return switch (self.bin_file.options.optimize_mode) { | |
| 4860 | return switch (self.bin_file.comp.root_mod.optimize_mode) { | |
| 4861 | 4861 | .Debug => true, |
| 4862 | 4862 | .ReleaseSafe => true, |
| 4863 | 4863 | .ReleaseFast => false, |
src/arch/x86_64/CodeGen.zig+6-3| ... | ... | @@ -25,7 +25,9 @@ const Emit = @import("Emit.zig"); |
| 25 | 25 | const Liveness = @import("../../Liveness.zig"); |
| 26 | 26 | const Lower = @import("Lower.zig"); |
| 27 | 27 | const Mir = @import("Mir.zig"); |
| 28 | const Package = @import("../../Package.zig"); | |
| 28 | 29 | const Module = @import("../../Module.zig"); |
| 30 | const Zcu = Module; | |
| 29 | 31 | const InternPool = @import("../../InternPool.zig"); |
| 30 | 32 | const Alignment = InternPool.Alignment; |
| 31 | 33 | const Target = std.Target; |
| ... | ... | @@ -56,6 +58,7 @@ bin_file: *link.File, |
| 56 | 58 | debug_output: DebugInfoOutput, |
| 57 | 59 | target: *const std.Target, |
| 58 | 60 | owner: Owner, |
| 61 | mod: *Package.Module, | |
| 59 | 62 | err_msg: ?*ErrorMsg, |
| 60 | 63 | args: []MCValue, |
| 61 | 64 | va_info: union { |
| ... | ... | @@ -10906,7 +10909,7 @@ fn genCall(self: *Self, info: union(enum) { |
| 10906 | 10909 | if (self.bin_file.cast(link.File.Elf)) |elf_file| { |
| 10907 | 10910 | const sym_index = try elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, func.owner_decl); |
| 10908 | 10911 | const sym = elf_file.symbol(sym_index); |
| 10909 | if (self.bin_file.options.pic) { | |
| 10912 | if (self.mod.pic) { | |
| 10910 | 10913 | const callee_reg: Register = switch (resolved_cc) { |
| 10911 | 10914 | .SysV => callee: { |
| 10912 | 10915 | if (!fn_info.is_var_args) break :callee .rax; |
| ... | ... | @@ -13819,7 +13822,7 @@ fn genLazySymbolRef( |
| 13819 | 13822 | const sym_index = elf_file.zigObjectPtr().?.getOrCreateMetadataForLazySymbol(elf_file, lazy_sym) catch |err| |
| 13820 | 13823 | return self.fail("{s} creating lazy symbol", .{@errorName(err)}); |
| 13821 | 13824 | const sym = elf_file.symbol(sym_index); |
| 13822 | if (self.bin_file.options.pic) { | |
| 13825 | if (self.mod.pic) { | |
| 13823 | 13826 | switch (tag) { |
| 13824 | 13827 | .lea, .call => try self.genSetReg(reg, Type.usize, .{ |
| 13825 | 13828 | .load_symbol = .{ .sym = sym.esym_index }, |
| ... | ... | @@ -16062,7 +16065,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue { |
| 16062 | 16065 | const const_mcv = try self.genTypedValue(.{ .ty = ty, .val = Value.fromInterned(ip_index) }); |
| 16063 | 16066 | switch (const_mcv) { |
| 16064 | 16067 | .lea_tlv => |tlv_sym| if (self.bin_file.cast(link.File.Elf)) |_| { |
| 16065 | if (self.bin_file.options.pic) { | |
| 16068 | if (self.mod.pic) { | |
| 16066 | 16069 | try self.spillRegisters(&.{ .rdi, .rax }); |
| 16067 | 16070 | } else { |
| 16068 | 16071 | try self.spillRegisters(&.{.rax}); |
src/arch/x86_64/Emit.zig+3-3| ... | ... | @@ -103,10 +103,10 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 103 | 103 | }); |
| 104 | 104 | }, |
| 105 | 105 | .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) { | |
| 107 | 107 | .Exe => false, |
| 108 | 108 | .Obj => true, |
| 109 | .Lib => emit.lower.bin_file.options.link_mode == .Static, | |
| 109 | .Lib => emit.lower.link_mode == .Static, | |
| 110 | 110 | }; |
| 111 | 111 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; |
| 112 | 112 | const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index); |
| ... | ... | @@ -114,7 +114,7 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 114 | 114 | if (sym.flags.needs_zig_got and !is_obj_or_static_lib) { |
| 115 | 115 | _ = try sym.getOrCreateZigGotEntry(sym_index, elf_file); |
| 116 | 116 | } |
| 117 | if (emit.lower.bin_file.options.pic) { | |
| 117 | if (emit.lower.pic) { | |
| 118 | 118 | const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib) |
| 119 | 119 | link.File.Elf.R_X86_64_ZIG_GOTPCREL |
| 120 | 120 | else if (sym.flags.needs_got) |
src/arch/x86_64/Lower.zig+7-4| ... | ... | @@ -1,6 +1,9 @@ |
| 1 | 1 | //! This file contains the functionality for lowering x86_64 MIR to Instructions |
| 2 | 2 | |
| 3 | 3 | bin_file: *link.File, |
| 4 | output_mode: std.builtin.OutputMode, | |
| 5 | link_mode: std.builtin.LinkMode, | |
| 6 | pic: bool, | |
| 4 | 7 | allocator: Allocator, |
| 5 | 8 | mir: Mir, |
| 6 | 9 | cc: std.builtin.CallingConvention, |
| ... | ... | @@ -336,10 +339,10 @@ fn isTls(sym: bits.Symbol, ctx: *link.File) bool { |
| 336 | 339 | } |
| 337 | 340 | |
| 338 | 341 | fn 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) { | |
| 340 | 343 | .Exe => false, |
| 341 | 344 | .Obj => true, |
| 342 | .Lib => lower.bin_file.options.link_mode == .Static, | |
| 345 | .Lib => lower.link_mode == .Static, | |
| 343 | 346 | }; |
| 344 | 347 | |
| 345 | 348 | const emit_prefix = prefix; |
| ... | ... | @@ -358,7 +361,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) |
| 358 | 361 | |
| 359 | 362 | if (isTls(sym, lower.bin_file)) { |
| 360 | 363 | // TODO handle extern TLS vars, i.e., emit GD model |
| 361 | if (lower.bin_file.options.pic) { | |
| 364 | if (lower.pic) { | |
| 362 | 365 | // Here, we currently assume local dynamic TLS vars, and so |
| 363 | 366 | // we emit LD model. |
| 364 | 367 | _ = lower.reloc(.{ .linker_tlsld = sym }); |
| ... | ... | @@ -403,7 +406,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) |
| 403 | 406 | } |
| 404 | 407 | |
| 405 | 408 | _ = lower.reloc(.{ .linker_reloc = sym }); |
| 406 | break :op if (lower.bin_file.options.pic) switch (mnemonic) { | |
| 409 | break :op if (lower.pic) switch (mnemonic) { | |
| 407 | 410 | .lea => { |
| 408 | 411 | break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) }; |
| 409 | 412 | }, |
src/libcxx.zig+2-12| ... | ... | @@ -299,12 +299,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 299 | 299 | try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node); |
| 300 | 300 | |
| 301 | 301 | 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(); | |
| 308 | 303 | } |
| 309 | 304 | |
| 310 | 305 | pub 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 { |
| 489 | 484 | try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node); |
| 490 | 485 | |
| 491 | 486 | 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(); | |
| 498 | 488 | } |
src/libtsan.zig+1-6| ... | ... | @@ -268,12 +268,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 268 | 268 | try comp.updateSubCompilation(sub_compilation, .libtsan, prog_node); |
| 269 | 269 | |
| 270 | 270 | 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(); | |
| 277 | 272 | } |
| 278 | 273 | |
| 279 | 274 | const tsan_sources = [_][]const u8{ |
src/libunwind.zig+1-6| ... | ... | @@ -151,12 +151,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 151 | 151 | |
| 152 | 152 | assert(comp.libunwind_static_lib == null); |
| 153 | 153 | |
| 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(); | |
| 160 | 155 | } |
| 161 | 156 | |
| 162 | 157 | const unwind_src_list = [_][]const u8{ |
src/link/Elf/synthetic_sections.zig+52-21| ... | ... | @@ -8,14 +8,16 @@ pub const DynamicSection = struct { |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | 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; | |
| 12 | 13 | const off = try elf_file.insertDynString(shared.soname()); |
| 13 | 14 | try dt.needed.append(gpa, off); |
| 14 | 15 | } |
| 15 | 16 | |
| 16 | 17 | pub fn setRpath(dt: *DynamicSection, rpath_list: []const []const u8, elf_file: *Elf) !void { |
| 17 | 18 | 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; | |
| 19 | 21 | var rpath = std.ArrayList(u8).init(gpa); |
| 20 | 22 | defer rpath.deinit(); |
| 21 | 23 | for (rpath_list, 0..) |path, i| { |
| ... | ... | @@ -248,7 +250,8 @@ pub const ZigGotSection = struct { |
| 248 | 250 | |
| 249 | 251 | pub fn addSymbol(zig_got: *ZigGotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index { |
| 250 | 252 | 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); | |
| 252 | 255 | const entry = &zig_got.entries.items[index]; |
| 253 | 256 | entry.* = sym_index; |
| 254 | 257 | const symbol = elf_file.symbol(sym_index); |
| ... | ... | @@ -349,7 +352,9 @@ pub const ZigGotSection = struct { |
| 349 | 352 | } |
| 350 | 353 | |
| 351 | 354 | 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()); | |
| 353 | 358 | for (zig_got.entries.items) |entry| { |
| 354 | 359 | const symbol = elf_file.symbol(entry); |
| 355 | 360 | const offset = symbol.zigGotAddress(elf_file); |
| ... | ... | @@ -481,7 +486,8 @@ pub const GotSection = struct { |
| 481 | 486 | |
| 482 | 487 | pub fn addGotSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index { |
| 483 | 488 | 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); | |
| 485 | 491 | const entry = &got.entries.items[index]; |
| 486 | 492 | entry.tag = .got; |
| 487 | 493 | entry.symbol_index = sym_index; |
| ... | ... | @@ -501,8 +507,10 @@ pub const GotSection = struct { |
| 501 | 507 | } |
| 502 | 508 | |
| 503 | 509 | pub fn addTlsLdSymbol(got: *GotSection, elf_file: *Elf) !void { |
| 510 | const comp = elf_file.base.comp; | |
| 511 | const gpa = comp.gpa; | |
| 504 | 512 | assert(got.flags.needs_tlsld); |
| 505 | const index = try got.allocateEntry(elf_file.base.allocator); | |
| 513 | const index = try got.allocateEntry(gpa); | |
| 506 | 514 | const entry = &got.entries.items[index]; |
| 507 | 515 | entry.tag = .tlsld; |
| 508 | 516 | entry.symbol_index = undefined; // unused |
| ... | ... | @@ -511,7 +519,9 @@ pub const GotSection = struct { |
| 511 | 519 | } |
| 512 | 520 | |
| 513 | 521 | 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); | |
| 515 | 525 | const entry = &got.entries.items[index]; |
| 516 | 526 | entry.tag = .tlsgd; |
| 517 | 527 | entry.symbol_index = sym_index; |
| ... | ... | @@ -526,7 +536,9 @@ pub const GotSection = struct { |
| 526 | 536 | } |
| 527 | 537 | |
| 528 | 538 | 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); | |
| 530 | 542 | const entry = &got.entries.items[index]; |
| 531 | 543 | entry.tag = .gottp; |
| 532 | 544 | entry.symbol_index = sym_index; |
| ... | ... | @@ -541,7 +553,9 @@ pub const GotSection = struct { |
| 541 | 553 | } |
| 542 | 554 | |
| 543 | 555 | 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); | |
| 545 | 559 | const entry = &got.entries.items[index]; |
| 546 | 560 | entry.tag = .tlsdesc; |
| 547 | 561 | entry.symbol_index = sym_index; |
| ... | ... | @@ -628,8 +642,9 @@ pub const GotSection = struct { |
| 628 | 642 | |
| 629 | 643 | pub fn addRela(got: GotSection, elf_file: *Elf) !void { |
| 630 | 644 | const comp = elf_file.base.comp; |
| 645 | const gpa = comp.gpa; | |
| 631 | 646 | 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)); | |
| 633 | 648 | |
| 634 | 649 | for (got.entries.items) |entry| { |
| 635 | 650 | const symbol = switch (entry.tag) { |
| ... | ... | @@ -847,6 +862,8 @@ pub const PltSection = struct { |
| 847 | 862 | } |
| 848 | 863 | |
| 849 | 864 | 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; | |
| 850 | 867 | const index = @as(u32, @intCast(plt.symbols.items.len)); |
| 851 | 868 | const symbol = elf_file.symbol(sym_index); |
| 852 | 869 | symbol.flags.has_plt = true; |
| ... | ... | @@ -855,7 +872,7 @@ pub const PltSection = struct { |
| 855 | 872 | new_extra.plt = index; |
| 856 | 873 | symbol.setExtra(new_extra, elf_file); |
| 857 | 874 | } 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); | |
| 859 | 876 | } |
| 860 | 877 | |
| 861 | 878 | pub fn size(plt: PltSection) usize { |
| ... | ... | @@ -895,7 +912,9 @@ pub const PltSection = struct { |
| 895 | 912 | } |
| 896 | 913 | |
| 897 | 914 | 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()); | |
| 899 | 918 | for (plt.symbols.items) |sym_index| { |
| 900 | 919 | const sym = elf_file.symbol(sym_index); |
| 901 | 920 | assert(sym.flags.import); |
| ... | ... | @@ -1010,6 +1029,8 @@ pub const PltGotSection = struct { |
| 1010 | 1029 | } |
| 1011 | 1030 | |
| 1012 | 1031 | 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; | |
| 1013 | 1034 | const index = @as(u32, @intCast(plt_got.symbols.items.len)); |
| 1014 | 1035 | const symbol = elf_file.symbol(sym_index); |
| 1015 | 1036 | symbol.flags.has_plt = true; |
| ... | ... | @@ -1019,7 +1040,7 @@ pub const PltGotSection = struct { |
| 1019 | 1040 | new_extra.plt_got = index; |
| 1020 | 1041 | symbol.setExtra(new_extra, elf_file); |
| 1021 | 1042 | } 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); | |
| 1023 | 1044 | } |
| 1024 | 1045 | |
| 1025 | 1046 | pub fn size(plt_got: PltGotSection) usize { |
| ... | ... | @@ -1077,6 +1098,8 @@ pub const CopyRelSection = struct { |
| 1077 | 1098 | } |
| 1078 | 1099 | |
| 1079 | 1100 | 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; | |
| 1080 | 1103 | const index = @as(u32, @intCast(copy_rel.symbols.items.len)); |
| 1081 | 1104 | const symbol = elf_file.symbol(sym_index); |
| 1082 | 1105 | symbol.flags.import = true; |
| ... | ... | @@ -1089,7 +1112,7 @@ pub const CopyRelSection = struct { |
| 1089 | 1112 | new_extra.copy_rel = index; |
| 1090 | 1113 | symbol.setExtra(new_extra, elf_file); |
| 1091 | 1114 | } 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); | |
| 1093 | 1116 | |
| 1094 | 1117 | const shared_object = symbol.file(elf_file).?.shared_object; |
| 1095 | 1118 | if (shared_object.aliases == null) { |
| ... | ... | @@ -1129,7 +1152,9 @@ pub const CopyRelSection = struct { |
| 1129 | 1152 | } |
| 1130 | 1153 | |
| 1131 | 1154 | 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()); | |
| 1133 | 1158 | for (copy_rel.symbols.items) |sym_index| { |
| 1134 | 1159 | const sym = elf_file.symbol(sym_index); |
| 1135 | 1160 | assert(sym.flags.import and sym.flags.has_copy_rel); |
| ... | ... | @@ -1162,7 +1187,8 @@ pub const DynsymSection = struct { |
| 1162 | 1187 | } |
| 1163 | 1188 | |
| 1164 | 1189 | 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; | |
| 1166 | 1192 | const index = @as(u32, @intCast(dynsym.entries.items.len + 1)); |
| 1167 | 1193 | const sym = elf_file.symbol(sym_index); |
| 1168 | 1194 | sym.flags.has_dynamic = true; |
| ... | ... | @@ -1244,7 +1270,8 @@ pub const HashSection = struct { |
| 1244 | 1270 | pub fn generate(hs: *HashSection, elf_file: *Elf) !void { |
| 1245 | 1271 | if (elf_file.dynsym.count() == 1) return; |
| 1246 | 1272 | |
| 1247 | const gpa = elf_file.base.allocator; | |
| 1273 | const comp = elf_file.base.comp; | |
| 1274 | const gpa = comp.gpa; | |
| 1248 | 1275 | const nsyms = elf_file.dynsym.count(); |
| 1249 | 1276 | |
| 1250 | 1277 | var buckets = try gpa.alloc(u32, nsyms); |
| ... | ... | @@ -1332,7 +1359,8 @@ pub const GnuHashSection = struct { |
| 1332 | 1359 | try cwriter.writeInt(u32, hash.num_bloom, .little); |
| 1333 | 1360 | try cwriter.writeInt(u32, bloom_shift, .little); |
| 1334 | 1361 | |
| 1335 | const gpa = elf_file.base.allocator; | |
| 1362 | const comp = elf_file.base.comp; | |
| 1363 | const gpa = comp.gpa; | |
| 1336 | 1364 | const hashes = try gpa.alloc(u32, exports.len); |
| 1337 | 1365 | defer gpa.free(hashes); |
| 1338 | 1366 | const indices = try gpa.alloc(u32, exports.len); |
| ... | ... | @@ -1434,7 +1462,8 @@ pub const VerneedSection = struct { |
| 1434 | 1462 | } |
| 1435 | 1463 | }; |
| 1436 | 1464 | |
| 1437 | const gpa = elf_file.base.allocator; | |
| 1465 | const comp = elf_file.base.comp; | |
| 1466 | const gpa = comp.gpa; | |
| 1438 | 1467 | var verneed = std.ArrayList(VersionedSymbol).init(gpa); |
| 1439 | 1468 | defer verneed.deinit(); |
| 1440 | 1469 | try verneed.ensureTotalCapacity(dynsyms.len); |
| ... | ... | @@ -1490,7 +1519,8 @@ pub const VerneedSection = struct { |
| 1490 | 1519 | } |
| 1491 | 1520 | |
| 1492 | 1521 | 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; | |
| 1494 | 1524 | const sym = try vern.verneed.addOne(gpa); |
| 1495 | 1525 | sym.* = .{ |
| 1496 | 1526 | .vn_version = 1, |
| ... | ... | @@ -1508,7 +1538,8 @@ pub const VerneedSection = struct { |
| 1508 | 1538 | version: [:0]const u8, |
| 1509 | 1539 | elf_file: *Elf, |
| 1510 | 1540 | ) !elf.Elf64_Vernaux { |
| 1511 | const gpa = elf_file.base.allocator; | |
| 1541 | const comp = elf_file.base.comp; | |
| 1542 | const gpa = comp.gpa; | |
| 1512 | 1543 | const sym = try vern.vernaux.addOne(gpa); |
| 1513 | 1544 | sym.* = .{ |
| 1514 | 1545 | .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 |
| 5242 | 5242 | }); |
| 5243 | 5243 | |
| 5244 | 5244 | 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 | }); | |
| 5261 | 5245 | |
| 5262 | 5246 | const build_mod = try Package.Module.create(arena, .{ |
| 5263 | 5247 | .global_cache_directory = global_cache_directory, |
| ... | ... | @@ -5425,7 +5409,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 5425 | 5409 | .config = config, |
| 5426 | 5410 | .root_mod = root_mod, |
| 5427 | 5411 | .main_mod = build_mod, |
| 5428 | .std_mod = std_mod, | |
| 5429 | 5412 | .emit_bin = emit_bin, |
| 5430 | 5413 | .emit_h = null, |
| 5431 | 5414 | .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 |
| 280 | 280 | .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{ |
| 281 | 281 | sub_compilation.bin_file.?.emit.sub_path, |
| 282 | 282 | }), |
| 283 | .lock = sub_compilation.bin_file.toOwnedLock(), | |
| 283 | .lock = sub_compilation.bin_file.?.toOwnedLock(), | |
| 284 | 284 | }); |
| 285 | 285 | }, |
| 286 | 286 | } |