Skip to content

CMake: Stop touching swiftmodule files on build - #91795

Open
etcwilde wants to merge 4 commits into
swiftlang:mainfrom
etcwilde:dont-touch-my-moustache
Open

etcwilde wants to merge 4 commits into
swiftlang:mainfrom
etcwilde:dont-touch-my-moustache

Conversation

@etcwilde

Copy link
Copy Markdown
Member

Swift-Syntax bumped minimum required CMake versions to 3.29. For whatever reason, that caused the code introduced in #70859 to start working as designed and invalidate the build graph on every run. That was to work around a bug in versions of CMake prior to 3.26, but has since been fixed. The compiler depends on Swift-Syntax, which requires 3.29, so also bumping the compiler while we're at it to take advantage of the improved Swift handling. Since we're jumping to something newer that has the bug fixed, we can drop the code that forces a full rebuild of the universe.

With this change, I am able to get to a null-build:

 %  ninja swift-frontend -d explain
ninja: no work to do.

I will note that this isn't perfect and that more invasive changes are needed to fully clean things up, this is to alleviate the constant forced rebuild.

I've also taken the opportunity to remove some of the redundant policy settings.

Bumping minimum required to CMake 3.29.

This means that CMP0067,  CMP0076, and CMP0077 will all be
automatically set to the new behavior. This also means that CMP0068 is
guaranteed to be a recognized policy so we don't need to guard it. If
the policy stops existing in the future, we want the configuration to
fail.
`add_pure_swift_host_library` touched things, which caused rebuilds. By
requiring CMake 3.29, we can drop the touching and rebuilding.
@etcwilde
etcwilde requested review from compnerd and rintaro August 27, 2026 21:38
@etcwilde

Copy link
Copy Markdown
Member Author

@swift-ci please test

@compnerd compnerd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be nice to adopt the new RPATH policy as well.

@etcwilde

Copy link
Copy Markdown
Member Author

@swift-ci please test

Newer versions of CMake try to pass the target name as the module if one
is not set explicitly. The target name contains hyphens, which is not
valid. Set it explicitly to avoid the hyphens.
@etcwilde
etcwilde force-pushed the dont-touch-my-moustache branch from bf047b2 to dab4ad7 Compare August 28, 2026 02:31
@etcwilde

Copy link
Copy Markdown
Member Author

@swift-ci please test

@etcwilde

Copy link
Copy Markdown
Member Author

@swift-ci please test Linux Platform

@compnerd

Copy link
Copy Markdown
Member

@swift-ci please test Linux platform

The newer behavior in CMake does a better job isolating modules from
users that don't declare their dependencies correctly. As a result,
several libraries failed to build because they couldn't find the
appropriate Swift module files from Swift Syntax.

Adding the missing dependency edges.
@etcwilde

etcwilde commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

swiftlang/swift-syntax#3423
@swift-ci please test

@etcwilde

Copy link
Copy Markdown
Member Author

swiftlang/swift-syntax#3423
@swift-ci please 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