SpotlightKid wrote: ↑Wed Nov 15, 2017 10:53 pm
I'm not interested in a workaround. I'm interested in improving MicroPython so that it compiles cleanly out of the box with Clang.
There's nothing to improve with micropython to "fix" this issue. Your compiler doesn't want to allow non-ASM statements in naked functions so you should improve Clang if you want it to compile non-ASM statements in naked functions.
"Out of the box" with software of any complexity is meaningless: of course there's going to have to be some
configuration.
If you luck out, sure you may be able to compile it without modifying anything in
mpconfigport.h or
nlr.h but that's the exception.
Why do you think there's so many
#if #elif macros below?
Code: Select all
struct _nlr_buf_t {
// the entries here must all be machine word size
nlr_buf_t *prev;
void *ret_val; // always a concrete object (an exception instance)
#if !defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP
#if defined(__i386__)
void *regs[6];
#elif defined(__x86_64__)
#if defined(__CYGWIN__)
void *regs[12];
#else
void *regs[8];
#endif
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
void *regs[10];
#elif defined(__xtensa__)
void *regs[10];
#else
#define MICROPY_NLR_SETJMP (1)
//#warning "No native NLR support for this arch, using setjmp implementation"
#endif
#endif
It's so you can configure it to your needs. If your needs are to use Clang, then you need to add
#define MICROPY_NLR_SETJMP 1 in
nlr.h
Here is the exact commit to Clang where they decided to add this constraint
Don't allow non-ASM statements in naked functions
https://reviews.llvm.org/rL217199