Skip to content

Commit bc4722e

Browse files
authored
swift build --build-system xcode is hardcoding "x86_64" rather than using the build destination triple (#3597)
When using the `xcode` build system, SwiftPM isn't passing down the same architecture that the native build system would have used. This has probably been masked in practice by the `xcode` build system only being used by default when multiple architectures are involved, in which case an overriding set of architectures is passed down. rdar://80334540
1 parent 1a146f4 commit bc4722e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Sources/XCBuildSupport/XcodeBuildSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
127127
platform: "macosx",
128128
sdk: "macosx",
129129
sdkVariant: nil,
130-
targetArchitecture: "x86_64",
130+
targetArchitecture: buildParameters.triple.arch.rawValue,
131131
supportedArchitectures: [],
132132
disableOnlyActiveArch: true
133133
)

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ final class BuildToolTests: XCTestCase {
282282
}
283283
}
284284

285+
func testXcodeBuildSystemDefaultSettings() throws {
286+
#if !os(macOS)
287+
try XCTSkipIf(true, "test requires `xcbuild` and is therefore only supported on macOS")
288+
#endif
289+
fixture(name: "ValidLayouts/SingleModule/ExecutableNew") { path in
290+
// Try building using XCBuild with default parameters. This should succeed. We build verbosely so we get full command lines.
291+
let defaultOutput = try execute(["-c", "debug", "-v"], packagePath: path).stdout
292+
293+
// Look for certain things in the output from XCBuild.
294+
XCTAssert(defaultOutput.contains("-target \(Resources.default.toolchain.triple.tripleString)"), defaultOutput)
295+
}
296+
}
297+
285298
func testXcodeBuildSystemOverrides() throws {
286299
#if !os(macOS)
287300
try XCTSkipIf(true, "test requires `xcbuild` and is therefore only supported on macOS")

0 commit comments

Comments
 (0)