Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-123748: Add conditional compilation rules to allow HACL SIMD256 to be compiled on universal#123989

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
freakboy3742 merged 3 commits intopython:mainfromfreakboy3742:universal-hacl
Sep 16, 2024

Conversation

freakboy3742
Copy link
Contributor

@freakboy3742freakboy3742 commentedSep 12, 2024
edited by bedevere-appbot
Loading

Add modifications to the compilation of hashlib to restore the ability to generate a universal build.

#119316 added an implementation of Blake2 to hashlib. That implementation compiles fine on single architecture macOS builds (both x86_64 and ARM64, as verified by CI); but universal2 builds generate a compilation error because the SIMD256 algorithmcan be compiled on x86_64, butcan't be compiled on ARM64. Since both architectures are compiled in a single pass, autoconf by itself can't detect or control how to include (or exclude) the SIMD256 module.

This PR:

  • Adds aHacl_Hash_Blake2b_Simd256_universal2.c file that conditionally#includes Hacl_Hash_Blake2b_Simd256.c`. This keeps the Python additions isolated, allowing the original HACL sources to be used (and updated) as-is.
  • Adds Makefile and configure changes to include the_universal2 wrapper variant if compiling on universal, along with configure logging to identify when this occurs
  • Adds a conditional block to the start ofblake2module.c that disables theHACL_CAN_COMPILE_SIMD256 symbol if on ARM64. On a pure ARM64 compile, this will never be executed; but in a universal build, it will.

Fixes#123748.

/cc@msprotz

Copy link
Contributor

@sethmlarsonsethmlarson left a comment

Choose a reason for hiding this comment

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

SBOM changes LGTM.

@msprotz
Copy link
Contributor

The logic looks good to me, but I wonder if this ends up enabling Blake2s/128 on ARM64? Right now it's not enabled (due to a slow barrel-shifter, I think, which gives so-so performance) by default, but might end up being enabled unintentionally for universal builds.

Also, I don't know if this is specific to this work, but I tried out./configure --with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2 but then when I tried to make sure built-in hashes were linked properly, I got this:

>>> import hashlib>>> hashlib.sha256<built-in function openssl_sha256>

(not sure this is related to the problem of universal builds, or if this is a more general issue with configure)

@freakboy3742
Copy link
ContributorAuthor

The logic looks good to me, but I wonder if this ends up enabling Blake2s/128 on ARM64? Right now it's not enabled (due to a slow barrel-shifter, I think, which gives so-so performance) by default, but might end up being enabled unintentionally for universal builds.

It will - unlike SIMD256.c, SIMD128.ccan be compiled on ARM64. However, given the existing configuration, it wouldn't be included in an ARM64-only build. I'll push an update to do a similar "#include and #undef" trick for the SIMD128 implementation so that we retain parity with single-architecture builds.

Also, I don't know if this is specific to this work, but I tried out./configure --with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2 but then when I tried to make sure built-in hashes were linked properly, I got this:

>>> import hashlib>>> hashlib.sha256<built-in function openssl_sha256>

(not sure this is related to the problem of universal builds, or if this is a more general issue with configure)

This is the same behavior I see in the official universal build of Python 3.13.0rc2 running on macOS. The same is true of other older Pythons that I've tested back to 3.8, so it doesn't appear to be specific to this patch.

Copy link
Member

@ned-deilyned-deily left a comment

Choose a reason for hiding this comment

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

I verified that universal2 and single-arch builds now compile without error. Thanks for tracking this down and following up.

gpshead reacted with heart emoji
@freakboy3742
Copy link
ContributorAuthor

@msprotz Are you happy with the current state of this patch?

Copy link
Member

@gpsheadgpshead left a comment

Choose a reason for hiding this comment

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

This makes sense to me, thanks for untangling this one!

Copy link
Contributor

@msprotzmsprotz left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for figuring out this tricky build issue -- much appreciated!

@freakboy3742freakboy3742 merged commitef530ce intopython:mainSep 16, 2024
39 checks passed
@freakboy3742freakboy3742 deleted the universal-hacl branchSeptember 16, 2024 04:23
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this pull requestSep 22, 2024
…nd SIMD128 on macOS (python#123989)Add conditional compilation rules to allow HACL SIMD256 and SIMD128 to be ignored on the ARM64 pass of universal2 macOS builds.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadgpshead approved these changes

@ned-deilyned-deilyned-deily approved these changes

@msprotzmsprotzmsprotz approved these changes

@sethmlarsonsethmlarsonsethmlarson approved these changes

@tirantiranAwaiting requested review from tirantiran is a code owner

@erlend-aaslanderlend-aaslandAwaiting requested review from erlend-aaslanderlend-aasland is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

Assignees
No one assigned
Labels
3.14bugs and security fixesbuildThe build process and cross-buildskip news
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Error compiling HACL* Blake2 support for macOS universal binaries
5 participants
@freakboy3742@msprotz@gpshead@ned-deily@sethmlarson

[8]ページ先頭

©2009-2025 Movatter.jp