Description
Looks today's updates got me GCC 9.1, which includes a new error for having "sp" in the clobber list for an __asm
statement. This comes up in both cmsis_gcc.h:__set_MSP
(and in the inlined copy in modmachine.c:machine_bootloader
).
modmachine.c: In function 'machine_bootloader':
../../lib/cmsis/inc/core_cm4.h:93:28: error: listing the stack pointer register 'sp' in a clobber list is deprecated [-Werror=deprecated]
93 | #define __ASM __asm /*!< asm keyword for GNU Compiler */
| ^~~~~
modmachine.c:306:5: note: in expansion of macro '__ASM'
306 | __ASM volatile ("movs r3, #0\nldr r3, [r3, #0]\nMSR msp, r3\n" : : : "r3", "sp");
| ^~~~~
../../lib/cmsis/inc/core_cm4.h:93:28: note: the value of the stack pointer after an 'asm' statement must be the same as it was before the statement
93 | #define __ASM __asm /*!< asm keyword for GNU Compiler */
| ^~~~~
modmachine.c:306:5: note: in expansion of macro '__ASM'
306 | __ASM volatile ("movs r3, #0\nldr r3, [r3, #0]\nMSR msp, r3\n" : : : "r3", "sp");
| ^~~~~
cc1: all warnings being treated as errors
There appears to be surprisingly little info about this, but here's the most relevant message from the gcc discussion.
https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg203357.html
From my understanding of the clobber list, that the compiler should restore the clobbered registers, it makes sense that "sp" should not have been in the clobber list in the first place.
I've attached disassembly of compiling for PYBV11 with both gcc 8.3, and 9.1 with "sp" removed from the clobber list. I haven't spotted any relevant difference.
machine_bootloader.9.1.txt
machine_bootloader.8.3.txt
Not sure the best way to fix this in lib/cmsis/inc/cmsis_gcc.h
though, seeing as there isn't a fix in upstream cmsis. Are you willing to have diffs to upstream?