Skip to content

Promote -swift-module-file= to a driver flag - #2104

Merged
artemcm merged 1 commit into
swiftlang:mainfrom
artemcm:SwiftModuleFileDriverFlag
Oct 20, 2026
Merged

artemcm merged 1 commit into
swiftlang:mainfrom
artemcm:SwiftModuleFileDriverFlag

Conversation

@artemcm

@artemcm artemcm commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Companion change to:
swiftlang/swift#87823

@artemcm

artemcm commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@cachemeifyoucan cachemeifyoucan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this needs to be a lot more complicated for explicit module build.

For explicit module build, the flag should be only passed to scanner, and the scanner will plan the build and return the dependency graph with the module file passed as part of it. That is the only way for caching build to be supported.

I don't know if this matters for implicit build, but implicit build can just pass the flag to frontend.

@artemcm
artemcm force-pushed the SwiftModuleFileDriverFlag branch from 1800a62 to 4ca5b2c Compare March 12, 2026 17:34
@artemcm

artemcm commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

For explicit module build, the flag should be only passed to scanner, and the scanner will plan the build and return the dependency graph with the module file passed as part of it. That is the only way for caching build to be supported.

I don't know if this matters for implicit build, but implicit build can just pass the flag to frontend.

Good catch. Done.

@cachemeifyoucan cachemeifyoucan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a test for explicit module build?


// For explicitly-built modules, only forward -swift-module-file= to the scanning action,
// for implicitly-built modules, forward it to all compilation tasks.
if (isPlanJobForExplicitModule && kind == .scanDependencies) || !isPlanJobForExplicitModule {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is isPlanJobForExplicitModule always true when kind == .scanDependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I expect it to be, yes.

@artemcm

artemcm commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Can we add a test for explicit module build?

There already is a test for explicit module build. What do you have in mind that's not covered there?

@cachemeifyoucan

Copy link
Copy Markdown
Contributor

There already is a test for explicit module build. What do you have in mind that's not covered there?

I want to see scanner returns the correct result when you pass -swift-module-file to it.

@artemcm
artemcm force-pushed the SwiftModuleFileDriverFlag branch 2 times, most recently from e22e746 to 729a29d Compare October 19, 2026 10:03
@artemcm

artemcm commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

There already is a test for explicit module build. What do you have in mind that's not covered there?

I want to see scanner returns the correct result when you pass -swift-module-file to it.

Done. @cachemeifyoucan could you please take another look?

.experimentalClangImporterDirectCc1Scan, from: &parsedOptions)
}

// For explicitly-built modules, only forward -swift-module-file= to the scanning action,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the test need to check this, not just explicit module build succeeded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, thanks.

@artemcm
artemcm force-pushed the SwiftModuleFileDriverFlag branch from 729a29d to f61789e Compare October 20, 2026 16:56
@artemcm

artemcm commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm
artemcm enabled auto-merge (rebase) October 20, 2026 17:41
@artemcm
artemcm merged commit 72676f2 into swiftlang:main Oct 20, 2026
27 checks passed
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.

2 participants