Title: Error compiling HACL* Blake2 support for macOS universal binaries · Issue #123748 · python/cpython · GitHub
Open Graph Title: Error compiling HACL* Blake2 support for macOS universal binaries · Issue #123748 · python/cpython
X Title: Error compiling HACL* Blake2 support for macOS universal binaries · Issue #123748 · python/cpython
Description: Bug report Bug description: #99108 tracks the addition of a native HACL implementation to CPython. #119316 added an implementation of Blake2 to hashlib. This compiles fine on single architecture macOS builds (as verified by CI); but univ...
Open Graph Description: Bug report Bug description: #99108 tracks the addition of a native HACL implementation to CPython. #119316 added an implementation of Blake2 to hashlib. This compiles fine on single architecture ma...
X Description: Bug report Bug description: #99108 tracks the addition of a native HACL implementation to CPython. #119316 added an implementation of Blake2 to hashlib. This compiles fine on single architecture ma...
Opengraph URL: https://github.com/python/cpython/issues/123748
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error compiling HACL* Blake2 support for macOS universal binaries","articleBody":"# Bug report\n\n### Bug description:\n\n#99108 tracks the addition of a native HACL implementation to CPython. #119316 added an implementation of Blake2 to `hashlib`.\n\nThis compiles fine on single architecture macOS builds (as verified by CI); but universal2 builds running on an ARM64 laptop generate a compilation error:\n\nTo reproduce the problem: on a macOS machine, configure the build with:\n```\n$ configure --enable-universalsdk=\"`xcrun --show-sdk-path`\" --with-universal-archs=universal2\n$ make\n```\n\nThis will eventually yield the compilation error:\n```\ngcc -c -I../../../Modules/_hacl -I../../../Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fstack-protector-strong -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I../../../Include/internal -I../../../Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I../../../Include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mavx2 -DHACL_CAN_COMPILE_VEC256 -o Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o ../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c\nIn file included from ../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:26:\nIn file included from ../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:40:\n../../../Modules/_hacl/internal/../Hacl_Hash_Blake2b_Simd256.h:56:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *fst;\n ^\n../../../Modules/_hacl/internal/../Hacl_Hash_Blake2b_Simd256.h:57:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *snd;\n ^\nIn file included from ../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:26:\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:44:32: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\nHacl_Hash_Blake2b_Simd256_init(Lib_IntVector_Intrinsics_vec256 *hash, uint32_t kk, uint32_t nn);\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:49:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *wv,\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:50:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *hash,\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:59:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *wv,\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:60:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *hash,\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:71:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *hash\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:76:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *st,\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:83:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *st\n ^\n../../../Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h:86:1: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\nLib_IntVector_Intrinsics_vec256 *Hacl_Hash_Blake2b_Simd256_malloc_with_key(void);\n^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:34:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *wv,\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:35:3: error: unknown type name 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 *hash,\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:53:3: error: use of undeclared identifier 'Lib_IntVector_Intrinsics_vec256'\n Lib_IntVector_Intrinsics_vec256 mask = Lib_IntVector_Intrinsics_vec256_zero;\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:72:3: error: use of undeclared identifier 'mask'\n mask =\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:73:5: error: call to undeclared function 'Lib_IntVector_Intrinsics_vec256_load64s'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]\n Lib_IntVector_Intrinsics_vec256_load64s(FStar_UInt128_uint128_to_uint64(totlen),\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:77:33: error: use of undeclared identifier 'Lib_IntVector_Intrinsics_vec256'; did you mean 'Lib_IntVector_Intrinsics_vec256_load64s'?\n memcpy(wv, hash, 4U * sizeof (Lib_IntVector_Intrinsics_vec256));\n ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n Lib_IntVector_Intrinsics_vec256_load64s\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_string.h:63:33: note: expanded from macro 'memcpy'\n __builtin___memcpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:73:5: note: 'Lib_IntVector_Intrinsics_vec256_load64s' declared here\n Lib_IntVector_Intrinsics_vec256_load64s(FStar_UInt128_uint128_to_uint64(totlen),\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:78:3: error: use of undeclared identifier 'Lib_IntVector_Intrinsics_vec256'; did you mean 'Lib_IntVector_Intrinsics_vec256_load64s'?\n Lib_IntVector_Intrinsics_vec256 *wv3 = wv + 3U;\n ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n Lib_IntVector_Intrinsics_vec256_load64s\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:73:5: note: 'Lib_IntVector_Intrinsics_vec256_load64s' declared here\n Lib_IntVector_Intrinsics_vec256_load64s(FStar_UInt128_uint128_to_uint64(totlen),\n ^\n../../../Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c:78:36: error: use of undeclared identifier 'wv3'\n Lib_IntVector_Intrinsics_vec256 *wv3 = wv + 3U;\n ^\nfatal error: too many errors emitted, stopping now [-ferror-limit=]\n20 errors generated.\nmake: *** [Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o] Error 1\n```\n\nFrom what I can make out, the error comes from the detection of `-mavx2` support. On a bare configure on an ARM64 machine, `-mavx2` support is apparently unsupported:\n```\nconfigure:30537: checking whether C compiler accepts -mavx2\nconfigure:30557: gcc -c -Werror -mavx2 conftest.c \u003e\u00265\nclang: error: argument unused during compilation: '-mavx2' [-Werror,-Wunused-command-line-argument]\n```\nand as a result, the `Hacl_Hash_Blake2b_Simd256.c` module isn't compiled. However, when universal support is enabled, `-mavx2` *is* supported:\n```\nconfigure:30537: checking whether C compiler accepts -mavx2\nconfigure:30557: gcc -c -arch arm64 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Werror -mavx2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk conftest.c \u003e\u00265\nconfigure:30557: $? = 0\nconfigure:30566: result: yes\n```\nand the module is included. Based on recent configure logs for x86_64 macOS builds, it appears that `-mavx2` *is* supported on x86_64. \n\nI'm not sufficiently familiar with the subject matter to comment on whether the fix here is to fix the autoconf detection to *disable* the problematic module on universal builds, or to correct the implementation so that it can compile for universal builds.\n\nTagging @msprotz @R1kM as the authors of the recent HACL* changes.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-123927\n* gh-123989\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/freakboy3742","@type":"Person","name":"freakboy3742"},"datePublished":"2024-09-05T22:56:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":22},"url":"https://github.com/123748/cpython/issues/123748"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:87889352-e02a-f89d-694b-6d7eea4e6535 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD20:1A500C:102FFC8:1516767:696B0B6E |
| html-safe-nonce | f6d237da63d8dd3413c5ca08d7231ff53fe32b5bfc2545ae8e61cde2410d0264 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDIwOjFBNTAwQzoxMDJGRkM4OjE1MTY3Njc6Njk2QjBCNkUiLCJ2aXNpdG9yX2lkIjoiNzQ3ODk4ODM5NzI1MTA3MDgzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bb91738eed293ebae44d595a5acf5b0cfa4754096595bdc7ff11134f6214d876 |
| hovercard-subject-tag | issue:2508966162 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/123748/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4212b15e38e9f33dad1616c8e57729cc8e2bcb086350d55f172eabbfae830d15/python/cpython/issues/123748 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4212b15e38e9f33dad1616c8e57729cc8e2bcb086350d55f172eabbfae830d15/python/cpython/issues/123748 |
| og:image:alt | Bug report Bug description: #99108 tracks the addition of a native HACL implementation to CPython. #119316 added an implementation of Blake2 to hashlib. This compiles fine on single architecture ma... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | freakboy3742 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width