Skip to content

Avoid gcc 7.2.1 compiler issues in nlr_push() #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ endif
ifeq ($(DEBUG), 1)
# Turn on Python modules useful for debugging (e.g. uheap, ustack).
CFLAGS += -ggdb
CFLAGS += -flto
ifeq ($(CHIP_FAMILY), samd21)
CFLAGS += -DENABLE_MICRO_TRACE_BUFFER
endif
Expand Down Expand Up @@ -122,8 +123,6 @@ ifeq ($(CHIP_FAMILY), samd51)
CFLAGS += \
-mthumb \
-mabi=aapcs-linux \
-mlong-calls \
-mtune=cortex-m4 \
-mcpu=cortex-m4 \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
Expand Down
8 changes: 7 additions & 1 deletion py/nlrthumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
#else
"b nlr_push_tail \n" // do the rest in C
#endif
);
: // output operands
: "r" (nlr) // input operands
// Do not use r1, r2, r3 as temporary saving registers.
// gcc 7.2.1 started doing this, and r3 got clobbered in nlr_push_tail.
// See https://github.com/adafruit/circuitpython/issues/500 for details.
: "r1", "r2", "r3" // clobbers
);

return 0; // needed to silence compiler warning
}
Expand Down