| ... | @@ -614,7 +614,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -614,7 +614,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 614 | const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib; | 614 | const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib; |
| 615 | const is_exe_or_dyn_lib = is_dyn_lib or self.base.options.output_mode == .Exe; | 615 | const is_exe_or_dyn_lib = is_dyn_lib or self.base.options.output_mode == .Exe; |
| 616 | const stack_size = self.base.options.stack_size_override orelse 0; | 616 | const stack_size = self.base.options.stack_size_override orelse 0; |
| 617 | const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os; | | |
| 618 | | 617 | |
| 619 | const id_symlink_basename = "zld.id"; | 618 | const id_symlink_basename = "zld.id"; |
| 620 | | 619 | |
| ... | @@ -629,8 +628,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -629,8 +628,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 629 | // We are about to obtain this lock, so here we give other processes a chance first. | 628 | // We are about to obtain this lock, so here we give other processes a chance first. |
| 630 | self.base.releaseLock(); | 629 | self.base.releaseLock(); |
| 631 | | 630 | |
| 632 | try man.addOptionalFile(self.base.options.linker_script); | | |
| 633 | try man.addOptionalFile(self.base.options.version_script); | | |
| 634 | try man.addListOfFiles(self.base.options.objects); | 631 | try man.addListOfFiles(self.base.options.objects); |
| 635 | for (comp.c_object_table.keys()) |key| { | 632 | for (comp.c_object_table.keys()) |key| { |
| 636 | _ = try man.addFile(key.status.success.object_path, null); | 633 | _ = try man.addFile(key.status.success.object_path, null); |
| ... | @@ -639,21 +636,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -639,21 +636,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 639 | // We can skip hashing libc and libc++ components that we are in charge of building from Zig | 636 | // We can skip hashing libc and libc++ components that we are in charge of building from Zig |
| 640 | // installation sources because they are always a product of the compiler version + target information. | 637 | // installation sources because they are always a product of the compiler version + target information. |
| 641 | man.hash.add(stack_size); | 638 | man.hash.add(stack_size); |
| 642 | man.hash.add(self.base.options.rdynamic); | | |
| 643 | man.hash.addListOfBytes(self.base.options.extra_lld_args); | | |
| 644 | man.hash.addListOfBytes(self.base.options.lib_dirs); | 639 | man.hash.addListOfBytes(self.base.options.lib_dirs); |
| 645 | man.hash.addListOfBytes(self.base.options.framework_dirs); | 640 | man.hash.addListOfBytes(self.base.options.framework_dirs); |
| 646 | man.hash.addListOfBytes(self.base.options.frameworks); | 641 | man.hash.addListOfBytes(self.base.options.frameworks); |
| 647 | man.hash.addListOfBytes(self.base.options.rpath_list); | 642 | man.hash.addListOfBytes(self.base.options.rpath_list); |
| 648 | man.hash.add(self.base.options.skip_linker_dependencies); | | |
| 649 | man.hash.add(self.base.options.z_nodelete); | | |
| 650 | man.hash.add(self.base.options.z_defs); | | |
| 651 | if (is_dyn_lib) { | 643 | if (is_dyn_lib) { |
| 652 | man.hash.addOptional(self.base.options.version); | 644 | man.hash.addOptional(self.base.options.version); |
| 653 | } | 645 | } |
| 654 | man.hash.addStringSet(self.base.options.system_libs); | 646 | man.hash.addStringSet(self.base.options.system_libs); |
| 655 | man.hash.add(allow_shlib_undefined); | | |
| 656 | man.hash.add(self.base.options.bind_global_refs_locally); | | |
| 657 | man.hash.addOptionalBytes(self.base.options.sysroot); | 647 | man.hash.addOptionalBytes(self.base.options.sysroot); |
| 658 | | 648 | |
| 659 | // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock. | 649 | // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock. |
| ... | @@ -909,16 +899,12 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -909,16 +899,12 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 909 | Compilation.dump_argv(argv.items); | 899 | Compilation.dump_argv(argv.items); |
| 910 | } | 900 | } |
| 911 | | 901 | |
| 912 | self.base.file = try fs.cwd().createFile(full_out_path, .{ | 902 | const sub_path = self.base.options.emit.?.sub_path; |
| | 903 | self.base.file = try directory.handle.createFile(sub_path, .{ |
| 913 | .truncate = true, | 904 | .truncate = true, |
| 914 | .read = true, | 905 | .read = true, |
| 915 | .mode = if (std.Target.current.os.tag == .windows) 0 else 0o777, | 906 | .mode = link.determineMode(self.base.options), |
| 916 | }); | 907 | }); |
| 917 | self.page_size = switch (self.base.options.target.cpu.arch) { | | |
| 918 | .aarch64 => 0x4000, | | |
| 919 | .x86_64 => 0x1000, | | |
| 920 | else => unreachable, | | |
| 921 | }; | | |
| 922 | | 908 | |
| 923 | // TODO mimicking insertion of null symbol from incremental linker. | 909 | // TODO mimicking insertion of null symbol from incremental linker. |
| 924 | // This will need to moved. | 910 | // This will need to moved. |
| ... | @@ -932,10 +918,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -932,10 +918,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 932 | try self.strtab.append(self.base.allocator, 0); | 918 | try self.strtab.append(self.base.allocator, 0); |
| 933 | | 919 | |
| 934 | try self.populateMetadata(); | 920 | try self.populateMetadata(); |
| | 921 | try self.addRpathLCs(rpaths.items); |
| 935 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); | 922 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); |
| 936 | try self.parseLibs(libs.items, self.base.options.sysroot); | 923 | try self.parseLibs(libs.items, self.base.options.sysroot); |
| 937 | try self.resolveSymbols(); | 924 | try self.resolveSymbols(); |
| 938 | try self.parseTextBlocks(); | 925 | try self.parseTextBlocks(); |
| | 926 | try self.addLoadDylibLCs(); |
| | 927 | try self.addDataInCodeLC(); |
| | 928 | try self.addCodeSignatureLC(); |
| 939 | | 929 | |
| 940 | { | 930 | { |
| 941 | // Add dyld_stub_binder as the final GOT entry. | 931 | // Add dyld_stub_binder as the final GOT entry. |
| ... | @@ -953,10 +943,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -953,10 +943,6 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 953 | } | 943 | } |
| 954 | | 944 | |
| 955 | try self.sortSections(); | 945 | try self.sortSections(); |
| 956 | try self.addRpathLCs(rpaths.items); | | |
| 957 | try self.addLoadDylibLCs(); | | |
| 958 | try self.addDataInCodeLC(); | | |
| 959 | try self.addCodeSignatureLC(); | | |
| 960 | try self.allocateTextSegment(); | 946 | try self.allocateTextSegment(); |
| 961 | try self.allocateDataConstSegment(); | 947 | try self.allocateDataConstSegment(); |
| 962 | try self.allocateDataSegment(); | 948 | try self.allocateDataSegment(); |