Skip to content

Commit

Permalink
Fix GCC 12 infinite loop in strlen
Browse files Browse the repository at this point in the history
Strlen was jumping to strlen as part of -ftree-loop-distribute-patterns.
Seems this sort of issue can be common and generally fixed with
-fno-builtin. However, some of those optimizations may be useful and I
don't think our semantics for the functions are wildly different than
the standard, so I'm fixing this surgically with
-ftree-loop-distribute-patterns to just util.c. That may be the wrong
call, so if this bites us again, let's go more aggressive.

[Above is commit message from FlashFloppy, which also references
FlashFloppy GitHub issue 660.]

Refs #60
  • Loading branch information
keirf committed Feb 11, 2025
1 parent 3243030 commit 041a618
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ OBJS += vectors.o

.PHONY: build_info.c
build_info.o: CFLAGS += -DFW_VER="\"$(FW_VER)\""

# Avoid infinite loops due to GCC noticing code that can be replaced by a call
# to a standard library function... within our implementation of that function.
util.o: CFLAGS += -fno-tree-loop-distribute-patterns

0 comments on commit 041a618

Please sign in to comment.