From 462e34c26659e13260efaedf2ded8b50b4c33bdb Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 16 Aug 2021 22:43:02 +1000 Subject: [PATCH 1/2] unix/Makefile: Disable error compression on arm-linux-gnueabi-gcc. This compiler is unable to optimise out the giant strcmp match generated by MP_MATCH_COMPRESSED. See github.com/micropython/micropython/pull/7659#issuecomment-899479793 Signed-off-by: Jim Mussared --- ports/unix/Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 36b6322d86c29..bf9d290abfa9a 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -290,6 +290,17 @@ else RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc' endif +ifeq ($(CROSS_COMPILE),arm-linux-gnueabi-) +# Force disable error text compression when compiling for ARM as the compiler +# cannot optimise out the giant strcmp list generated for MP_MATCH_COMPRESSED. +# Checked on: +# arm-linux-gnueabi-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 +# arm-linux-gnueabi-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 +# See https://github.com/micropython/micropython/pull/7659 for details. +$(info Detected arm-linux-gnueabi-gcc. Disabling error message compression.) +MICROPY_ROM_TEXT_COMPRESSION = 0 +endif + include $(TOP)/py/mkrules.mk .PHONY: test test_full From 3be4ca179ef924d607ad862120171569d395d9a1 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 16 Aug 2021 22:45:06 +1000 Subject: [PATCH 2/2] tests/extmod/vfs_fat_finaliser.py: Ensure alloc at never-used GC blocks. Prevents the finaliser from being missed if there's a dangling reference on the stack to one of the blocks for the files (that this test checks that they get finalised). See github.com/micropython/micropython/pull/7659#issuecomment-899479793 Signed-off-by: Jim Mussared --- tests/extmod/vfs_fat_finaliser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/extmod/vfs_fat_finaliser.py b/tests/extmod/vfs_fat_finaliser.py index e30f42f8471f5..b67afc2d94641 100644 --- a/tests/extmod/vfs_fat_finaliser.py +++ b/tests/extmod/vfs_fat_finaliser.py @@ -56,6 +56,13 @@ def ioctl(self, op, arg): # Here we test that the finaliser is actually called during a garbage collection. import gc +# Do a large number of single-block allocations to move the GC head forwards, +# ensuring that the files are allocated from never-before-used blocks and +# therefore couldn't possibly have any references to them left behind on +# the stack. +for i in range(1024): + [] + N = 4 for i in range(N): n = "x%d" % i