[HACL] The `HACL_CAN_COMPILE_VEC128` macro is not defined when building Python with `-Wundef`

Aperta Adatta ai principianti
#162,219 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@tamaki0575-cloud ci sta già lavorando.

Dal 21/11/2026.

  • #162393 di @tamaki0575-cloud — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, python
Ambito
build-system

Direzione di ricerca

Gli avvisi provengono da #if HACL_CAN_COMPILE_VEC128 / ..._VEC256 in Modules/_hacl/Hacl_Streaming_HMAC.c (circa 18 punti), mentre Modules/blake2module.c e Modules/hmacmodule.c mostrano come le macro vengono normalmente inoltrate da _Py_HACL_CAN_COMPILE_VEC*. Per prima cosa decidi il punto della correzione: proteggere ogni #if nel file .c, oppure definire le macro in Modules/_hacl/internal/Hacl_Streaming_HMAC.h — controlla come le sorgenti _hacl sono vendorizzate/rigenerate prima di modificare, poiché i file generati possono essere sovrascritti. Ricompila con -Wundef (vedi gh-162214) e conferma che gli avvisi Hacl_Streaming_HMAC sono spariti; fatto significa una build pulita, non solo silenziosa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

build extension-modules topic-C-API type-bug

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.

Lingua principale
Python
Stelle
78.4k
Fork
36.6k
Merge medio
23h 34m
PR unite (30g)
610

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/cpython

Tutte le issue di python/cpython

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.