authorgravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2020-12-15 19:30:00+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-08 20:07:59-07:00
loge4b8148e9c0dc8e1e523965456a59d469e93a26c
tree07f4da41e0fd295a45cee5530ba24edc63161c06
parenteb696e453ff770e54188e14acb65e01e87a4eebd

Fix system library path detection on linux

Uses the NativeTargetInfo results instead of std.Target.current.

2 files changed, 7 insertions(+), 7 deletions(-)

lib/std/zig/system.zig+6-6
......@@ -15,8 +15,6 @@ const Target = std.Target;
1515const CrossTarget = std.zig.CrossTarget;
1616const macos = @import("system/macos.zig");
1717
18const is_windows = Target.current.os.tag == .windows;
19
2018pub const getSDKPath = macos.getSDKPath;
2119
2220pub const NativePaths = struct {
......@@ -26,7 +24,9 @@ pub const NativePaths = struct {
2624 rpaths: ArrayList([:0]u8),
2725 warnings: ArrayList([:0]u8),
2826
29 pub fn detect(allocator: *Allocator) !NativePaths {
27 pub fn detect(allocator: *Allocator, native_info: NativeTargetInfo) !NativePaths {
28 const native_target = native_info.target;
29
3030 var self: NativePaths = .{
3131 .include_dirs = ArrayList([:0]u8).init(allocator),
3232 .lib_dirs = ArrayList([:0]u8).init(allocator),
......@@ -103,9 +103,9 @@ pub const NativePaths = struct {
103103 return self;
104104 }
105105
106 if (!is_windows) {
107 const triple = try Target.current.linuxTriple(allocator);
108 const qual = Target.current.cpu.arch.ptrBitWidth();
106 if (native_target.os.tag != .windows) {
107 const triple = try native_target.linuxTriple(allocator);
108 const qual = native_target.cpu.arch.ptrBitWidth();
109109
110110 // TODO: $ ld --verbose | grep SEARCH_DIR
111111 // the output contains some paths that end with lib64, maybe include them too?
src/main.zig+1-1
......@@ -1448,7 +1448,7 @@ fn buildOutputType(
14481448 }
14491449
14501450 if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) {
1451 const paths = std.zig.system.NativePaths.detect(arena) catch |err| {
1451 const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| {
14521452 fatal("unable to detect native system paths: {s}", .{@errorName(err)});
14531453 };
14541454 for (paths.warnings.items) |warning| {