Skip to content

Support macros when cross-compiling #7118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ee34109
Keep separate build parameters for host and target
MaxDesiatov Dec 5, 2023
12a1ea0
Fix build errors
MaxDesiatov Dec 6, 2023
d020e28
Fix tests, restore SourceKit-LSP compatibility
MaxDesiatov Dec 6, 2023
1270b44
Address remaining deprecations of `buildParameters` use
MaxDesiatov Dec 6, 2023
172055c
Remove unused deprecated properties and functions
MaxDesiatov Dec 6, 2023
7592888
Deprecate old `BuildPlan` initializer with no `BuildParameters` disti…
MaxDesiatov Dec 6, 2023
0fee29a
Clean up formattin
MaxDesiatov Dec 6, 2023
fc8e92c
Fix Linux build issues in tests
MaxDesiatov Dec 6, 2023
38ffcae
Support macros when cross-compiling
MaxDesiatov Nov 23, 2023
57e9c9d
Fix build issues after rebase
MaxDesiatov Dec 6, 2023
dc18982
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Dec 15, 2023
a148910
Clean up the diff
MaxDesiatov Dec 15, 2023
e542e7a
Use `topologicalSort` with `Identifiable` on `ResolvedTarget`
MaxDesiatov Dec 20, 2023
8e167f1
Reduce number of iterations in `testRecursiveDependencies`
MaxDesiatov Dec 21, 2023
b9126a3
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Dec 21, 2023
871e653
Merge branch 'maxd/identifiable-topological-sort' of github.com:apple…
MaxDesiatov Dec 21, 2023
cde00ec
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Jan 2, 2024
4d26807
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Jan 25, 2024
ef8e36c
Update `buildTriple` in `ResolvedTarget` and `ResolvedProduct`
MaxDesiatov Jan 30, 2024
779f7e8
Remove debug logging
MaxDesiatov Jan 30, 2024
2e144e1
Refine `ResolvedTarget/description` for logging
MaxDesiatov Jan 30, 2024
83aad66
Make sure host tools dependencies are in the build plan
MaxDesiatov Jan 30, 2024
63eaf8d
Fix nodes naming collisions in the build plan
MaxDesiatov Jan 31, 2024
eabe05b
Fix remaining name collisions in llbuild manifests
MaxDesiatov Feb 6, 2024
f59aeb1
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Feb 6, 2024
a8b35ef
Fix incorrect `-tool` suffix module paths, plugins build triple
MaxDesiatov Feb 13, 2024
2cd8150
Fix package plugins built without `-tool` suffix
MaxDesiatov Feb 15, 2024
73a6a99
Fix `PluginsBuildPlanTests` failure
MaxDesiatov Feb 15, 2024
3ade20f
Assign correct triple to macro products, fix macros load path
MaxDesiatov Feb 15, 2024
d083be6
Fix stray debug printer
MaxDesiatov Feb 15, 2024
379bf0f
Restore `BuildPlan(productsBuildParameters:...)` compat
MaxDesiatov Feb 16, 2024
99b7bd6
Fix doc comment
MaxDesiatov Feb 16, 2024
b83db64
Address PR feedback
MaxDesiatov Feb 16, 2024
76dd8c4
Update `CHANGELOG.md`
MaxDesiatov Feb 16, 2024
788c7af
Fix tests for `destinationBuildParameters` property renaming
MaxDesiatov Feb 16, 2024
e858a4c
Fix `destinationBuildParameters` renaming
MaxDesiatov Feb 16, 2024
9b055aa
Merge branch 'main' of github.com:apple/swift-package-manager into ma…
MaxDesiatov Feb 18, 2024
889acfd
Fix build directory path in `BuildOperationTests`
MaxDesiatov Feb 18, 2024
cfc1b65
Update CHANGELOG.md
MaxDesiatov Feb 18, 2024
10d1aea
Update CHANGELOG.md
MaxDesiatov Feb 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
Note: This is in reverse chronological order, so newer entries are added to the top.

Swift Next
Swift 6.0
-----------

* [#7202]

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

* [#7201]

`// 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.

* [#7118]

Macros cross-compiled by SwiftPM with Swift SDKs are now correctly built, loaded, and evaluated for the host triple.

Swift 5.10
-----------

* [#7010]

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.

* [7101]
* [#7101]

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

Expand Down Expand Up @@ -387,4 +398,8 @@ Swift 3.0
[#6276]: https://github.com/apple/swift-package-manager/pull/6276
[#6540]: https://github.com/apple/swift-package-manager/pull/6540
[#6663]: https://github.com/apple/swift-package-manager/pull/6663
[#7010]: https://github.com/apple/swift-package-manager/pull/7010
[#7101]: https://github.com/apple/swift-package-manager/pull/7101
[#7118]: https://github.com/apple/swift-package-manager/pull/7118
[#7201]: https://github.com/apple/swift-package-manager/pull/7201
[#7202]: https://github.com/apple/swift-package-manager/pull/7202
11 changes: 10 additions & 1 deletion Sources/Basics/Collections/IdentifiableSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ public struct IdentifiableSet<Element: Identifiable>: Collection {
}

public subscript(id: Element.ID) -> Element? {
self.storage[id]
get {
self.storage[id]
}
set {
self.storage[id] = newValue
}
}

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

public mutating func insert(_ element: Element) {
self.storage[element.id] = element
}

public func union(_ otherSequence: some Sequence<Element>) -> Self {
var result = self
for element in otherSequence {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import struct SPMBuildCore.BuildParameters
import struct SPMBuildCore.BuildToolPluginInvocationResult
import struct SPMBuildCore.PrebuildCommandResult

@_spi(SwiftPMInternal)
import SPMBuildCore

import enum TSCBasic.ProcessEnv

/// Target description for a Clang target i.e. C language family target.
Expand Down Expand Up @@ -49,7 +52,7 @@ public final class ClangTargetBuildDescription {

/// Path to the bundle generated for this module (if any).
var bundlePath: AbsolutePath? {
guard !resources.isEmpty else {
guard !self.resources.isEmpty else {
return .none
}

Expand Down Expand Up @@ -127,7 +130,7 @@ public final class ClangTargetBuildDescription {
self.target = target
self.toolsVersion = toolsVersion
self.buildParameters = buildParameters
self.tempsPath = buildParameters.buildPath.appending(component: target.c99name + ".build")
self.tempsPath = target.tempsPath(buildParameters)
self.derivedSources = Sources(paths: [], root: tempsPath.appending("DerivedSources"))

// We did not use to apply package plugins to C-family targets in prior tools-versions, this preserves the behavior.
Expand Down Expand Up @@ -219,7 +222,7 @@ public final class ClangTargetBuildDescription {
if self.buildParameters.triple.isDarwin() {
args += ["-fobjc-arc"]
}
args += try buildParameters.targetTripleArgs(for: target)
args += try self.buildParameters.tripleArgs(for: target)

args += optimizationArguments
args += activeCompilationConditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
// setting is the package-level right now. We might need to figure out a better
// answer for libraries if/when we support specifying deployment target at the
// target-level.
args += try self.buildParameters.targetTripleArgs(for: self.product.targets[self.product.targets.startIndex])
args += try self.buildParameters.tripleArgs(for: self.product.targets[self.product.targets.startIndex])

// Add arguments from declared build settings.
args += self.buildSettingsFlags
Expand Down Expand Up @@ -346,7 +346,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
// Library search path for the toolchain's copy of SwiftSyntax.
#if BUILD_MACROS_AS_DYLIBS
if product.type == .macro {
args += try ["-L", buildParameters.toolchain.hostLibDir.pathString]
args += try ["-L", defaultBuildParameters.toolchain.hostLibDir.pathString]
}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2015-2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import struct Basics.AbsolutePath
import struct PackageGraph.ResolvedTarget

@_spi(SwiftPMInternal)
import SPMBuildCore

extension ResolvedTarget {
func tempsPath(_ buildParameters: BuildParameters) -> AbsolutePath {
buildParameters.buildPath.appending(component: self.c99name + "\(self.buildTriple.suffix).build")
}
}
Loading