Skip to content

Commit bad6319

Browse files
MaxDesiatovfurby-tm
authored andcommitted
Revert "Revert "Support macros when cross-compiling (swiftlang#7118)" (swiftlang#7352)" (swiftlang#7353)
Reverts swiftlang#7352. Modified to build tests for the host triple when any macros are added to test modules directly as dependencies.
1 parent 5747b10 commit bad6319

File tree

55 files changed

+1410
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1410
-472
lines changed

CHANGELOG.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
Note: This is in reverse chronological order, so newer entries are added to the top.
22

3-
Swift Next
3+
Swift 6.0
44
-----------
55

66
* [#7202]
77

88
Package manifests can now access information about the Git repository the given package is in via the context object's
99
`gitInformation` property. This allows to determine the current tag (if any), the current commit and whether or not there are uncommited changes.
1010

11+
* [#7201]
12+
13+
`// swift-tools-version:` can now be specified on subsequent lines of `Package.swift`, for example when first few lines are required to contain a licensing comment header.
14+
15+
* [#7118]
16+
17+
Macros cross-compiled by SwiftPM with Swift SDKs are now correctly built, loaded, and evaluated for the host triple.
18+
19+
Swift 5.10
20+
-----------
21+
1122
* [#7010]
1223

1324
On macOS, `swift build` and `swift run` now produce binaries that allow backtraces in debug builds. Pass `SWIFT_BACKTRACE=enable=yes` environment variable to enable backtraces on such binaries when running them.
1425

15-
* [7101]
26+
* [#7101]
1627

1728
Binary artifacts are now cached along side repository checkouts so they do not need to be re-downloaded across projects.
1829

@@ -387,4 +398,8 @@ Swift 3.0
387398
[#6276]: https://github.com/apple/swift-package-manager/pull/6276
388399
[#6540]: https://github.com/apple/swift-package-manager/pull/6540
389400
[#6663]: https://github.com/apple/swift-package-manager/pull/6663
401+
[#7010]: https://github.com/apple/swift-package-manager/pull/7010
390402
[#7101]: https://github.com/apple/swift-package-manager/pull/7101
403+
[#7118]: https://github.com/apple/swift-package-manager/pull/7118
404+
[#7201]: https://github.com/apple/swift-package-manager/pull/7201
405+
[#7202]: https://github.com/apple/swift-package-manager/pull/7202

Sources/Basics/Collections/IdentifiableSet.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ public struct IdentifiableSet<Element: Identifiable>: Collection {
4545
}
4646

4747
public subscript(id: Element.ID) -> Element? {
48-
self.storage[id]
48+
get {
49+
self.storage[id]
50+
}
51+
set {
52+
self.storage[id] = newValue
53+
}
4954
}
5055

5156
public func index(after i: Index) -> Index {
5257
Index(storageIndex: self.storage.index(after: i.storageIndex))
5358
}
5459

60+
public mutating func insert(_ element: Element) {
61+
self.storage[element.id] = element
62+
}
63+
5564
public func union(_ otherSequence: some Sequence<Element>) -> Self {
5665
var result = self
5766
for element in otherSequence {

Sources/Build/BuildDescription/ClangTargetBuildDescription.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ package final class ClangTargetBuildDescription {
5353

5454
/// Path to the bundle generated for this module (if any).
5555
var bundlePath: AbsolutePath? {
56-
guard !resources.isEmpty else {
56+
guard !self.resources.isEmpty else {
5757
return .none
5858
}
5959

@@ -133,7 +133,7 @@ package final class ClangTargetBuildDescription {
133133
self.target = target
134134
self.toolsVersion = toolsVersion
135135
self.buildParameters = buildParameters
136-
self.tempsPath = buildParameters.buildPath.appending(component: target.c99name + ".build")
136+
self.tempsPath = target.tempsPath(buildParameters)
137137
self.derivedSources = Sources(paths: [], root: tempsPath.appending("DerivedSources"))
138138

139139
// We did not use to apply package plugins to C-family targets in prior tools-versions, this preserves the behavior.
@@ -225,7 +225,7 @@ package final class ClangTargetBuildDescription {
225225
if self.buildParameters.triple.isDarwin() {
226226
args += ["-fobjc-arc"]
227227
}
228-
args += try buildParameters.targetTripleArgs(for: target)
228+
args += try self.buildParameters.tripleArgs(for: target)
229229

230230
args += optimizationArguments
231231
args += activeCompilationConditions

Sources/Build/BuildDescription/ProductBuildDescription.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescriptio
321321
// setting is the package-level right now. We might need to figure out a better
322322
// answer for libraries if/when we support specifying deployment target at the
323323
// target-level.
324-
args += try self.buildParameters.targetTripleArgs(for: self.product.targets[self.product.targets.startIndex])
324+
args += try self.buildParameters.tripleArgs(for: self.product.targets[self.product.targets.startIndex])
325325

326326
// Add arguments from declared build settings.
327327
args += self.buildSettingsFlags
@@ -356,7 +356,7 @@ package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescriptio
356356
// Library search path for the toolchain's copy of SwiftSyntax.
357357
#if BUILD_MACROS_AS_DYLIBS
358358
if product.type == .macro {
359-
args += try ["-L", buildParameters.toolchain.hostLibDir.pathString]
359+
args += try ["-L", defaultBuildParameters.toolchain.hostLibDir.pathString]
360360
}
361361
#endif
362362

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2015-2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import struct Basics.AbsolutePath
14+
import struct PackageGraph.ResolvedModule
15+
16+
import SPMBuildCore
17+
18+
extension ResolvedModule {
19+
func tempsPath(_ buildParameters: BuildParameters) -> AbsolutePath {
20+
let suffix = buildParameters.suffix(triple: self.buildTriple)
21+
return buildParameters.buildPath.appending(component: "\(self.c99name)\(suffix).build")
22+
}
23+
}

0 commit comments

Comments
 (0)