| author | |
| committer | |
| log | 852e7e24b5f15b489463bdabb0039e2a424e5ee6 |
| tree | d64e0e2c20afa448be6a0b7e29617c6f603966f5 |
| parent | 9097bcc06e8d9c4691fac18f7a6b4d7f2d63eefe |
| parent | 8707555c0b1fd071fc87be8b74b06ad7bd71098f |
| signature |
move rpath to frontend and remove native paths from it5 files changed, 9 insertions(+), 74 deletions(-)
lib/std/zig/system/NativePaths.zig+1| ... | ... | @@ -59,6 +59,7 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths { |
| 59 | 59 | } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') { |
| 60 | 60 | const lib_path = word[2..]; |
| 61 | 61 | try self.addLibDir(lib_path); |
| 62 | try self.addRPath(lib_path); | |
| 62 | 63 | } else { |
| 63 | 64 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); |
| 64 | 65 | break; |
src/Compilation.zig-6| ... | ... | @@ -1049,7 +1049,6 @@ pub const CreateOptions = struct { |
| 1049 | 1049 | linker_print_icf_sections: bool = false, |
| 1050 | 1050 | linker_print_map: bool = false, |
| 1051 | 1051 | llvm_opt_bisect_limit: i32 = -1, |
| 1052 | each_lib_rpath: ?bool = null, | |
| 1053 | 1052 | build_id: ?std.zig.BuildId = null, |
| 1054 | 1053 | disable_c_depfile: bool = false, |
| 1055 | 1054 | linker_z_nodelete: bool = false, |
| ... | ... | @@ -1341,9 +1340,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1341 | 1340 | |
| 1342 | 1341 | const error_limit = options.error_limit orelse (std.math.maxInt(u16) - 1); |
| 1343 | 1342 | |
| 1344 | const each_lib_rpath = options.each_lib_rpath orelse | |
| 1345 | options.root_mod.resolved_target.is_native_os; | |
| 1346 | ||
| 1347 | 1343 | // We put everything into the cache hash that *cannot be modified |
| 1348 | 1344 | // during an incremental update*. For example, one cannot change the |
| 1349 | 1345 | // target between updates, but one can change source files, so the |
| ... | ... | @@ -1578,7 +1574,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1578 | 1574 | .emit_relocs = options.link_emit_relocs, |
| 1579 | 1575 | .soname = options.soname, |
| 1580 | 1576 | .compatibility_version = options.compatibility_version, |
| 1581 | .each_lib_rpath = each_lib_rpath, | |
| 1582 | 1577 | .build_id = build_id, |
| 1583 | 1578 | .disable_lld_caching = options.disable_lld_caching or options.cache_mode == .whole, |
| 1584 | 1579 | .subsystem = options.subsystem, |
| ... | ... | @@ -2552,7 +2547,6 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2552 | 2547 | man.hash.addListOfBytes(opts.lib_dirs); |
| 2553 | 2548 | man.hash.addListOfBytes(opts.rpath_list); |
| 2554 | 2549 | man.hash.addListOfBytes(opts.symbol_wrap_set.keys()); |
| 2555 | man.hash.add(opts.each_lib_rpath); | |
| 2556 | 2550 | if (comp.config.link_libc) { |
| 2557 | 2551 | man.hash.add(comp.libc_installation != null); |
| 2558 | 2552 | const target = comp.root_mod.resolved_target.result; |
src/link.zig-1| ... | ... | @@ -104,7 +104,6 @@ pub const File = struct { |
| 104 | 104 | max_memory: ?u64, |
| 105 | 105 | export_symbol_names: []const []const u8, |
| 106 | 106 | global_base: ?u64, |
| 107 | each_lib_rpath: bool, | |
| 108 | 107 | build_id: std.zig.BuildId, |
| 109 | 108 | disable_lld_caching: bool, |
| 110 | 109 | hash_style: Elf.HashStyle, |
src/link/Elf.zig-63| ... | ... | @@ -16,7 +16,6 @@ lib_dirs: []const []const u8, |
| 16 | 16 | hash_style: HashStyle, |
| 17 | 17 | compress_debug_sections: CompressDebugSections, |
| 18 | 18 | symbol_wrap_set: std.StringArrayHashMapUnmanaged(void), |
| 19 | each_lib_rpath: bool, | |
| 20 | 19 | sort_section: ?SortSection, |
| 21 | 20 | soname: ?[]const u8, |
| 22 | 21 | bind_global_refs_locally: bool, |
| ... | ... | @@ -320,7 +319,6 @@ pub fn createEmpty( |
| 320 | 319 | .hash_style = options.hash_style, |
| 321 | 320 | .compress_debug_sections = options.compress_debug_sections, |
| 322 | 321 | .symbol_wrap_set = options.symbol_wrap_set, |
| 323 | .each_lib_rpath = options.each_lib_rpath, | |
| 324 | 322 | .sort_section = options.sort_section, |
| 325 | 323 | .soname = options.soname, |
| 326 | 324 | .bind_global_refs_locally = options.bind_global_refs_locally, |
| ... | ... | @@ -1108,25 +1106,6 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) |
| 1108 | 1106 | _ = try rpath_table.put(rpath, {}); |
| 1109 | 1107 | } |
| 1110 | 1108 | |
| 1111 | if (self.each_lib_rpath) { | |
| 1112 | var test_path = std.ArrayList(u8).init(gpa); | |
| 1113 | defer test_path.deinit(); | |
| 1114 | for (self.lib_dirs) |lib_dir_path| { | |
| 1115 | for (comp.system_libs.keys()) |link_lib| { | |
| 1116 | if (!(try self.accessLibPath(&test_path, null, lib_dir_path, link_lib, .Dynamic))) | |
| 1117 | continue; | |
| 1118 | _ = try rpath_table.put(lib_dir_path, {}); | |
| 1119 | } | |
| 1120 | } | |
| 1121 | for (comp.objects) |obj| { | |
| 1122 | if (Compilation.classifyFileExt(obj.path) == .shared_library) { | |
| 1123 | const lib_dir_path = std.fs.path.dirname(obj.path) orelse continue; | |
| 1124 | if (obj.loption) continue; | |
| 1125 | _ = try rpath_table.put(lib_dir_path, {}); | |
| 1126 | } | |
| 1127 | } | |
| 1128 | } | |
| 1129 | ||
| 1130 | 1109 | // TSAN |
| 1131 | 1110 | if (comp.config.any_sanitize_thread) { |
| 1132 | 1111 | try positionals.append(.{ .path = comp.tsan_static_lib.?.full_object_path }); |
| ... | ... | @@ -1693,22 +1672,6 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1693 | 1672 | try argv.append(rpath); |
| 1694 | 1673 | } |
| 1695 | 1674 | |
| 1696 | if (self.each_lib_rpath) { | |
| 1697 | for (self.lib_dirs) |lib_dir_path| { | |
| 1698 | try argv.append("-rpath"); | |
| 1699 | try argv.append(lib_dir_path); | |
| 1700 | } | |
| 1701 | for (comp.objects) |obj| { | |
| 1702 | if (Compilation.classifyFileExt(obj.path) == .shared_library) { | |
| 1703 | const lib_dir_path = std.fs.path.dirname(obj.path) orelse continue; | |
| 1704 | if (obj.loption) continue; | |
| 1705 | ||
| 1706 | try argv.append("-rpath"); | |
| 1707 | try argv.append(lib_dir_path); | |
| 1708 | } | |
| 1709 | } | |
| 1710 | } | |
| 1711 | ||
| 1712 | 1675 | try argv.appendSlice(&.{ |
| 1713 | 1676 | "-z", |
| 1714 | 1677 | try std.fmt.allocPrint(arena, "stack-size={d}", .{self.base.stack_size}), |
| ... | ... | @@ -2439,7 +2402,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2439 | 2402 | man.hash.add(comp.config.rdynamic); |
| 2440 | 2403 | man.hash.addListOfBytes(self.lib_dirs); |
| 2441 | 2404 | man.hash.addListOfBytes(self.base.rpath_list); |
| 2442 | man.hash.add(self.each_lib_rpath); | |
| 2443 | 2405 | if (output_mode == .Exe) { |
| 2444 | 2406 | man.hash.add(self.base.stack_size); |
| 2445 | 2407 | man.hash.add(self.base.build_id); |
| ... | ... | @@ -2739,31 +2701,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2739 | 2701 | try argv.appendSlice(&.{ "-wrap", symbol_name }); |
| 2740 | 2702 | } |
| 2741 | 2703 | |
| 2742 | if (self.each_lib_rpath) { | |
| 2743 | var test_path = std.ArrayList(u8).init(arena); | |
| 2744 | for (self.lib_dirs) |lib_dir_path| { | |
| 2745 | for (comp.system_libs.keys()) |link_lib| { | |
| 2746 | if (!(try self.accessLibPath(&test_path, null, lib_dir_path, link_lib, .Dynamic))) | |
| 2747 | continue; | |
| 2748 | if ((try rpath_table.fetchPut(lib_dir_path, {})) == null) { | |
| 2749 | try argv.append("-rpath"); | |
| 2750 | try argv.append(lib_dir_path); | |
| 2751 | } | |
| 2752 | } | |
| 2753 | } | |
| 2754 | for (comp.objects) |obj| { | |
| 2755 | if (Compilation.classifyFileExt(obj.path) == .shared_library) { | |
| 2756 | const lib_dir_path = std.fs.path.dirname(obj.path) orelse continue; | |
| 2757 | if (obj.loption) continue; | |
| 2758 | ||
| 2759 | if ((try rpath_table.fetchPut(lib_dir_path, {})) == null) { | |
| 2760 | try argv.append("-rpath"); | |
| 2761 | try argv.append(lib_dir_path); | |
| 2762 | } | |
| 2763 | } | |
| 2764 | } | |
| 2765 | } | |
| 2766 | ||
| 2767 | 2704 | for (self.lib_dirs) |lib_dir| { |
| 2768 | 2705 | try argv.append("-L"); |
| 2769 | 2706 | try argv.append(lib_dir); |
src/main.zig+8-4| ... | ... | @@ -866,7 +866,6 @@ fn buildOutputType( |
| 866 | 866 | var image_base: ?u64 = null; |
| 867 | 867 | var link_eh_frame_hdr = false; |
| 868 | 868 | var link_emit_relocs = false; |
| 869 | var each_lib_rpath: ?bool = null; | |
| 870 | 869 | var build_id: ?std.zig.BuildId = null; |
| 871 | 870 | var runtime_args_start: ?usize = null; |
| 872 | 871 | var test_filter: ?[]const u8 = null; |
| ... | ... | @@ -964,6 +963,7 @@ fn buildOutputType( |
| 964 | 963 | .frameworks = .{}, |
| 965 | 964 | .framework_dirs = .{}, |
| 966 | 965 | .rpath_list = .{}, |
| 966 | .each_lib_rpath = null, | |
| 967 | 967 | .libc_paths_file = try EnvVar.ZIG_LIBC.get(arena), |
| 968 | 968 | .link_objects = .{}, |
| 969 | 969 | .native_system_include_paths = &.{}, |
| ... | ... | @@ -1334,9 +1334,9 @@ fn buildOutputType( |
| 1334 | 1334 | } else if (mem.eql(u8, arg, "-fno-compiler-rt")) { |
| 1335 | 1335 | want_compiler_rt = false; |
| 1336 | 1336 | } else if (mem.eql(u8, arg, "-feach-lib-rpath")) { |
| 1337 | each_lib_rpath = true; | |
| 1337 | create_module.each_lib_rpath = true; | |
| 1338 | 1338 | } else if (mem.eql(u8, arg, "-fno-each-lib-rpath")) { |
| 1339 | each_lib_rpath = false; | |
| 1339 | create_module.each_lib_rpath = false; | |
| 1340 | 1340 | } else if (mem.eql(u8, arg, "--test-cmd-bin")) { |
| 1341 | 1341 | try test_exec_args.append(null); |
| 1342 | 1342 | } else if (mem.eql(u8, arg, "--test-evented-io")) { |
| ... | ... | @@ -3236,7 +3236,6 @@ fn buildOutputType( |
| 3236 | 3236 | .verbose_llvm_cpu_features = verbose_llvm_cpu_features, |
| 3237 | 3237 | .time_report = time_report, |
| 3238 | 3238 | .stack_report = stack_report, |
| 3239 | .each_lib_rpath = each_lib_rpath, | |
| 3240 | 3239 | .build_id = build_id, |
| 3241 | 3240 | .test_filter = test_filter, |
| 3242 | 3241 | .test_name_prefix = test_name_prefix, |
| ... | ... | @@ -3450,6 +3449,7 @@ const CreateModule = struct { |
| 3450 | 3449 | native_system_include_paths: []const []const u8, |
| 3451 | 3450 | framework_dirs: std.ArrayListUnmanaged([]const u8), |
| 3452 | 3451 | rpath_list: std.ArrayListUnmanaged([]const u8), |
| 3452 | each_lib_rpath: ?bool, | |
| 3453 | 3453 | libc_paths_file: ?[]const u8, |
| 3454 | 3454 | link_objects: std.ArrayListUnmanaged(Compilation.LinkObject), |
| 3455 | 3455 | }; |
| ... | ... | @@ -3644,6 +3644,10 @@ fn createModule( |
| 3644 | 3644 | create_module.want_native_include_dirs = true; |
| 3645 | 3645 | } |
| 3646 | 3646 | |
| 3647 | if (create_module.each_lib_rpath orelse resolved_target.is_native_os) { | |
| 3648 | try create_module.rpath_list.appendSlice(arena, create_module.lib_dirs.items); | |
| 3649 | } | |
| 3650 | ||
| 3647 | 3651 | // Trigger native system library path detection if necessary. |
| 3648 | 3652 | if (create_module.sysroot == null and |
| 3649 | 3653 | resolved_target.is_native_os and resolved_target.is_native_abi and |