Skip to content

Commit 9fd1884

Browse files
committed
Use -print-target-info instead of a hardcoded triple
1 parent 6d93142 commit 9fd1884

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
592592
}
593593
}
594594

595+
private static var _hostTriple: Triple?
595596
private static var _packageDescriptionMinimumDeploymentTarget: String?
596597

597598
/// Parse the manifest at the given path to JSON.
@@ -660,11 +661,15 @@ public final class ManifestLoader: ManifestLoaderProtocol {
660661

661662
// Use the same minimum deployment target as the PackageDescription library (with a fallback of 10.15).
662663
#if os(macOS)
664+
if Self._hostTriple == nil {
665+
Self._hostTriple = Triple.getHostTriple(usingSwiftCompiler: resources.swiftCompiler.pathString)
666+
}
667+
let triple = Self._hostTriple!
663668
if Self._packageDescriptionMinimumDeploymentTarget == nil {
664669
Self._packageDescriptionMinimumDeploymentTarget = (try MinimumDeploymentTarget.computeMinimumDeploymentTarget(of: macOSPackageDescriptionPath))?.versionString ?? "10.15"
665670
}
666671
let version = Self._packageDescriptionMinimumDeploymentTarget!
667-
cmd += ["-target", "x86_64-apple-macosx\(version)"]
672+
cmd += ["-target", "\(triple)\(version)"]
668673
#endif
669674

670675
cmd += compilerFlags

Sources/SPMBuildCore/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ add_library(SPMBuildCore
1111
BuildSystem.swift
1212
BuiltTestProduct.swift
1313
Sanitizers.swift
14-
Toolchain.swift
15-
Triple.swift)
14+
Toolchain.swift)
1615
# NOTE(compnerd) workaround for CMake not setting up include flags yet
1716
set_target_properties(SPMBuildCore PROPERTIES
1817
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

swift-tools-support-core/Sources/TSCUtility/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_library(TSCUtility
3232
SimplePersistence.swift
3333
StringExtensions.swift
3434
StringMangling.swift
35+
Triple.swift
3536
URL.swift
3637
Verbosity.swift
3738
Version.swift

0 commit comments

Comments
 (0)