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;...@@ -15,8 +15,6 @@ const Target = std.Target;
15const CrossTarget = std.zig.CrossTarget;15const CrossTarget = std.zig.CrossTarget;
16const macos = @import("system/macos.zig");16const macos = @import("system/macos.zig");
1717
18const is_windows = Target.current.os.tag == .windows;
19
20pub const getSDKPath = macos.getSDKPath;18pub const getSDKPath = macos.getSDKPath;
2119
22pub const NativePaths = struct {20pub const NativePaths = struct {
...@@ -26,7 +24,9 @@ pub const NativePaths = struct {...@@ -26,7 +24,9 @@ pub const NativePaths = struct {
26 rpaths: ArrayList([:0]u8),24 rpaths: ArrayList([:0]u8),
27 warnings: ArrayList([:0]u8),25 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
30 var self: NativePaths = .{30 var self: NativePaths = .{
31 .include_dirs = ArrayList([:0]u8).init(allocator),31 .include_dirs = ArrayList([:0]u8).init(allocator),
32 .lib_dirs = ArrayList([:0]u8).init(allocator),32 .lib_dirs = ArrayList([:0]u8).init(allocator),
...@@ -103,9 +103,9 @@ pub const NativePaths = struct {...@@ -103,9 +103,9 @@ pub const NativePaths = struct {
103 return self;103 return self;
104 }104 }
105105
106 if (!is_windows) {106 if (native_target.os.tag != .windows) {
107 const triple = try Target.current.linuxTriple(allocator);107 const triple = try native_target.linuxTriple(allocator);
108 const qual = Target.current.cpu.arch.ptrBitWidth();108 const qual = native_target.cpu.arch.ptrBitWidth();
109109
110 // TODO: $ ld --verbose | grep SEARCH_DIR110 // TODO: $ ld --verbose | grep SEARCH_DIR
111 // the output contains some paths that end with lib64, maybe include them too?111 // the output contains some paths that end with lib64, maybe include them too?
src/main.zig+1-1
...@@ -1448,7 +1448,7 @@ fn buildOutputType(...@@ -1448,7 +1448,7 @@ fn buildOutputType(
1448 }1448 }
14491449
1450 if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) {1450 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| {
1452 fatal("unable to detect native system paths: {s}", .{@errorName(err)});1452 fatal("unable to detect native system paths: {s}", .{@errorName(err)});
1453 };1453 };
1454 for (paths.warnings.items) |warning| {1454 for (paths.warnings.items) |warning| {