Skip to content

Assert that only declared dependencies are used when compiling/linking #466

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

ldaley
Copy link

@ldaley ldaley commented Apr 30, 2025

This is the first increment towards supporting centralized declared dependencies.

This introduces a DEPENDENCIES build setting, that is a string list of “logical” dependency names (e.g. Foo for Foo.framework). When invoking a tool that supports trace information, the trace will be cross referenced with the declared dependencies and the action will fail if a file is used that does not “resolve” to a logical dependency declared in DEPENDENCIES. This process of analyzing trace data and asserting that only declared dependencies are used is referred to as “verification”.

This PR adds verification for linking, and non-modular clang compilation. Later changes will add support for other trace-producing tools.

The error reporting and diagnostic experience in this change is considered rudimentary/provisional, and will be improved in subsequent changes.

@@ -50,7 +50,7 @@ fileprivate extension CommandResult {
}

extension TaskAction {
func spawn(commandLine: [String], environment: [String: String], workingDirectory: String, dynamicExecutionDelegate: any DynamicTaskExecutionDelegate, clientDelegate: any TaskExecutionClientDelegate, processDelegate: any ProcessDelegate) async throws {
static func spawn(commandLine: [String], environment: [String: String], workingDirectory: String, dynamicExecutionDelegate: any DynamicTaskExecutionDelegate, clientDelegate: any TaskExecutionClientDelegate, processDelegate: any ProcessDelegate) async throws {
Copy link
Author

Choose a reason for hiding this comment

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

As it stands, I need to use this from the introduced TaskDependencyVerification.Adapter.exec() (volatile link), so made it static. This doesn't feel right.

A better home might be as an extension of the newly introduced TaskExecutionContext (volatile link). That's an even more invasive change though.

Any suggestions on how to clean this up welcome.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Moving to TaskExecutionContext seems fine; there's no particularly strong reason I put this here.

}

func findLibraryName() -> String? {
if fileExtension == "a" && basename.starts(with: "lib") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Libraries on Windows don't start with lib. This is also not technically required on Unix either, so we should think how to handle mapping of libraries that aren't necessarily using the lib prefix.

Copy link
Author

Choose a reason for hiding this comment

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

I've more deeply encapsulated this and added clarifying documentation that it does not attempt to be a viable implementation for general use.

The intention is not to do more with this at this time in this change set, but evolve later.

How do you suggest we resolve the partial status of this for this PR?

@ldaley ldaley force-pushed the ldaley/dependency-verification branch from 570e1c2 to 7699bd5 Compare May 2, 2025 21:38
@ldaley
Copy link
Author

ldaley commented May 2, 2025

@swift-ci test

@ldaley
Copy link
Author

ldaley commented May 3, 2025

@mirza-garibovic @jakepetroules this is ready for another review pass. I don't expect that it is mergeable, but there is nothing that I intend to add change other than addressing feedback-to-come.

@ldaley ldaley changed the title [WIP] Assert that only declared dependencies are used when compiling/linking Assert that only declared dependencies are used when compiling/linking May 3, 2025
@ldaley ldaley marked this pull request as ready for review May 5, 2025 15:44
@ldaley ldaley force-pushed the ldaley/dependency-verification branch from 0cd961d to 73e0bd7 Compare May 5, 2025 17:30
@ldaley
Copy link
Author

ldaley commented May 5, 2025

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants