Skip to content

Prevent unnecessary rebuilds when modifying swiftc arguments #8803

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 2 commits into
base: main
Choose a base branch
from

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Jun 11, 2025

Many arguments for the compiler are marked as doesNotAffectIncrementalBuild in swift-driver. Use the argument hashing in swift-driver to hash the swift compiler flags and incorporate that in to the build hash signature used to determine if SwiftPM should do a full rebuild.

This prevents unnecssary rebuilds when adding or changing arguments like -Xswiftc -diagnostic-style=llvm. For a list of arguments that no longer affect rebuilds, search for doesNotAffectIncrementalBuild in https://github.com/swiftlang/swift-driver/blob/main/Sources/SwiftOptions/Options.swift.

This builds on the work introduced in #8717 which avoided unnecessary rebuilds when SwiftPM arguments changed.

Many arguments for the compiler are marked as
`doesNotAffectIncrementalBuild` in `swift-driver`. Use the argument
hashing in swift-driver to hash the swift compiler flags and incorporate
that in to the build hash signature used to determine if SwiftPM should
do a full rebuild.

This prevents unnecssary rebuilds when adding or changing arguments like
`-Xswiftc -diagnostic-style=llvm`. For a list of arguments that no
longer affect rebuilds, search for `doesNotAffectIncrementalBuild` in
https://github.com/swiftlang/swift-driver/blob/main/Sources/SwiftOptions/Options.swift.

This builds on the work introduced in swiftlang#8717 which avoided unnecessary
rebuilds when SwiftPM arguments changed.
@MahdiBM
Copy link

MahdiBM commented Jun 12, 2025

@plemarquand This is huge in certain situations. Does this also cover env vars, or only command line arguments?

@plemarquand
Copy link
Contributor Author

@MahdiBM This patch just covers -Xswiftc arguments. I dont think we can do something similar with env vars since we can't know what downstream tools (LLVM, swiftc, etc...) are going to use today or in future.

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

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

LGTM, but it would be nice to have a test for this if we can

@plemarquand
Copy link
Contributor Author

@owenv I agree. I'm going to wait for #8714 to land to avoid merge conflicts.

@plemarquand
Copy link
Contributor Author

@swift-ci please test

@dschaefer2
Copy link
Member

Great find. Thanks @plemarquand !

@plemarquand
Copy link
Contributor Author

@swift-ci test windows

@plemarquand
Copy link
Contributor Author

@swift-ci test macOS

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.

5 participants