Skip to content

Commit 096175e

Browse files
committed
Use the platform of a stub binary when looking up compatible architectures
1 parent 9268518 commit 096175e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Sources/SWBTaskConstruction/TaskProducers/TaskProducer.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,11 @@ public class TaskProducerContext: StaleFileRemovalContext, BuildFileResolution
810810

811811
public func availableMatchingArchitecturesInStubBinary(at stubBinary: Path, requestedArchs: [String]) async -> [String] {
812812
let stubArchs: Set<String>
813+
let stubPlatforms: [any PlatformInfoProvider]
813814
do {
814-
stubArchs = try globalProductPlan.planRequest.buildRequestContext.getCachedMachOInfo(at: stubBinary).architectures
815+
let stubInfo = try globalProductPlan.planRequest.buildRequestContext.getCachedMachOInfo(at: stubBinary)
816+
stubArchs = stubInfo.architectures
817+
stubPlatforms = stubInfo.platforms.compactMap { lookupPlatformInfo(platform: $0) }
815818
} catch {
816819
delegate.error("unable to create tasks to copy stub binary: can't determine architectures of binary: \(stubBinary.str): \(error)")
817820
return []
@@ -821,12 +824,14 @@ public class TaskProducerContext: StaleFileRemovalContext, BuildFileResolution
821824
if stubArchs.contains(arch) {
822825
archsToExtract.insert(arch)
823826
} else {
824-
let specLookupContext = SpecLookupCtxt(specRegistry: workspaceContext.core.specRegistry, platform: settings.platform)
825-
let compatibilityArchs = (specLookupContext.getSpec(arch) as? ArchitectureSpec)?.compatibilityArchs
826-
if let compatibleArch = compatibilityArchs?.first(where: { stubArchs.contains($0) }) {
827+
var compatibilityArchs: [String] = []
828+
for platform in stubPlatforms {
829+
compatibilityArchs.append(contentsOf: (workspaceContext.core.specRegistry.getSpec(arch, domain: platform.name) as? ArchitectureSpec)?.compatibilityArchs ?? [])
830+
}
831+
if let compatibleArch = compatibilityArchs.first(where: { stubArchs.contains($0) }) {
827832
archsToExtract.insert(compatibleArch)
828833
} else {
829-
delegate.warning("stub binary at '\(stubBinary.str)' does not contain a slice for '\(arch)' or a compatible architecture")
834+
delegate.warning("stub binary at '\(stubBinary.str)' does not contain a slice for '\(arch)' or a compatible architecture. Stub architectures: \(stubArchs.joined(separator: ", ")). Compatibility architectures for \(arch): \(compatibilityArchs.joined(separator: ", "))")
830835
}
831836
}
832837
}

0 commit comments

Comments
 (0)