Fix system library path detection on linux

Uses the NativeTargetInfo results instead of std.Target.current.
This commit is contained in:
xackus 2020-12-15 19:30:00 +01:00 committed by Andrew Kelley
parent eb696e453f
commit e4b8148e9c
2 changed files with 7 additions and 7 deletions

View File

@ -15,8 +15,6 @@ const Target = std.Target;
const CrossTarget = std.zig.CrossTarget;
const macos = @import("system/macos.zig");
const is_windows = Target.current.os.tag == .windows;
pub const getSDKPath = macos.getSDKPath;
pub const NativePaths = struct {
@ -26,7 +24,9 @@ pub const NativePaths = struct {
rpaths: ArrayList([:0]u8),
warnings: ArrayList([:0]u8),
pub fn detect(allocator: *Allocator) !NativePaths {
pub fn detect(allocator: *Allocator, native_info: NativeTargetInfo) !NativePaths {
const native_target = native_info.target;
var self: NativePaths = .{
.include_dirs = ArrayList([:0]u8).init(allocator),
.lib_dirs = ArrayList([:0]u8).init(allocator),
@ -103,9 +103,9 @@ pub const NativePaths = struct {
return self;
}
if (!is_windows) {
const triple = try Target.current.linuxTriple(allocator);
const qual = Target.current.cpu.arch.ptrBitWidth();
if (native_target.os.tag != .windows) {
const triple = try native_target.linuxTriple(allocator);
const qual = native_target.cpu.arch.ptrBitWidth();
// TODO: $ ld --verbose | grep SEARCH_DIR
// the output contains some paths that end with lib64, maybe include them too?

View File

@ -1448,7 +1448,7 @@ fn buildOutputType(
}
if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) {
const paths = std.zig.system.NativePaths.detect(arena) catch |err| {
const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| {
fatal("unable to detect native system paths: {s}", .{@errorName(err)});
};
for (paths.warnings.items) |warning| {