fix not setting the dynamic linker path when cross compiling

This commit is contained in:
Andrew Kelley 2020-02-26 16:32:28 -05:00
parent 0912484c4f
commit 622b5b62c2
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -668,6 +668,7 @@ export fn stage2_target_parse(
error.ProcessFdQuotaExceeded => return .ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded => return .SystemFdQuotaExceeded,
error.DeviceBusy => return .DeviceBusy,
error.UnknownDynamicLinkerPath => return .UnknownDynamicLinkerPath,
};
return .None;
}
@ -1137,6 +1138,7 @@ fn enumInt(comptime Enum: type, int: c_int) Enum {
/// TODO self-host this function
fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8) !Target {
var adjusted_target = cross_target.toTarget();
var have_native_dl = false;
if (cross_target.cpu_arch == null or cross_target.os_tag == null) {
const detected_info = try std.zig.system.NativeTargetInfo.detect(std.heap.c_allocator);
if (cross_target.cpu_arch == null) {
@ -1155,6 +1157,7 @@ fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8)
adjusted_target.os = detected_info.target.os;
if (detected_info.dynamic_linker) |dl| {
have_native_dl = true;
dynamic_linker_ptr.* = dl.ptr;
}
if (cross_target.abi == null) {
@ -1164,6 +1167,14 @@ fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8)
adjusted_target.abi = Target.Abi.default(adjusted_target.cpu.arch, adjusted_target.os);
}
}
if (!have_native_dl) {
dynamic_linker_ptr.* = adjusted_target.getStandardDynamicLinkerPath(
std.heap.c_allocator,
) catch |err| switch (err) {
error.TargetHasNoDynamicLinker => null,
else => |e| return e,
};
}
return adjusted_target;
}