| 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,6 +59,7 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths { |
| 59 | } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') { | 59 | } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') { |
| 60 | const lib_path = word[2..]; | 60 | const lib_path = word[2..]; |
| 61 | try self.addLibDir(lib_path); | 61 | try self.addLibDir(lib_path); |
| 62 | try self.addRPath(lib_path); | ||
| 62 | } else { | 63 | } else { |
| 63 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); | 64 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); |
| 64 | break; | 65 | break; |
src/Compilation.zig-6| ... | @@ -1049,7 +1049,6 @@ pub const CreateOptions = struct { | ... | @@ -1049,7 +1049,6 @@ pub const CreateOptions = struct { |
| 1049 | linker_print_icf_sections: bool = false, | 1049 | linker_print_icf_sections: bool = false, |
| 1050 | linker_print_map: bool = false, | 1050 | linker_print_map: bool = false, |
| 1051 | llvm_opt_bisect_limit: i32 = -1, | 1051 | llvm_opt_bisect_limit: i32 = -1, |
| 1052 | each_lib_rpath: ?bool = null, | ||
| 1053 | build_id: ?std.zig.BuildId = null, | 1052 | build_id: ?std.zig.BuildId = null, |
| 1054 | disable_c_depfile: bool = false, | 1053 | disable_c_depfile: bool = false, |
| 1055 | linker_z_nodelete: bool = false, | 1054 | linker_z_nodelete: bool = false, |
| ... | @@ -1341,9 +1340,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil | ... | @@ -1341,9 +1340,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1341 | 1340 | ||
| 1342 | const error_limit = options.error_limit orelse (std.math.maxInt(u16) - 1); | 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 | // We put everything into the cache hash that *cannot be modified | 1343 | // We put everything into the cache hash that *cannot be modified |
| 1348 | // during an incremental update*. For example, one cannot change the | 1344 | // during an incremental update*. For example, one cannot change the |
| 1349 | // target between updates, but one can change source files, so the | 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,7 +1574,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1578 | .emit_relocs = options.link_emit_relocs, | 1574 | .emit_relocs = options.link_emit_relocs, |
| 1579 | .soname = options.soname, | 1575 | .soname = options.soname, |
| 1580 | .compatibility_version = options.compatibility_version, | 1576 | .compatibility_version = options.compatibility_version, |
| 1581 | .each_lib_rpath = each_lib_rpath, | ||
| 1582 | .build_id = build_id, | 1577 | .build_id = build_id, |
| 1583 | .disable_lld_caching = options.disable_lld_caching or options.cache_mode == .whole, | 1578 | .disable_lld_caching = options.disable_lld_caching or options.cache_mode == .whole, |
| 1584 | .subsystem = options.subsystem, | 1579 | .subsystem = options.subsystem, |
| ... | @@ -2552,7 +2547,6 @@ fn addNonIncrementalStuffToCacheManifest( | ... | @@ -2552,7 +2547,6 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2552 | man.hash.addListOfBytes(opts.lib_dirs); | 2547 | man.hash.addListOfBytes(opts.lib_dirs); |
| 2553 | man.hash.addListOfBytes(opts.rpath_list); | 2548 | man.hash.addListOfBytes(opts.rpath_list); |
| 2554 | man.hash.addListOfBytes(opts.symbol_wrap_set.keys()); | 2549 | man.hash.addListOfBytes(opts.symbol_wrap_set.keys()); |
| 2555 | man.hash.add(opts.each_lib_rpath); | ||
| 2556 | if (comp.config.link_libc) { | 2550 | if (comp.config.link_libc) { |
| 2557 | man.hash.add(comp.libc_installation != null); | 2551 | man.hash.add(comp.libc_installation != null); |
| 2558 | const target = comp.root_mod.resolved_target.result; | 2552 | const target = comp.root_mod.resolved_target.result; |
src/link.zig-1| ... | @@ -104,7 +104,6 @@ pub const File = struct { | ... | @@ -104,7 +104,6 @@ pub const File = struct { |
| 104 | max_memory: ?u64, | 104 | max_memory: ?u64, |
| 105 | export_symbol_names: []const []const u8, | 105 | export_symbol_names: []const []const u8, |
| 106 | global_base: ?u64, | 106 | global_base: ?u64, |
| 107 | each_lib_rpath: bool, | ||
| 108 | build_id: std.zig.BuildId, | 107 | build_id: std.zig.BuildId, |
| 109 | disable_lld_caching: bool, | 108 | disable_lld_caching: bool, |
| 110 | hash_style: Elf.HashStyle, | 109 | hash_style: Elf.HashStyle, |
src/link/Elf.zig-63| ... | @@ -16,7 +16,6 @@ lib_dirs: []const []const u8, | ... | @@ -16,7 +16,6 @@ lib_dirs: []const []const u8, |
| 16 | hash_style: HashStyle, | 16 | hash_style: HashStyle, |
| 17 | compress_debug_sections: CompressDebugSections, | 17 | compress_debug_sections: CompressDebugSections, |
| 18 | symbol_wrap_set: std.StringArrayHashMapUnmanaged(void), | 18 | symbol_wrap_set: std.StringArrayHashMapUnmanaged(void), |
| 19 | each_lib_rpath: bool, | ||
| 20 | sort_section: ?SortSection, | 19 | sort_section: ?SortSection, |
| 21 | soname: ?[]const u8, | 20 | soname: ?[]const u8, |
| 22 | bind_global_refs_locally: bool, | 21 | bind_global_refs_locally: bool, |
| ... | @@ -320,7 +319,6 @@ pub fn createEmpty( | ... | @@ -320,7 +319,6 @@ pub fn createEmpty( |
| 320 | .hash_style = options.hash_style, | 319 | .hash_style = options.hash_style, |
| 321 | .compress_debug_sections = options.compress_debug_sections, | 320 | .compress_debug_sections = options.compress_debug_sections, |
| 322 | .symbol_wrap_set = options.symbol_wrap_set, | 321 | .symbol_wrap_set = options.symbol_wrap_set, |
| 323 | .each_lib_rpath = options.each_lib_rpath, | ||
| 324 | .sort_section = options.sort_section, | 322 | .sort_section = options.sort_section, |
| 325 | .soname = options.soname, | 323 | .soname = options.soname, |
| 326 | .bind_global_refs_locally = options.bind_global_refs_locally, | 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,25 +1106,6 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) |
| 1108 | _ = try rpath_table.put(rpath, {}); | 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 | // TSAN | 1109 | // TSAN |
| 1131 | if (comp.config.any_sanitize_thread) { | 1110 | if (comp.config.any_sanitize_thread) { |
| 1132 | try positionals.append(.{ .path = comp.tsan_static_lib.?.full_object_path }); | 1111 | try positionals.append(.{ .path = comp.tsan_static_lib.?.full_object_path }); |
| ... | @@ -1693,22 +1672,6 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { | ... | @@ -1693,22 +1672,6 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1693 | try argv.append(rpath); | 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 | try argv.appendSlice(&.{ | 1675 | try argv.appendSlice(&.{ |
| 1713 | "-z", | 1676 | "-z", |
| 1714 | try std.fmt.allocPrint(arena, "stack-size={d}", .{self.base.stack_size}), | 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,7 +2402,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2439 | man.hash.add(comp.config.rdynamic); | 2402 | man.hash.add(comp.config.rdynamic); |
| 2440 | man.hash.addListOfBytes(self.lib_dirs); | 2403 | man.hash.addListOfBytes(self.lib_dirs); |
| 2441 | man.hash.addListOfBytes(self.base.rpath_list); | 2404 | man.hash.addListOfBytes(self.base.rpath_list); |
| 2442 | man.hash.add(self.each_lib_rpath); | ||
| 2443 | if (output_mode == .Exe) { | 2405 | if (output_mode == .Exe) { |
| 2444 | man.hash.add(self.base.stack_size); | 2406 | man.hash.add(self.base.stack_size); |
| 2445 | man.hash.add(self.base.build_id); | 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,31 +2701,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2739 | try argv.appendSlice(&.{ "-wrap", symbol_name }); | 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 | for (self.lib_dirs) |lib_dir| { | 2704 | for (self.lib_dirs) |lib_dir| { |
| 2768 | try argv.append("-L"); | 2705 | try argv.append("-L"); |
| 2769 | try argv.append(lib_dir); | 2706 | try argv.append(lib_dir); |
src/main.zig+8-4| ... | @@ -866,7 +866,6 @@ fn buildOutputType( | ... | @@ -866,7 +866,6 @@ fn buildOutputType( |
| 866 | var image_base: ?u64 = null; | 866 | var image_base: ?u64 = null; |
| 867 | var link_eh_frame_hdr = false; | 867 | var link_eh_frame_hdr = false; |
| 868 | var link_emit_relocs = false; | 868 | var link_emit_relocs = false; |
| 869 | var each_lib_rpath: ?bool = null; | ||
| 870 | var build_id: ?std.zig.BuildId = null; | 869 | var build_id: ?std.zig.BuildId = null; |
| 871 | var runtime_args_start: ?usize = null; | 870 | var runtime_args_start: ?usize = null; |
| 872 | var test_filter: ?[]const u8 = null; | 871 | var test_filter: ?[]const u8 = null; |
| ... | @@ -964,6 +963,7 @@ fn buildOutputType( | ... | @@ -964,6 +963,7 @@ fn buildOutputType( |
| 964 | .frameworks = .{}, | 963 | .frameworks = .{}, |
| 965 | .framework_dirs = .{}, | 964 | .framework_dirs = .{}, |
| 966 | .rpath_list = .{}, | 965 | .rpath_list = .{}, |
| 966 | .each_lib_rpath = null, | ||
| 967 | .libc_paths_file = try EnvVar.ZIG_LIBC.get(arena), | 967 | .libc_paths_file = try EnvVar.ZIG_LIBC.get(arena), |
| 968 | .link_objects = .{}, | 968 | .link_objects = .{}, |
| 969 | .native_system_include_paths = &.{}, | 969 | .native_system_include_paths = &.{}, |
| ... | @@ -1334,9 +1334,9 @@ fn buildOutputType( | ... | @@ -1334,9 +1334,9 @@ fn buildOutputType( |
| 1334 | } else if (mem.eql(u8, arg, "-fno-compiler-rt")) { | 1334 | } else if (mem.eql(u8, arg, "-fno-compiler-rt")) { |
| 1335 | want_compiler_rt = false; | 1335 | want_compiler_rt = false; |
| 1336 | } else if (mem.eql(u8, arg, "-feach-lib-rpath")) { | 1336 | } else if (mem.eql(u8, arg, "-feach-lib-rpath")) { |
| 1337 | each_lib_rpath = true; | 1337 | create_module.each_lib_rpath = true; |
| 1338 | } else if (mem.eql(u8, arg, "-fno-each-lib-rpath")) { | 1338 | } else if (mem.eql(u8, arg, "-fno-each-lib-rpath")) { |
| 1339 | each_lib_rpath = false; | 1339 | create_module.each_lib_rpath = false; |
| 1340 | } else if (mem.eql(u8, arg, "--test-cmd-bin")) { | 1340 | } else if (mem.eql(u8, arg, "--test-cmd-bin")) { |
| 1341 | try test_exec_args.append(null); | 1341 | try test_exec_args.append(null); |
| 1342 | } else if (mem.eql(u8, arg, "--test-evented-io")) { | 1342 | } else if (mem.eql(u8, arg, "--test-evented-io")) { |
| ... | @@ -3236,7 +3236,6 @@ fn buildOutputType( | ... | @@ -3236,7 +3236,6 @@ fn buildOutputType( |
| 3236 | .verbose_llvm_cpu_features = verbose_llvm_cpu_features, | 3236 | .verbose_llvm_cpu_features = verbose_llvm_cpu_features, |
| 3237 | .time_report = time_report, | 3237 | .time_report = time_report, |
| 3238 | .stack_report = stack_report, | 3238 | .stack_report = stack_report, |
| 3239 | .each_lib_rpath = each_lib_rpath, | ||
| 3240 | .build_id = build_id, | 3239 | .build_id = build_id, |
| 3241 | .test_filter = test_filter, | 3240 | .test_filter = test_filter, |
| 3242 | .test_name_prefix = test_name_prefix, | 3241 | .test_name_prefix = test_name_prefix, |
| ... | @@ -3450,6 +3449,7 @@ const CreateModule = struct { | ... | @@ -3450,6 +3449,7 @@ const CreateModule = struct { |
| 3450 | native_system_include_paths: []const []const u8, | 3449 | native_system_include_paths: []const []const u8, |
| 3451 | framework_dirs: std.ArrayListUnmanaged([]const u8), | 3450 | framework_dirs: std.ArrayListUnmanaged([]const u8), |
| 3452 | rpath_list: std.ArrayListUnmanaged([]const u8), | 3451 | rpath_list: std.ArrayListUnmanaged([]const u8), |
| 3452 | each_lib_rpath: ?bool, | ||
| 3453 | libc_paths_file: ?[]const u8, | 3453 | libc_paths_file: ?[]const u8, |
| 3454 | link_objects: std.ArrayListUnmanaged(Compilation.LinkObject), | 3454 | link_objects: std.ArrayListUnmanaged(Compilation.LinkObject), |
| 3455 | }; | 3455 | }; |
| ... | @@ -3644,6 +3644,10 @@ fn createModule( | ... | @@ -3644,6 +3644,10 @@ fn createModule( |
| 3644 | create_module.want_native_include_dirs = true; | 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 | // Trigger native system library path detection if necessary. | 3651 | // Trigger native system library path detection if necessary. |
| 3648 | if (create_module.sysroot == null and | 3652 | if (create_module.sysroot == null and |
| 3649 | resolved_target.is_native_os and resolved_target.is_native_abi and | 3653 | resolved_target.is_native_os and resolved_target.is_native_abi and |