Skip to content

Support for prebuilt packages in the SDK #7337

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 5 commits into from
Feb 16, 2024
Merged

Support for prebuilt packages in the SDK #7337

merged 5 commits into from
Feb 16, 2024

Conversation

neonichu
Copy link
Contributor

This should allow satisfying a package dependency with a package in the SDK (or toolchain) based on metadata. If the given prebuilt library is version-compatible, we essentially elide the dependency from the graph. If it is not, we will fetch and build the dependency as normal. If a library with associated metadata is linked without a corresponding package dependency, we'll emit a warning.

@neonichu neonichu self-assigned this Feb 13, 2024
@neonichu
Copy link
Contributor Author

@swift-ci please test

}

// FIXME: We need a real makefile deps parser here...
let deps = contents.description.split(whereSeparator: { $0.isWhitespace })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we need to solve, but I'll unlikely be able to do it for this PR. One path forward could be exposing llbuild's parser via the Swift API.

import class TSCUtility.PercentProgressAnimation
import protocol TSCUtility.ProgressAnimationProtocol
import var TSCUtility.verbosity
import TSCUtility // cannot be scoped because of `String.spm_mangleToC99ExtendedIdentifier()`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way? @MaxDesiatov maybe you have suggestions?

@neonichu
Copy link
Contributor Author

CMake config needs to be updated as well

This should allow satisfying a package dependency with a package in the SDK (or toolchain) based on metadata. If the given prebuilt library is version-compatible, we essentially elide the dependency from the graph. If it is not, we will fetch and build the dependency as normal. If a library with associated metadata is linked without a corresponding package dependency, we'll emit a warning.
@neonichu
Copy link
Contributor Author

@swift-ci please test

@neonichu
Copy link
Contributor Author

@swift-ci please test windows

@neonichu
Copy link
Contributor Author

I don't think I will address installing the config as part of this PR which will also conveniently work as a feature flag because no config == no metadata which leads to skipping most of the new logic.

@neonichu neonichu marked this pull request as ready for review February 15, 2024 07:31
@neonichu
Copy link
Contributor Author

@swift-ci please test

@neonichu
Copy link
Contributor Author

@swift-ci please test windows

@neonichu
Copy link
Contributor Author

I think this is in a reasonable state to land since it does achieve all basic functionality goals:

  • elide matching package dependencies based on metadata
  • if the provided version is incompatible, falls back to source
  • produce a warning if there's matching metadata but no declared package dependency

Tests are still passing and the new functionality is disabled in production until we actually install a metadata file into the toolchain. During development, we pick up the metadata file from the build directory.

@neonichu
Copy link
Contributor Author

It should be possible to add some tests for the resolution functionality, probably should have one where we use the metadata and one where we fallback to the source package. Not as clear whether we can test the warning behavior since that is implemented in the build system which isn't as amenable to testing with mock data.

@@ -32,6 +32,7 @@ extension PackageGraph {
customPlatformsRegistry: PlatformRegistry? = .none,
customXCTestMinimumDeploymentTargets: [PackageModel.Platform: PlatformVersion]? = .none,
testEntryPointPath: AbsolutePath? = nil,
availableLibraries: [LibraryMetadata],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a default empty array argument here so that clients outside of this package relying on this function don't break? This would also fix the smoke test CI jobs, as SourceKit-LSP can't be built with this PR as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's correct that this is a breaking change?

I would see it similar to the binaryArtifacts parameter which also doesn't offer a default value. Whatever gets passed in has to match what was provided to the underlying workspace, so it's important that clients make a deliberate choice here.

I think in the fullness of time this probably shouldn't be a public API, though, or it should be refactored in a way that parameters that are associated with the workspace can't be arbitrarily passed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is the loadPackageGraph() on the workspace.

Yah it's a little unfortunate that it needs the parameter, but it's basically the consequence of the toolchain being private and that code being in an extension of workspace. I didn't really want to change the existing assumption that the toolchain object wouldn't be usable there.

@MaxDesiatov MaxDesiatov added the swift build Changes impacting `swift build` label Feb 15, 2024
@neonichu
Copy link
Contributor Author

swiftlang/sourcekit-lsp#1054
@swift-ci please test

@neonichu
Copy link
Contributor Author

swiftlang/sourcekit-lsp#1054
@swift-ci please test

@neonichu
Copy link
Contributor Author

swiftlang/sourcekit-lsp#1054
@swift-ci please test windows

1 similar comment
@neonichu
Copy link
Contributor Author

swiftlang/sourcekit-lsp#1054
@swift-ci please test windows

@neonichu neonichu merged commit cae580e into main Feb 16, 2024
@neonichu neonichu deleted the sdk-deps branch February 16, 2024 20:21
MaxDesiatov added a commit that referenced this pull request Feb 19, 2024
#7337 is breaking
toolchain builds, so we should pass `SKIP_RESOURCE_SUPPORT` by default
to avoid that.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
This should allow satisfying a package dependency with a package in the
SDK (or toolchain) based on metadata. If the given prebuilt library is
version-compatible, we essentially elide the dependency from the graph.
If it is not, we will fetch and build the dependency as normal. If a
library with associated metadata is linked without a corresponding
package dependency, we'll emit a warning.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
swiftlang#7337 is breaking
toolchain builds, so we should pass `SKIP_RESOURCE_SUPPORT` by default
to avoid that.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
This should allow satisfying a package dependency with a package in the
SDK (or toolchain) based on metadata. If the given prebuilt library is
version-compatible, we essentially elide the dependency from the graph.
If it is not, we will fetch and build the dependency as normal. If a
library with associated metadata is linked without a corresponding
package dependency, we'll emit a warning.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
swiftlang#7337 is breaking
toolchain builds, so we should pass `SKIP_RESOURCE_SUPPORT` by default
to avoid that.
xedin added a commit to xedin/swift-package-manager that referenced this pull request Jul 19, 2024
xedin added a commit to xedin/swift-package-manager that referenced this pull request Jul 19, 2024
xedin added a commit to xedin/swift-package-manager that referenced this pull request Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement modules graph Modules dependency resolution swift build Changes impacting `swift build`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants