On 2/27/25 1:17 PM, Jan Dubiec wrote:
When INT_TYPE_SIZE < BITS_PER_WORD gcc emits a call to an external ffs()
implementation instead of a call to "__builtin_ffs()" – see function
init_optabs() in <SRCROOT>/gcc/optabs-libfuncs.cc. External ffs()
(which is usually the one from newlib) in turn calls __builtin_ffs()
what causes infinite recursion and stack overflow. This patch overrides
default gcc bahaviour for H8/300H (and newer) and provides a generic
ffs() implementation for HImode.
2025-02-27 Jan Dubiec <j...@o2.pl>
PR target/114222
gcc/ChangeLog:
* config/h8300/h8300.cc (h8300_init_libfuncs): For HImode override
calls to external ffs() (from newlib) with calls to __ffshi2() from
libgcc. The implementation of ffs() in newlib calls __builtin_ffs()
what causes infinite recursion and finally a stack overflow.
libgcc/ChangeLog:
* config/h8300/t-h8300: Add __ffshi2().
* config/h8300/ffshi2.c: New file.
Thanks. It's a viable workaround for the newlib glitch. I've pushed it
to the trunk (again, obviously H8 specific so OK as an exception to
stage4 policy).
Jeff
ps. I must admit some curiosity what you're doing with the H8 port. It
hasn't exactly been a high interest port for a long time.