[HACL] The `HACL_CAN_COMPILE_VEC128` macro is not defined when building Python with `-Wundef`
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 64/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 領域
- build-system
研究方向
警告來自 #if HACL_CAN_COMPILE_VEC128 / ..._VEC256,它們位於 Modules/_hacl/Hacl_Streaming_HMAC.c 中(約 18 處),而 Modules/blake2module.c 和 Modules/hmacmodule.c 展示了巨集通常如何從 _Py_HACL_CAN_COMPILE_VEC* 轉發。首先確定修復位置:保護每個 #if(位於 .c 檔案中),或在 Modules/_hacl/internal/Hacl_Streaming_HMAC.h 中定義這些巨集——編輯前檢查 _hacl 原始碼是如何 vendored/重新產生的,因為產生的檔案可能被覆寫。用 -Wundef 重新建置(見 gh-162214),並確認 Hacl_Streaming_HMAC 的警告已消失;完成意味著一次乾淨的建置,而不只是靜默的建置。
由索引模型根據 Issue 內容生成。
描述
The HACL_CAN_COMPILE_VEC128 and HACL_CAN_COMPILE_VEC256 macros are not defined when building Python with -Wundef. See issue gh-162214 for -Wundef flag.
Build logs:
gcc -Wno-unused-variable -c -I./Modules/_hacl -I./Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -g -Og -Wall -Wundef -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 -I. -I./Include -fPIC -o Modules/_hacl/Hacl_Streaming_HMAC.o ./Modules/_hacl/Hacl_Streaming_HMAC.c
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'malloc_':
./Modules/_hacl/Hacl_Streaming_HMAC.c:477:13: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
477 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:540:13: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
540 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'init':
./Modules/_hacl/Hacl_Streaming_HMAC.c:654:9: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
654 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:671:9: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
671 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'update_multi':
./Modules/_hacl/Hacl_Streaming_HMAC.c:771:9: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
771 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:796:9: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
796 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'update_last':
./Modules/_hacl/Hacl_Streaming_HMAC.c:897:9: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
897 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:921:9: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
921 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'finish':
./Modules/_hacl/Hacl_Streaming_HMAC.c:1043:9: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
1043 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:1060:9: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
1060 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'copy':
./Modules/_hacl/Hacl_Streaming_HMAC.c:1342:9: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
1342 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:1381:9: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
1381 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function 'hash':
./Modules/_hacl/Hacl_Streaming_HMAC.c:1468:13: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
1468 | #if HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:1480:13: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
1480 | #if HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c: In function '_Py_LibHacl_Hacl_Streaming_HMAC_malloc_':
./Modules/_hacl/Hacl_Streaming_HMAC.c:1971:8: warning: 'HACL_CAN_COMPILE_VEC256' is not defined, evaluates to '0' [-Wundef]
1971 | #if !HACL_CAN_COMPILE_VEC256
| ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_hacl/Hacl_Streaming_HMAC.c:1977:8: warning: 'HACL_CAN_COMPILE_VEC128' is not defined, evaluates to '0' [-Wundef]
1977 | #if !HACL_CAN_COMPILE_VEC128
| ^~~~~~~~~~~~~~~~~~~~~~~
One solution would be to replace #if HACL_CAN_COMPILE_VEC128 with #if defined(HACL_CAN_COMPILE_VEC128) && HACL_CAN_COMPILE_VEC128 (and same change for the 256 macro) in Modules/_hacl/Hacl_Streaming_HMAC.c.
Modules/blake2module.c and Modules/hmacmodule.c define the two macros. Example:
#if defined(__APPLE__) && defined(__arm64__)
# undef _Py_HACL_CAN_COMPILE_VEC128
# undef _Py_HACL_CAN_COMPILE_VEC256
#endif
// HACL* expects HACL_CAN_COMPILE_VEC* macros to be set in order to enable
// the corresponding SIMD instructions so we need to "forward" the values
// we just deduced above.
#define HACL_CAN_COMPILE_VEC128 _Py_HACL_CAN_COMPILE_VEC128
#define HACL_CAN_COMPILE_VEC256 _Py_HACL_CAN_COMPILE_VEC256
But Modules/_hacl/internal/Hacl_Streaming_HMAC.h doesn't set these macros.
- 主要語言
- Python
- 星號
- 78.4k
- 分支
- 36.6k
- 平均合併
- 23 小時 34 分鐘
- 30 天內合併 PR
- 610
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
interpreter-core type-bug
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
stdlib topic-subprocess type-bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
corner case: base64.b32decode ignorechars=b'=' miscounts padding可能已有人在做 @ElDShell 今天認領。 未關閉3.15 easy type-bug
難度 2/5 1-3 小時 新手友好度 62/100
python/cpython#162353 · 1 則留言 ·
維護者通常 1 天內回覆
-
TracebackException.lineno changes from str to int after format() when a keyword typo suggestion is found可能已有人在做 @Sudhakar7J 於 2 天前認領。 未關閉stdlib type-bug
難度 2/5 1-3 小時 新手友好度 67/100
python/cpython#162296 · 1 則留言 ·
維護者通常 1 天內回覆
-
zipfile: ZipInfo.comment exceeding 65535 bytes causes struct.error in ZipFile.close() without proper validation可能已有人在做 @1cbyc 於 5 天前認領。 未關閉stdlib type-bug
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
vllm-project/vllm#69304 · 1 則留言 ·
維護者通常 1 天內回覆
-
pydanty:is-working
難度 2/5 1-3 小時 新手友好度 68/100
pydantic/pydantic-ai#14187 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
test
難度 2/5 1-3 小時 新手友好度 62/100
prebid/salesagent#2676 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 62/100
sunososobro-hub/cloudball#339 ·
維護者通常 1 天內回覆