mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
macho: allow .simulator ABI when targeting Apple simulator env
For example, in order to run a binary on an iPhone Simulator, you need to specify that explicitly as part of the target as `aarch64-ios-simulator` rather than `aarch64-ios-gnu` or `aarch64-ios` for short.
This commit is contained in:
parent
7007684984
commit
2371a63bd4
@ -2736,14 +2736,15 @@ fn populateMetadata(self: *MachO) !void {
|
||||
));
|
||||
const ver = self.base.options.target.os.version_range.semver.min;
|
||||
const version = ver.major << 16 | ver.minor << 8 | ver.patch;
|
||||
const is_simulator_abi = self.base.options.target.abi == .simulator;
|
||||
var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{
|
||||
.cmd = macho.LC_BUILD_VERSION,
|
||||
.cmdsize = cmdsize,
|
||||
.platform = switch (self.base.options.target.os.tag) {
|
||||
.macos => macho.PLATFORM_MACOS,
|
||||
.ios => macho.PLATFORM_IOSSIMULATOR,
|
||||
.watchos => macho.PLATFORM_WATCHOS,
|
||||
.tvos => macho.PLATFORM_TVOS,
|
||||
.ios => if (is_simulator_abi) macho.PLATFORM_IOSSIMULATOR else macho.PLATFORM_IOS,
|
||||
.watchos => if (is_simulator_abi) macho.PLATFORM_WATCHOSSIMULATOR else macho.PLATFORM_WATCHOS,
|
||||
.tvos => if (is_simulator_abi) macho.PLATFORM_TVOSSIMULATOR else macho.PLATFORM_TVOS,
|
||||
else => unreachable,
|
||||
},
|
||||
.minos = version,
|
||||
@ -4355,14 +4356,15 @@ pub fn populateMissingMetadata(self: *MachO) !void {
|
||||
));
|
||||
const ver = self.base.options.target.os.version_range.semver.min;
|
||||
const version = ver.major << 16 | ver.minor << 8 | ver.patch;
|
||||
const is_simulator_abi = self.base.options.target.abi == .simulator;
|
||||
var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{
|
||||
.cmd = macho.LC_BUILD_VERSION,
|
||||
.cmdsize = cmdsize,
|
||||
.platform = switch (self.base.options.target.os.tag) {
|
||||
.macos => macho.PLATFORM_MACOS,
|
||||
.ios => macho.PLATFORM_IOSSIMULATOR,
|
||||
.watchos => macho.PLATFORM_WATCHOS,
|
||||
.tvos => macho.PLATFORM_TVOS,
|
||||
.ios => if (is_simulator_abi) macho.PLATFORM_IOSSIMULATOR else macho.PLATFORM_IOS,
|
||||
.watchos => if (is_simulator_abi) macho.PLATFORM_WATCHOSSIMULATOR else macho.PLATFORM_WATCHOS,
|
||||
.tvos => if (is_simulator_abi) macho.PLATFORM_TVOSSIMULATOR else macho.PLATFORM_TVOS,
|
||||
else => unreachable,
|
||||
},
|
||||
.minos = version,
|
||||
|
||||
@ -340,10 +340,16 @@ fn targetToAppleString(allocator: *Allocator, target: std.Target) ![]const u8 {
|
||||
.x86_64 => "x86_64",
|
||||
else => unreachable,
|
||||
};
|
||||
if (target.os.tag == .ios) {
|
||||
return std.fmt.allocPrint(allocator, "{s}-{s}-simulator", .{ arch, @tagName(target.os.tag) });
|
||||
const os = @tagName(target.os.tag);
|
||||
const abi: ?[]const u8 = switch (target.abi) {
|
||||
.gnu => null,
|
||||
.simulator => "simulator",
|
||||
else => unreachable,
|
||||
};
|
||||
if (abi) |x| {
|
||||
return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ arch, os, x });
|
||||
}
|
||||
return std.fmt.allocPrint(allocator, "{s}-{s}", .{ arch, @tagName(target.os.tag) });
|
||||
return std.fmt.allocPrint(allocator, "{s}-{s}", .{ arch, os });
|
||||
}
|
||||
|
||||
pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, lib_stub: LibStub) !void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user