Skip to content

Conversation

DougGregor
Copy link
Member

The bridging header is effectively imported as a "public" import. This new option makes it an "internal" import, so that entities accessible via the bridging header cannot be part of public API.

Driver part of rdar://74011750.

@DougGregor
Copy link
Member Author

swiftlang/swift#84410

@swift-ci please test

self.importBridgingHeaderAsInternal = importBridgingHeaderOption.option == .internalImportBridgingHeader
} else {
self.originalObjCHeaderFile = nil
self.importBridgingHeaderAsInternal = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not quite correct. I think it maybe need to be internal if library evolution is enabled.

The special case that falls here is that the current module doesn't have a bridging header but there is dependency swift binary module that has bridging header, thus scanner can create a chained bridging for current module. In this case, there isn't a bridging header import flag that indicates if current module does internal import or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I understand how to construct this special case. In the place where the driver used to always generate -import-pch for the chained header, it now checks whether the bridging header is internal and will pass the new -internal-import-pch instead (which treats the PCH as internal-only). Is that not sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

A swift testcase for this is: https://github.com/swiftlang/swift/blob/main/test/ScanDependencies/bridging-header-autochaining.swift#L51-L55

Requirement is:

  • Module has no bridging header
  • Binary module dependency has bridging header
  • Enable auto chaining.

In this case, driver invocation will not have -*import-bridging-header, swift-driver needs to figure out which -import-pch flag flavor to pass the PCH flag to swift-frontend.

Copy link
Member Author

Choose a reason for hiding this comment

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

When the binary module dependency has an internal bridging header (the new thing), it's not recorded that it has a bridging header at all, so there is no chaining. No?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my example, internal bridging header is not using internal bridging header, but the legacy bridging header.

@DougGregor
Copy link
Member Author

@swift-ci please test Windows

@DougGregor DougGregor merged commit 3093b07 into swiftlang:main Sep 23, 2025
3 checks passed
@DougGregor DougGregor deleted the internal-import-bridging-header branch September 23, 2025 06:09
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.

4 participants