| ... | ... | @@ -76,13 +76,16 @@ fn calcLCsSize(gpa: Allocator, options: *const link.Options, ctx: CalcLCsSizeCtx |
| 76 | 76 | } |
| 77 | 77 | // LC_SOURCE_VERSION |
| 78 | 78 | sizeofcmds += @sizeOf(macho.source_version_command); |
| 79 | | // LC_BUILD_VERSION or LC_VERSION_MIN_ |
| 80 | | if (Platform.fromTarget(options.target).isBuildVersionCompatible()) { |
| 81 | | // LC_BUILD_VERSION |
| 82 | | sizeofcmds += @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version); |
| 83 | | } else { |
| 84 | | // LC_VERSION_MIN_ |
| 85 | | sizeofcmds += @sizeOf(macho.version_min_command); |
| 79 | // LC_BUILD_VERSION or LC_VERSION_MIN_ or nothing |
| 80 | { |
| 81 | const platform = Platform.fromTarget(options.target); |
| 82 | if (platform.isBuildVersionCompatible()) { |
| 83 | // LC_BUILD_VERSION |
| 84 | sizeofcmds += @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version); |
| 85 | } else if (platform.isVersionMinCompatible()) { |
| 86 | // LC_VERSION_MIN_ |
| 87 | sizeofcmds += @sizeOf(macho.version_min_command); |
| 88 | } |
| 86 | 89 | } |
| 87 | 90 | // LC_UUID |
| 88 | 91 | sizeofcmds += @sizeOf(macho.uuid_command); |
| ... | ... | @@ -384,6 +387,15 @@ pub const Platform = struct { |
| 384 | 387 | return false; |
| 385 | 388 | } |
| 386 | 389 | |
| 390 | pub fn isVersionMinCompatible(plat: Platform) bool { |
| 391 | inline for (supported_platforms) |sup_plat| { |
| 392 | if (sup_plat[0] == plat.os_tag and sup_plat[1] == plat.abi) { |
| 393 | return sup_plat[3] <= plat.toAppleVersion(); |
| 394 | } |
| 395 | } |
| 396 | return false; |
| 397 | } |
| 398 | |
| 387 | 399 | pub fn fmtTarget(plat: Platform, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(formatTarget) { |
| 388 | 400 | return .{ .data = .{ .platform = plat, .cpu_arch = cpu_arch } }; |
| 389 | 401 | } |