Conversation
|
Code size report: |
|
No idea why, but there are failures in CI: Maybe it's the use of |
|
Well that was interesting. On Ubuntu 24.04 with gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1) (but not on godbolt 13.3.0), using that is, rather than emitting nothing for In order to make this happen, a call to |
This version is believed to work from Clang 3.0 to 22.1.0 (all versions on godbolt at the time of writing). Clang rejects the `(void)x;` notation for a used variable in a naked asm function, so do this only conditionally. Introduces use of `__builtin_unreachable()` with gcc. This saves 1 byte by causing gcc not to emit an `ud2` opcode at the end. However, the unreachable sanitizer (enabled by default(!) on Ubuntu 24.04 with gcc version 13.3.0) corrupts the ebx register, so it must be disabled. Clang does not accept `__builtin_unreachable` or `return 0;` here, UNREACHABLE must expand to nothing. Closes: micropython#17415 Signed-off-by: Jeff Epler <jepler@unpythonic.net>

Summary
This version is believed to work from Clang 3.0 to 22.1.0 (all versions on godbolt at the time of writing).
Clang rejects the
(void)x;notation for a used variable in a naked asm function, so do this only conditionally.Introduces use of
__builtin_unreachable()with gcc. This saves 1 byte by causing gcc not to emit anud2opcode at the end. Clang does not accept__builtin_unreachableorreturn 0;here, so it must emit nothing.Closes: #17415
Testing
Locally, I ran
make clean && make CC="clang -m32 -g" -j12 test//basic test//nativein ports/unix.Trade-offs and Alternatives
This combination is not ci-tested. A ci-time test could be added, perhaps nanbox or just a dupe of something else like standard.
Generative AI
I did not use generative AI tools when creating this PR.