Skip to content

Unable to build mpy-cross with Apple clang version 17.0.0 #18116

@Anton-2

Description

@Anton-2

Port, board and/or hardware

any

MicroPython version

Tested on v1.26.0 and latest master today v1.26.0-161-g8757eb715.

Reproduction

cd mpy-cross
make

Expected behaviour

Expected to build mpy-cross, like

...
LINK build/mpy-cross
__TEXT	__DATA	__OBJC	others	dec	hex
425984	16384	0	4295032832	4295475200	10007c000

Observed behaviour

Build fails with :

CC ../py/parse.c
../py/parse.c:349:19: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
  349 |                || mp_obj_is_float(*o)
      |                   ^~~~~~~~~~~~~~~~~~~
../py/obj.h:120:28: note: expanded from macro 'mp_obj_is_float'
  120 | #define mp_obj_is_float(o) mp_obj_is_type((o), &mp_type_float)
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../py/obj.h:979:31: note: expanded from macro 'mp_obj_is_type'
  979 | #define mp_obj_is_type(o, t) (mp_type_assert_not_bool_int_str_nonetype(t) && mp_obj_is_exact_type(o, t))
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../py/obj.h:973:5: note: expanded from macro 'mp_type_assert_not_bool_int_str_nonetype'
  973 |     MP_STATIC_ASSERT_NONCONSTEXPR((t) != &mp_type_bool), assert((t) != &mp_type_bool),         \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../py/misc.h:76:45: note: expanded from macro 'MP_STATIC_ASSERT_NONCONSTEXPR'
   76 | #define MP_STATIC_ASSERT_NONCONSTEXPR(cond) MP_STATIC_ASSERT(cond)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
../py/misc.h:66:51: note: expanded from macro 'MP_STATIC_ASSERT'
   66 | #define MP_STATIC_ASSERT(cond) ((void)sizeof(char[1 - 2 * !(cond)]))
      |                                                   ^~~~~~~~~~~~~~~

... same error repeated ...

12 errors generated.
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting
make: *** [build/py/parse.o] Error 1

Additional Information

I was able to build may-cross before.

This fails after upgrading to macos 26, that probably upgraded clang to version 17.0.0 in the process.
This clang version seems to dislike the MP_STATIC_ASSERT macro.

Compilation works when silencing the gnu-folding-constant warning/error :

like (in micropython/py/misc.h) :

// Static assertion macro
#define MP_STATIC_ASSERT(cond) \
    _Pragma("GCC diagnostic push") \
    _Pragma("GCC diagnostic ignored \"-Wgnu-folding-constant\"") \
    ((void)sizeof(char[1 - 2 * !(cond)])) \
    _Pragma("GCC diagnostic pop")

... but I don't know if its safe to do, and how it'll affect other compilers.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions