Skip to content

[Dependency Scanning] Miscellaneous fixes to import statement info serialization #80723

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 1 commit into from
Apr 14, 2025

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 10, 2025

  • Deserialization of binary module dependencies was still relying on stale code (e.g. currentModuleImports, currentOptionalModuleImports) from serialized import strings, instead of the now in-use import infos.
  • Imports without a source location (e.g. implicit imports of stdlib) were not getting serialized at all
  • Optional import arrays were not being written out at all

@artemcm
Copy link
Contributor Author

artemcm commented Apr 10, 2025

@swift-ci smoke 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.

Can you have a better commit message to explain the fixes? I still have trouble to understand what exact issue is being fixed here.

//
// RUN: grep "IMPORT_STATEMENT_NODE" %t/cache.moddepcache.initial.dump.txt | wc -l > %t/initial_scan_import_count.txt
// RUN: grep "IMPORT_STATEMENT_NODE" %t/cache.moddepcache.dump.txt | wc -l > %t/secondary_scan_import_count.txt
// RUN: diff %t/initial_scan_import_count.txt %t/secondary_scan_import_count.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

Does output change order somehow? Should we just diff all the import line, rather than the count?

If we only care about count, I assume it is a known number that doesn't change? Maybe use CHECK-COUNT-{NUM} instead of diffing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does output change order somehow? Should we just diff all the import line, rather than the count?

While I don't think the order should change, we haven't actually intentionally ensured that all the various string identifiers will have identical order and values. If we intend to have that, then that's something to pursue. But in the meantime I want to have the test be a bit simpler and at least ensure that we have preserved the same count of imports.

I assume it is a known number that doesn't change?

There is a lot of precedent of Swift adding implicit imports throughout the years and I really didn't want to hard-code this into the test so that it would have to be updated in the future.

…rialization

- Deserialization of binary module dependencies was still relying on stale code (e.g. 'currentModuleImports', 'currentOptionalModuleImports') from serialized import strings, instead of the now in-use import infos.
- Imports without a source location (e.g. implicit imports of stdlib) were not getting serialized at all
- Optional import arrays were not being written out at all
@artemcm artemcm force-pushed the FixDepScanImportSerialization branch from dbaf99c to e2f50b5 Compare April 10, 2025 17:26
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 for the problem fixed. I do prefer the cache to be deterministic though.

@artemcm
Copy link
Contributor Author

artemcm commented Apr 10, 2025

@swift-ci smoke test

@artemcm artemcm merged commit 9efe489 into swiftlang:main Apr 14, 2025
3 checks passed
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