| author | |
| committer | |
| log | 377ecc6afb14a112a07c6d2c3570e2b77b12a116 |
| tree | 706ef264ff807f729e37e2aef2b83a8d8e7ab99e |
| parent | aa7d16aba1f0b3a9e816684618d16cb1d178a6d3 |
7 files changed, 38 insertions(+), 5 deletions(-)
lib/std/Build/Step/Compile.zig+7| ... | ... | @@ -113,6 +113,9 @@ linker_allow_shlib_undefined: ?bool = null, |
| 113 | 113 | /// Allow version scripts to refer to undefined symbols. |
| 114 | 114 | linker_allow_undefined_version: ?bool = null, |
| 115 | 115 | |
| 116 | // Enable (or disable) the new DT_RUNPATH tag in the dynamic section. | |
| 117 | linker_enable_new_dtags: ?bool = null, | |
| 118 | ||
| 116 | 119 | /// Permit read-only relocations in read-only segments. Disallowed by default. |
| 117 | 120 | link_z_notext: bool = false, |
| 118 | 121 | |
| ... | ... | @@ -1490,6 +1493,10 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1490 | 1493 | try zig_args.append(if (x) "--undefined-version" else "--no-undefined-version"); |
| 1491 | 1494 | } |
| 1492 | 1495 | |
| 1496 | if (self.linker_enable_new_dtags) |enabled| { | |
| 1497 | try zig_args.append(if (enabled) "--enable-new-dtags" else "--disable-new-dtags"); | |
| 1498 | } | |
| 1499 | ||
| 1493 | 1500 | if (self.kind == .@"test") { |
| 1494 | 1501 | if (self.exec_cmd_args) |exec_cmd_args| { |
| 1495 | 1502 | for (exec_cmd_args) |cmd_arg| { |
src/Compilation.zig+5-2| ... | ... | @@ -1034,6 +1034,7 @@ pub const CreateOptions = struct { |
| 1034 | 1034 | linker_script: ?[]const u8 = null, |
| 1035 | 1035 | version_script: ?[]const u8 = null, |
| 1036 | 1036 | linker_allow_undefined_version: bool = false, |
| 1037 | linker_enable_new_dtags: ?bool = null, | |
| 1037 | 1038 | soname: ?[]const u8 = null, |
| 1038 | 1039 | linker_gc_sections: ?bool = null, |
| 1039 | 1040 | linker_allow_shlib_undefined: ?bool = null, |
| ... | ... | @@ -1581,6 +1582,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1581 | 1582 | .image_base = options.image_base, |
| 1582 | 1583 | .version_script = options.version_script, |
| 1583 | 1584 | .allow_undefined_version = options.linker_allow_undefined_version, |
| 1585 | .enable_new_dtags = options.linker_enable_new_dtags, | |
| 1584 | 1586 | .gc_sections = options.linker_gc_sections, |
| 1585 | 1587 | .emit_relocs = options.link_emit_relocs, |
| 1586 | 1588 | .soname = options.soname, |
| ... | ... | @@ -2460,7 +2462,7 @@ fn prepareWholeEmitSubPath(arena: Allocator, opt_emit: ?EmitLoc) error{OutOfMemo |
| 2460 | 2462 | /// to remind the programmer to update multiple related pieces of code that |
| 2461 | 2463 | /// are in different locations. Bump this number when adding or deleting |
| 2462 | 2464 | /// anything from the link cache manifest. |
| 2463 | pub const link_hash_implementation_version = 12; | |
| 2465 | pub const link_hash_implementation_version = 13; | |
| 2464 | 2466 | |
| 2465 | 2467 | fn addNonIncrementalStuffToCacheManifest( |
| 2466 | 2468 | comp: *Compilation, |
| ... | ... | @@ -2469,7 +2471,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2469 | 2471 | ) !void { |
| 2470 | 2472 | const gpa = comp.gpa; |
| 2471 | 2473 | |
| 2472 | comptime assert(link_hash_implementation_version == 12); | |
| 2474 | comptime assert(link_hash_implementation_version == 13); | |
| 2473 | 2475 | |
| 2474 | 2476 | if (comp.module) |mod| { |
| 2475 | 2477 | try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man }); |
| ... | ... | @@ -2541,6 +2543,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2541 | 2543 | try man.addOptionalFile(opts.linker_script); |
| 2542 | 2544 | try man.addOptionalFile(opts.version_script); |
| 2543 | 2545 | man.hash.add(opts.allow_undefined_version); |
| 2546 | man.hash.addOptional(opts.enable_new_dtags); | |
| 2544 | 2547 | |
| 2545 | 2548 | man.hash.addOptional(opts.stack_size); |
| 2546 | 2549 | man.hash.addOptional(opts.image_base); |
src/link.zig+1| ... | ... | @@ -113,6 +113,7 @@ pub const File = struct { |
| 113 | 113 | gc_sections: ?bool, |
| 114 | 114 | allow_shlib_undefined: ?bool, |
| 115 | 115 | allow_undefined_version: bool, |
| 116 | enable_new_dtags: ?bool, | |
| 116 | 117 | subsystem: ?std.Target.SubSystem, |
| 117 | 118 | linker_script: ?[]const u8, |
| 118 | 119 | version_script: ?[]const u8, |
src/link/Coff/lld.zig+1-1| ... | ... | @@ -70,7 +70,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 70 | 70 | man = comp.cache_parent.obtain(); |
| 71 | 71 | self.base.releaseLock(); |
| 72 | 72 | |
| 73 | comptime assert(Compilation.link_hash_implementation_version == 12); | |
| 73 | comptime assert(Compilation.link_hash_implementation_version == 13); | |
| 74 | 74 | |
| 75 | 75 | for (comp.objects) |obj| { |
| 76 | 76 | _ = try man.addFile(obj.path, null); |
src/link/Elf.zig+11-1| ... | ... | @@ -22,6 +22,7 @@ bind_global_refs_locally: bool, |
| 22 | 22 | linker_script: ?[]const u8, |
| 23 | 23 | version_script: ?[]const u8, |
| 24 | 24 | allow_undefined_version: bool, |
| 25 | enable_new_dtags: ?bool, | |
| 25 | 26 | print_icf_sections: bool, |
| 26 | 27 | print_map: bool, |
| 27 | 28 | entry_name: ?[]const u8, |
| ... | ... | @@ -330,6 +331,7 @@ pub fn createEmpty( |
| 330 | 331 | .linker_script = options.linker_script, |
| 331 | 332 | .version_script = options.version_script, |
| 332 | 333 | .allow_undefined_version = options.allow_undefined_version, |
| 334 | .enable_new_dtags = options.enable_new_dtags, | |
| 333 | 335 | .print_icf_sections = options.print_icf_sections, |
| 334 | 336 | .print_map = options.print_map, |
| 335 | 337 | }; |
| ... | ... | @@ -2170,11 +2172,12 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2170 | 2172 | // We are about to obtain this lock, so here we give other processes a chance first. |
| 2171 | 2173 | self.base.releaseLock(); |
| 2172 | 2174 | |
| 2173 | comptime assert(Compilation.link_hash_implementation_version == 12); | |
| 2175 | comptime assert(Compilation.link_hash_implementation_version == 13); | |
| 2174 | 2176 | |
| 2175 | 2177 | try man.addOptionalFile(self.linker_script); |
| 2176 | 2178 | try man.addOptionalFile(self.version_script); |
| 2177 | 2179 | man.hash.add(self.allow_undefined_version); |
| 2180 | man.hash.addOptional(self.enable_new_dtags); | |
| 2178 | 2181 | for (comp.objects) |obj| { |
| 2179 | 2182 | _ = try man.addFile(obj.path, null); |
| 2180 | 2183 | man.hash.add(obj.must_link); |
| ... | ... | @@ -2529,6 +2532,13 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2529 | 2532 | } else { |
| 2530 | 2533 | try argv.append("--no-undefined-version"); |
| 2531 | 2534 | } |
| 2535 | if (self.enable_new_dtags) |enable_new_dtags| { | |
| 2536 | if (enable_new_dtags) { | |
| 2537 | try argv.append("--enable-new-dtags"); | |
| 2538 | } else { | |
| 2539 | try argv.append("--disable-new-dtags"); | |
| 2540 | } | |
| 2541 | } | |
| 2532 | 2542 | } |
| 2533 | 2543 | |
| 2534 | 2544 | // Positional arguments to the linker such as object files. |
src/link/Wasm.zig+1-1| ... | ... | @@ -3375,7 +3375,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo |
| 3375 | 3375 | // We are about to obtain this lock, so here we give other processes a chance first. |
| 3376 | 3376 | wasm.base.releaseLock(); |
| 3377 | 3377 | |
| 3378 | comptime assert(Compilation.link_hash_implementation_version == 12); | |
| 3378 | comptime assert(Compilation.link_hash_implementation_version == 13); | |
| 3379 | 3379 | |
| 3380 | 3380 | for (comp.objects) |obj| { |
| 3381 | 3381 | _ = try man.addFile(obj.path, null); |
src/main.zig+12| ... | ... | @@ -496,6 +496,8 @@ const usage_build_generic = |
| 496 | 496 | \\ --version-script [path] Provide a version .map file |
| 497 | 497 | \\ --undefined-version Allow version scripts to refer to undefined symbols |
| 498 | 498 | \\ --no-undefined-version (default) Disallow version scripts from referring to undefined symbols |
| 499 | \\ --enable-new-dtags Use the new behavior for dynamic tags (RUNPATH) | |
| 500 | \\ --disable-new-dtags Use the old behavior for dynamic tags (RPATH) | |
| 499 | 501 | \\ --dynamic-linker [path] Set the dynamic interpreter path (usually ld.so) |
| 500 | 502 | \\ --sysroot [path] Set the system root directory (usually /) |
| 501 | 503 | \\ --version [ver] Dynamic library semver |
| ... | ... | @@ -824,6 +826,7 @@ fn buildOutputType( |
| 824 | 826 | var linker_script: ?[]const u8 = null; |
| 825 | 827 | var version_script: ?[]const u8 = null; |
| 826 | 828 | var linker_allow_undefined_version: bool = false; |
| 829 | var linker_enable_new_dtags: ?bool = null; | |
| 827 | 830 | var disable_c_depfile = false; |
| 828 | 831 | var linker_sort_section: ?link.File.Elf.SortSection = null; |
| 829 | 832 | var linker_gc_sections: ?bool = null; |
| ... | ... | @@ -1191,6 +1194,10 @@ fn buildOutputType( |
| 1191 | 1194 | linker_allow_undefined_version = true; |
| 1192 | 1195 | } else if (mem.eql(u8, arg, "--no-undefined-version")) { |
| 1193 | 1196 | linker_allow_undefined_version = false; |
| 1197 | } else if (mem.eql(u8, arg, "--enable-new-dtags")) { | |
| 1198 | linker_enable_new_dtags = true; | |
| 1199 | } else if (mem.eql(u8, arg, "--disable-new-dtags")) { | |
| 1200 | linker_enable_new_dtags = false; | |
| 1194 | 1201 | } else if (mem.eql(u8, arg, "--library") or mem.eql(u8, arg, "-l")) { |
| 1195 | 1202 | // We don't know whether this library is part of libc |
| 1196 | 1203 | // or libc++ until we resolve the target, so we append |
| ... | ... | @@ -2153,6 +2160,10 @@ fn buildOutputType( |
| 2153 | 2160 | linker_allow_undefined_version = true; |
| 2154 | 2161 | } else if (mem.eql(u8, arg, "--no-undefined-version")) { |
| 2155 | 2162 | linker_allow_undefined_version = false; |
| 2163 | } else if (mem.eql(u8, arg, "--enable-new-dtags")) { | |
| 2164 | linker_enable_new_dtags = true; | |
| 2165 | } else if (mem.eql(u8, arg, "--disable-new-dtags")) { | |
| 2166 | linker_enable_new_dtags = false; | |
| 2156 | 2167 | } else if (mem.eql(u8, arg, "-O")) { |
| 2157 | 2168 | linker_optimization = linker_args_it.nextOrFatal(); |
| 2158 | 2169 | } else if (mem.startsWith(u8, arg, "-O")) { |
| ... | ... | @@ -3181,6 +3192,7 @@ fn buildOutputType( |
| 3181 | 3192 | .linker_script = linker_script, |
| 3182 | 3193 | .version_script = version_script, |
| 3183 | 3194 | .linker_allow_undefined_version = linker_allow_undefined_version, |
| 3195 | .linker_enable_new_dtags = linker_enable_new_dtags, | |
| 3184 | 3196 | .disable_c_depfile = disable_c_depfile, |
| 3185 | 3197 | .soname = resolved_soname, |
| 3186 | 3198 | .linker_sort_section = linker_sort_section, |