Skip to content

[Dependency Scanning] Scan header inputs of binary Swift module dependencies #72067

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

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Mar 4, 2024

Otherwise they may have module dependencies of their own which will not be detected by the scanner and included in the list of explicit inputs for compilation.

These header inputs typically occur on binary Swift modules which were built with a bridging header.

@artemcm artemcm force-pushed the FixTransitiveHeaderLookupInDependencyScan branch 2 times, most recently from f033fae to afb81a0 Compare March 4, 2024 22:48
@artemcm artemcm requested a review from nkcsgexi March 4, 2024 22:48
@artemcm
Copy link
Contributor Author

artemcm commented Mar 4, 2024

@swift-ci test

@cachemeifyoucan
Copy link
Contributor

Should we check both PCH and no-PCH build? I guess when you import binary module, the binary module itself will know it needs to import PCH or headers directly and all we care in the scanner is to figure out the module dependencies?

@artemcm
Copy link
Contributor Author

artemcm commented Mar 4, 2024

Should we check both PCH and no-PCH build? I guess when you import binary module, the binary module itself will know it needs to import PCH or headers directly and all we care in the scanner is to figure out the module dependencies?

The binary module we import, when built with PCH or non-PCH, will still just serialize the path to the .h file, so to the client it will not make a difference.

@cachemeifyoucan
Copy link
Contributor

The binary module we import, when built with PCH or non-PCH, will still just serialize the path to the .h file, so to the client it will not make a difference.

So those also needs be absolute path that exists on the file system of the client? As I don't expect client to setup search path to find the header. And the client will do an implicit PCH build before importing into clang importer?

@artemcm
Copy link
Contributor Author

artemcm commented Mar 4, 2024

The binary module we import, when built with PCH or non-PCH, will still just serialize the path to the .h file, so to the client it will not make a difference.

So those also needs be absolute path that exists on the file system of the client? As I don't expect client to setup search path to find the header.

We also serialize the contents of the .h into the .swiftmodule, so the absolute path is not necessary in that case, I believe.

And the client will do an implicit PCH build before importing into clang importer?

Yes, that's accurate. The clients are not able to load the PCH directly, if one was previously built, because its build context is not guaranteed to match.

@cachemeifyoucan
Copy link
Contributor

cachemeifyoucan commented Mar 4, 2024

Yes, that's accurate. The clients are not able to load the PCH directly, if one was previously built, because its build context is not guaranteed to match.

I see. Now I feel stronger about making bridging header dependencies a separate entry in the future so we can teach build system to schedule explicit PCH builds for source module and binary module.

@artemcm artemcm force-pushed the FixTransitiveHeaderLookupInDependencyScan branch from afb81a0 to e0402a9 Compare March 5, 2024 16:41
@artemcm
Copy link
Contributor Author

artemcm commented Mar 5, 2024

@swift-ci test

@artemcm artemcm force-pushed the FixTransitiveHeaderLookupInDependencyScan branch from e0402a9 to 49bca81 Compare March 5, 2024 17:53
@artemcm
Copy link
Contributor Author

artemcm commented Mar 5, 2024

@swift-ci test

Copy link
Contributor

@cachemeifyoucan cachemeifyoucan left a comment

Choose a reason for hiding this comment

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

LGTM in general with some comments.

…dencies

Otherwise they may have module dependencies of their own which will not be detected by the scanner and included in the list of explicit inputs for compilation.
@artemcm artemcm force-pushed the FixTransitiveHeaderLookupInDependencyScan branch from 49bca81 to bfa8c0e Compare March 6, 2024 19:02
@artemcm
Copy link
Contributor Author

artemcm commented Mar 6, 2024

@swift-ci test

@artemcm artemcm enabled auto-merge March 6, 2024 19:03
Copy link
Contributor

@cachemeifyoucan cachemeifyoucan left a comment

Choose a reason for hiding this comment

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

SGTM

@artemcm artemcm merged commit d113ea1 into swiftlang:main Mar 7, 2024
4 of 5 checks passed
@artemcm artemcm deleted the FixTransitiveHeaderLookupInDependencyScan branch March 7, 2024 17:25
artemcm added a commit to artemcm/swift-driver that referenced this pull request Jul 8, 2024
…er inputs of binary module dependencies

As of swiftlang/swift#72067, we instead serialize `.h` inputs directly into binary `.swiftmodule` files, because their clients may not be able to use the dependnecies' corresponding `.pch` files due to a compilation context mismatch. The clients of such binary modules then consume the serialized `.h` files directly, and compile them, implicitly, using explicit module dependencies collected during scan of such header files.

Resolves rdar://131261765
artemcm added a commit to artemcm/swift-driver that referenced this pull request Jul 8, 2024
…er inputs of binary module dependencies

As of swiftlang/swift#72067, we instead serialize `.h` inputs directly into binary `.swiftmodule` files, because their clients may not be able to use the dependnecies' corresponding `.pch` files due to a compilation context mismatch. The clients of such binary modules then consume the serialized `.h` files directly, and compile them, implicitly, using explicit module dependencies collected during scan of such header files.

Resolves rdar://131261765
artemcm added a commit to swiftlang/swift-driver that referenced this pull request Jul 8, 2024
…er inputs of binary module dependencies

As of swiftlang/swift#72067, we instead serialize `.h` inputs directly into binary `.swiftmodule` files, because their clients may not be able to use the dependnecies' corresponding `.pch` files due to a compilation context mismatch. The clients of such binary modules then consume the serialized `.h` files directly, and compile them, implicitly, using explicit module dependencies collected during scan of such header files.

Resolves rdar://131261765
artemcm added a commit to swiftlang/swift-driver that referenced this pull request Jul 8, 2024
…er inputs of binary module dependencies

As of swiftlang/swift#72067, we instead serialize `.h` inputs directly into binary `.swiftmodule` files, because their clients may not be able to use the dependnecies' corresponding `.pch` files due to a compilation context mismatch. The clients of such binary modules then consume the serialized `.h` files directly, and compile them, implicitly, using explicit module dependencies collected during scan of such header files.

Resolves rdar://131261765
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