Skip to content
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

Hash function change in swift #120

Open
bkolb opened this issue Feb 5, 2025 · 2 comments
Open

Hash function change in swift #120

bkolb opened this issue Feb 5, 2025 · 2 comments

Comments

@bkolb
Copy link

bkolb commented Feb 5, 2025

New versions of swift seem to use a different hashing strategy. It is incompatible with

llvm::hash_code pathHashVal = llvm::hash_value(absPath);

Here is the change: swiftlang/swift#77116

@bkolb
Copy link
Author

bkolb commented Feb 5, 2025

The relevant change seems to be
https://github.com/swiftlang/llvm-project/pull/9140/files#diff-dcdee0465a74e090b01bd5bd0d214f65f430f25a56b837ab627966318de1ff27R289

-  llvm::hash_code PathHashVal = llvm::hash_value(RemappedPath);
-  llvm::APInt(64, PathHashVal).toString(Str, 36, /*Signed=*/false);
+  auto PathHashVal = llvm::xxh3_64bits(RemappedPath);
+  llvm::APInt(64, PathHashVal).toStringUnsigned(Str, /*Radix*/ 36);

@bkolb
Copy link
Author

bkolb commented Feb 6, 2025

I am not the expert on this, but maybe it would be better to use this somehow instead:
https://github.com/swiftlang/indexstore-db/blob/main/Sources/IndexStoreDB_Index/include/IndexStoreDB_Index/indexstore_functions.h

bkolb added a commit to bkolb/index-import that referenced this issue Feb 6, 2025
bkolb added a commit to bkolb/index-import that referenced this issue Feb 6, 2025
In a recent change, swift changed the way a hash is calculated.
https://github.com/swiftlang/llvm-project/pull/9140/files#diff-dcdee0465a74e090b01bd5bd0d214f65f430f25a56b837ab627966318de1ff27R289

This change replicates this change.

Issue: MobileNativeFoundation#120
Signed-off-by: Bernd Kolb <[email protected]>
bkolb added a commit to bkolb/index-import that referenced this issue Feb 6, 2025
In a recent change, swift changed the way a hash is calculated.
https://github.com/swiftlang/llvm-project/pull/9140/files#diff-dcdee0465a74e090b01bd5bd0d214f65f430f25a56b837ab627966318de1ff27R289

This change replicates this change.

Issue: MobileNativeFoundation#120
Signed-off-by: Bernd Kolb <[email protected]>
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

No branches or pull requests

1 participant