Repository navigation
Conversation
cederom
reviewed
Nov 6, 2026
cederom
left a comment
Contributor
There was a problem hiding this comment.
Thank you @Fix-Point please sign the commit :-)
NuttX <stdint.h> typedefs uint128_t to the native "unsigned __int128" when
__INT128_DEFINED is set (arch types.h, under __SIZEOF_INT128__), clashing
with the uint128_t alias of the vendored HACL krml/types.h struct
("conflicting types for 'uint128_t'" when building Modules/_hacl).
Redirect the name instead of renaming its uses: while __INT128_DEFINED,
krml/types.h maps the uint128_t token to a private alias of the krml
struct, so the upstream typedef line and all HACL code keep the upstream
spelling but bind to the struct. The krml system-header dependency set is
parsed first (krml/internal/target.h; on NuttX <stdio.h> reaches
nuttx/lib/math32.h, the only header using uint128_t natively), so platform
headers keep their native typedef and the redirect stays in effect for the
rest of the translation unit. Includes keep the upstream order; the patch
is inert on platforms without __INT128_DEFINED.
Verified: all Modules/_hacl/*.c compile with gcc/clang x86-64 (redirect
active) and gcc -m32 / arm-none-eabi-gcc / avr-gcc (inactive); a mixed-TU
stress build (krml/types.h + nuttx/lib/math32.h in one TU) compiles and
runs correctly on 5 toolchains; MD5/SHA1/SHA2-224/256/384/512 (incl. the
streaming 128-bit length path)/SHA3 digests are byte-identical to Python
hashlib in all four binding configurations and the _Generic probe confirms
uint128_t binds to FStar_UInt128_uint128 in _hacl TUs; the full patch
series 0001..0022 applies cleanly to CPython v3.13.0. Known limit: a
platform macro whose body spells uint128_t (e.g. NuttX FLS128) must be
used after "#undef uint128_t", as noted in the patch.
Assisted-By: mimo-v2.6-pro
Signed-off-by: ouyangxiangzhen <[email protected]>
xiaoxiang781216
approved these changes
Nov 6, 2026
casaroli
reviewed
Nov 6, 2026
| $(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0019-undef-get_errno-set_errno-to-avoid-nuttx-macro-coll.patch | ||
| $(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0020-ctypes-skip-pythonapi-on-nuttx.patch | ||
| $(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0021-posixmodule-ignore-utime-enosys-on-nuttx.patch | ||
| $(Q) patch -p1 -d $(CPYTHON_UNPACKNAME) < patch$(DELIM)0022-hacl-krml-avoid-uint128-typedef-conflict-with-nuttx-stdint.patch |
Contributor
There was a problem hiding this comment.
The CI check job fails with "Makefile modified but interpreters/python/CMakeLists.txt was not updated". CMake needs no change here, because line 37 of CMakeLists.txt already applies every patch/*.patch.
Fix: add [skip-cmake-parity] to the commit message, with that reason.
xiaoxiang781216
approved these changes
Nov 8, 2026
Contributor
Author
|
The PR is dropped since |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to apache/nuttx#21491
CI-breaking
uint128_ttypedef clash between NuttX<stdint.h>(__INT128_DEFINED) and the vendored HACLkrml/types.h, fixed minimally: a single#ifdef __INT128_DEFINEDblock (hoist system-header parse + token redirect), +7/−0 in one file, upstream include order untouched, inert without__INT128_DEFINED.Building the vendored HACL* hash code (
Modules/_hacl) of interpreters/python currently fails on NuttX withconflicting types for 'uint128_t': NuttX<stdint.h>typedefsuint128_tto the nativeunsigned __int128whenever__INT128_DEFINEDis set (archtypes.h, under__SIZEOF_INT128__), colliding with theuint128_ttypedef of the vendoredkrml/types.hstruct.The fix redirects the name instead of renaming its uses. One
#ifdef __INT128_DEFINEDblock just before the typedef inModules/_hacl/include/krml/types.h:krml/internal/target.h(the krml system-header dependency set; on NuttX<stdio.h>reachesnuttx/lib/math32.h, the only header usinguint128_tnatively) so platform headers keep their native typedef, anduint128_ttoken to a private alias of the krml struct (#define uint128_t __FStar_UInt128_uint128), so the upstream typedef line and all HACL code keep the upstream spelling but bind to the struct.The redirect then stays in effect for the rest of the translation unit. Includes keep the upstream order (zero deleted lines); the whole block is a no-op where
__INT128_DEFINEDis not set. Shipped as patch 0022 of the existing interpreters/python patch series (plus one Makefile line applying it), following the established patch mechanism.Impact
interpreters/pythonchanges.__INT128_DEFINEDplatforms (e.g. arm-none-eabi and AVR targets, glibc hosts): the entire block is#ifdef-guarded.uint128_t(e.g. NuttXFLS128) must be used after#undef uint128_t.Testing
Verification matrix (host: Ubuntu 22.04.5 LTS x86-64; gcc 13.1.0, clang 14.0.0, arm-none-eabi-gcc 10.3.1, avr-gcc 5.4.0; real NuttX headers with
__INT128_DEFINEDactive, i.e. CI-faithful): 30 PASS / 0 FAIL.Modules/_hacl+ NuttX<stdint.h>reproduces the CI error verbatim:error: conflicting types for 'uint128_t'; have 'struct FStar_UInt128_uint128_s'.Modules/_hacl/*.c(Hacl_Hash_MD5/SHA1/SHA2/SHA3) build clean: gcc x86-64 and clang x86-64 with the redirect active (__INT128_DEFINED), plus gcc-m32,arm-none-eabi-gcc,avr-gcc.hashlibin all four binding configurations (patched guard-off, patched guard-on, unpatched baseline, unpatched arch types). A_Genericprobe confirmsuint128_tbinds toFStar_UInt128_uint128(size 16) inside_haclTUs in every configuration.krml/types.h+nuttx/lib/math32.hin one translation unit): compiles and runs correctly (nativeumulh64semantics + HACL struct semantics) on gcc x86-64, clang x86-64, gcc-m32; compiles onarm-none-eabi-gccandavr-gcc(compile-only targets).types.his byte-identical to the verified reference andfstar_uint128_struct_endianness.hremains upstream-untouched.