Skip to content

Sema: Warn on all non-resilient uses of @_implementationOnly import, even for clang targets #76267

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

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Sep 4, 2024

The warning about using '@_implementationOnly' without enabling library evolution for 'client' may lead to instability during execution was wrongly restricted to only imports of Swift modules. Make sure they are raised for imports of clang modules as well.

rdar://135233043

@xymus
Copy link
Contributor Author

xymus commented Sep 4, 2024

@swift-ci Please smoke test

…r clang targets

The warnings about `using '@_implementationOnly' without enabling library evolution for 'client'
may lead to instability during execution` and `@_implementationOnly' is deprecated, use
'internal import' instead` were wrongly restricted to only Swift import targets.
Make sure they are raised for clang module targets as well.

rdar://135233043
…n to Swift targets

Preserve the warning to use `internal import` instead of `@_implementationOnly`
to imports of Swift modules only. This warning can be noisy, limiting it may
prevent users from outright learning to ignore it. Typical uses of an
`@_implementationOnly` import of a clang module is often for a project
internal module instead of a layering concern as we have with Swift module
targets. We can leave legacy uses of `@_implementationOnly` in peace for now.
@xymus xymus force-pushed the warn-on-ioi-clang-targets branch from 558f8d1 to 6c3c108 Compare September 5, 2024 17:42
@xymus
Copy link
Contributor Author

xymus commented Sep 5, 2024

@swift-ci Please smoke test

I reviewed the new logic to keep the warning to use internal import instead of @_implementationOnly to imports of Swift modules only. This warning can be noisy, limiting it may prevent users from outright learning to ignore it. Typical uses of an @_implementationOnly import of a clang module is often for a project internal module instead of a wider layering concern as we have with Swift module targets. We can leave legacy uses of @_implementationOnly in peace for now.

@tshortli
Copy link
Contributor

tshortli commented Sep 5, 2024

The potential miscompiles that can arise from @_implementationOnly are equally present whether it is a Swift or a clang module that is being imported, though. I thought we wanted this warning to help prevent more time wasted debugging that kind of issue, for both project owners and compiler engineers.

@xymus
Copy link
Contributor Author

xymus commented Sep 5, 2024

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Sep 5, 2024

@tshortli My last change only silenced the deprecation warning in resilient modules. That's generally reliable, the one miscompile there I'm aware of would be with test clients that can't load the dependency because of different search paths. It's rare but maybe it's worth the warning.

@tshortli
Copy link
Contributor

tshortli commented Sep 5, 2024

Oh, I misunderstood, thanks for clarifying. I have debugged miscompiles stemming from the combination of @_implementationOnly import and @testable imports of resilient libraries, but I agree it's way more niche and perhaps not worth the noise. I think eventually we should warn about it, though.

@xymus xymus merged commit d71bd2d into swiftlang:main Sep 6, 2024
3 checks passed
@xymus xymus deleted the warn-on-ioi-clang-targets branch September 6, 2024 03:01
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