Skip to content

Commit 541733f

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

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Sources/SWBTaskConstruction/TaskProducers/TaskProducer.swift

Lines changed: 9 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,13 @@ 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+
let compatibilityArchs: [String] = stubPlatforms.flatMap { platform in
828+
(workspaceContext.core.specRegistry.getSpec(arch, domain: platform.name) as? ArchitectureSpec)?.compatibilityArchs ?? []
829+
}
830+
if let compatibleArch = compatibilityArchs.first(where: { stubArchs.contains($0) }) {
827831
archsToExtract.insert(compatibleArch)
828832
} else {
829-
delegate.warning("stub binary at '\(stubBinary.str)' does not contain a slice for '\(arch)' or a compatible architecture")
833+
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: ", "))")
830834
}
831835
}
832836
}

0 commit comments

Comments
 (0)