Skip to content

Commit

Permalink
py/py.mk: Use additional CFLAGS to compile string0.c.
Browse files Browse the repository at this point in the history
Otherwise functions like memset might get optimised to call themselves (eg
with gcc 10).  And provide CFLAGS_BUILTIN so these options can be changed
by a port if needed.

Fixes issue #6053.
  • Loading branch information
dpgeorge committed May 27, 2020
1 parent 4bbba30 commit a902b69
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions py/py.mk
Expand Up @@ -266,6 +266,11 @@ $(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER

SRC_QSTR += $(HEADER_BUILD)/moduledefs.h

# Standard C functions like memset need to be compiled with special flags so
# the compiler does not optimise these functions in terms of themselves.
CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto
$(BUILD)/lib/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN)

# Force nlr code to always be compiled with space-saving optimisation so
# that the function preludes are of a minimal and predictable form.
$(PY_BUILD)/nlr%.o: CFLAGS += -Os
Expand Down

0 comments on commit a902b69

Please sign in to comment.