aboutsummaryrefslogtreecommitdiff
path: root/py/py.mk
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-05-21 11:27:09 +1000
committerDamien George <damien.p.george@gmail.com>2020-05-27 23:10:23 +1000
commita902b69dd51de0e3fe3bb6955296591d6a93abab (patch)
tree5bda4b15d5b629ebe714d66a49d9271943fd82fe /py/py.mk
parent4bbba3060d451d4dfa147ebc793acd1cc7364e5a (diff)
py/py.mk: Use additional CFLAGS to compile string0.c.
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.
Diffstat (limited to 'py/py.mk')
-rw-r--r--py/py.mk5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/py.mk b/py/py.mk
index 0a98ccc00..d864a7ed3 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -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