From aab0945629746b48eb3930bcff9ea2c910bebb75 Mon Sep 17 00:00:00 2001 From: local-dev Date: Tue, 2 Jun 2026 16:49:14 -0700 Subject: [PATCH] [build] B: Enable %lld/%llu and C99 format support in printf The z build script's newlib configure invocation never passed --enable-newlib-io-long-long or --enable-newlib-io-c99-formats. Without these flags the generated newlib.h ends up with #undef _WANT_IO_LONG_LONG and #undef _WANT_IO_C99_FORMATS, which makes newlib's vfprintf silently treat %lld/%llu as %ld/%lu (dropping the high 32 bits of long-long args on i686) and disables C99 format specifiers. Concrete impact: CPython's test_struct.test_issue98248 fails 32 subtests on i686-nanvix because PyErr_Format with the format string "'%c' format requires %lld <= number <= %lld" called with LLONG_MIN and LLONG_MAX reports the message as "'q' format requires 0 <= number <= -1" instead of the correct 64-bit bounds. Any other user-space code using %lld/%llu is silently broken in the same way. configure.host already sets default_newlib_io_long_long=yes for *-nanvix*, but that only takes effect when the explicit --enable-... switch is also passed; without it the option ends up disabled. Adding the two switches to z's configure call enables long-long and C99 printf support unconditionally for Nanvix toolchain builds and does not change behavior for any other host. Validation: after rebuilding the toolchain image with this patch, CPython regrtest's test_struct batch goes from 32 failures to 0; full 160/160 modules now pass. struct.pack('@Q', -1) raises "'Q' format requires 0 <= number <= 18446744073709551615" (correct 64-bit max) instead of the previous "... <= 4294967295". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- z | 2 ++ 1 file changed, 2 insertions(+) diff --git a/z b/z index bfdbda5d20..373fb51ab5 100755 --- a/z +++ b/z @@ -178,6 +178,8 @@ configure_steps() { --target="${Z_TARGET}" \ --prefix="${Z_INSTALL_LOCATION}" \ --disable-multilib \ + --enable-newlib-io-long-long \ + --enable-newlib-io-c99-formats \ "${cc_for_target_flags[@]}" || { print_error "Configuration failed." return 1