Skip to content

Conversation

@dschaefer2
Copy link
Member

@dschaefer2 dschaefer2 commented Oct 17, 2025

There is an issue when a macro that uses prebuilts uses a library that also depends on the swift-syntax library. This is commonly used to share utility code between macros.

However, we currently can't tell whether the library will only be built for the host so it can not take advantage of the prebuilts. When a macro which is using prebuilts uses that library, we are seeing crashes in the macro caused when the library and the swift-syntax it uses is built for debug which is then linked with the macro which uses the swift-syntax prebuilts which are built for release.

For now, this change turns off the prebuilts for macros that use such a library to avoid the crash. We'll investigate making the use of prebuilts conditional on the build settings in a future release.

To be able to implement this change, we need to be able to detect the downstream swift-syntax dependency. We move the insertion of the settings for the prebuilts from Module creation time until after the ResolvedModuleBuilder is created so that we can make the changes there before the final ResolvedModules are created.

There is an issue when a macro that uses prebuilts uses a library
that also depends on the swift-syntax library. This is commonly
used to share utility code between macros.

However, we currently can't tell whether the library will only be
built for the host so it can not take advantage of the prebuilts.
When a macro which is using prebuilts uses that library, we are
seeing crashes in the macro caused when the library and the
swift-syntax it uses is built for debug which is then linked with
the macro which uses the swift-syntas prebuilts which are built
for release.

For now, this change turns off the prebuilts for macros that use
such a library to avoid the crash. We'll investigate making the
use of prebuilts conditional on the build settings in a future
release.

To be able to implement this change, we need to be able to detect
the downstream swift-syntax dependency. We move the insertion of
the settings for the prebuilts from Module creation time until
after the ResolvedModuleBuilder is created so that we can make
the changes there before the final ResolvedModules are created.
@dschaefer2 dschaefer2 requested a review from a team as a code owner October 17, 2025 20:44
@dschaefer2 dschaefer2 changed the title Fix crash in macros caused by mixing prebuilts and source. [6.2]Fix crash in macros caused by mixing prebuilts and source. Oct 17, 2025
@dschaefer2
Copy link
Member Author

Addressing #9196

@dschaefer2
Copy link
Member Author

@swift-ci please test

@dschaefer2
Copy link
Member Author

@swift-ci please test windows

@dschaefer2 dschaefer2 merged commit 742e5c2 into swiftlang:release/6.2 Oct 20, 2025
6 checks passed
@dschaefer2 dschaefer2 deleted the fixMacroCrash branch October 20, 2025 20:34
dschaefer2 added a commit to dschaefer2/swift-package-manager that referenced this pull request Oct 20, 2025
…#9261)

There is an issue when a macro that uses prebuilts uses a library that
also depends on the swift-syntax library. This is commonly used to share
utility code between macros.

However, we currently can't tell whether the library will only be built
for the host so it can not take advantage of the prebuilts. When a macro
which is using prebuilts uses that library, we are seeing crashes in the
macro caused when the library and the swift-syntax it uses is built for
debug which is then linked with the macro which uses the swift-syntax
prebuilts which are built for release.

For now, this change turns off the prebuilts for macros that use such a
library to avoid the crash. We'll investigate making the use of
prebuilts conditional on the build settings in a future release.

To be able to implement this change, we need to be able to detect the
downstream swift-syntax dependency. We move the insertion of the
settings for the prebuilts from Module creation time until after the
ResolvedModuleBuilder is created so that we can make the changes there
before the final ResolvedModules are created.
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