Skip to content

Compiling Unix Port on Apple Silicon (arm64) #11039

@relic-se

Description

@relic-se

CircuitPython version and board name

Output of `uname -a`
Darwin *.local 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:41:26 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8132 arm64

Code/REPL

# N/A

Behavior

The following errors were encountered while attempting to follow the guide at https://docs.circuitpython.org/en/latest/ports/unix/README.html. Latest versions of llvm, pkg-config and libffi installed via Homebrew: brew install llvm pkgconf libffi.

MP3 Platform Detection

GEN build-coverage/genhdr/mpversion.h
In file included from ../../lib/mp3/src/hufftabs.c:44:
In file included from ../../lib/mp3/src/coder.h:47:
In file included from ../../lib/mp3/src/mp3common.h:47:
../../lib/mp3/src/mp3dec.h:80:2: error: No platform defined. See valid options in mp3dec.h
   80 | #error No platform defined. See valid options in mp3dec.h
      |  ^
1 error generated.

I can comment out the following line within the Adafruit_MP3 submodule from lib/mp3/src/mp3dec.h:80 to continue compilation:

// #error No platform defined. See valid options in mp3dec.h

My best guess is that arm64 is functional, but support isn't declared.

Typedef Redefinition

GEN build-coverage/frozen_content.c
In file included from ../../shared-bindings/audiocore/__init__.c:15:
In file included from ../../shared-bindings/audiocore/RawSample.h:9:
In file included from ../../shared-module/audiocore/RawSample.h:11:
../../shared-module/audiocore/__init__.h:29:3: error: redefinition of typedef 'audiosample_base_t' is a C11 feature [-Werror,-Wtypedef-redefinition]
   29 | } audiosample_base_t;
      |   ^
../../shared-bindings/audiocore/__init__.h:16:33: note: previous definition is here
   16 | typedef struct audiosample_base audiosample_base_t;
      |                                 ^
1 error generated.

Changing -std=gnu99 to -std=gnu11 within ports/unix/Makefile fixes these errors. Support within Clang is "Partial": https://clang.llvm.org/c_status.html.

I assume that other platforms (ie: not using clang) aren't reporting this error even though they're on the older C99 standard.

Implicit Conversion

../../shared-bindings/audiomp3/MP3Decoder.c:202:29: error: implicit conversion increases floating-point precision: 'float' to 'mp_float_t' (aka 'double')
      [-Werror,-Wdouble-promotion]
  202 |     return mp_obj_new_float(common_hal_audiomp3_mp3file_get_rms_level(self));
      |            ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
-e See https://learn.adafruit.com/building-circuitpython; Adafruit Discord #circuitpython-dev
make: *** [build-coverage/shared-bindings/audiomp3/MP3Decoder.o] Error 1

Forcing the type on shared-bindings/audiomp3/MP3Decoder.c:202 fixes this error:

return mp_obj_new_float((mp_float_t) common_hal_audiomp3_mp3file_get_rms_level(self));

ports/unix/variants/mpconfigvariant_common.h:41 defines MICROPY_FLOAT_IMPL as MICROPY_FLOAT_IMPL_DOUBLE. This causes py/mpconfig.h:998 to use double for mp_float_t, triggering the type mismatch.

Description

After the above changes are made, the coverage variant successfully compiles.

Additional information

Running make test results in 11 failed tests:

11 tests failed: basics/try_finally_return4.py basics/try_finally_return5.py float/complex1.py basics/try_finally_break.py basics/try_finally_break2.py basics/try_finally_continue.py basics/try_finally_return2.py basics/try_finally_return3.py float/math_fun.py float/math_fun_special.py thread/stress_schedule.py

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions