building micropython on mac os x - YMMV

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Posts: 6
Joined: Sun Sep 01, 2019 3:34 pm

building micropython on mac os x - YMMV

Post by sanandak » Sun Sep 01, 2019 4:10 pm

Here are the steps I had to take to build on my mac. I did some things without fully understanding what their further impacts may be - so caveat emptor. (the tests did run ok for what that is worth...)

I mostly followed the instructions on this wiki page
[url] ... on-Mac-OSX[/url]

Mac OSX v10.14.5
$ uname -a
Darwin .local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
$ gcc --version
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/Applications/
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/

1. system includes may not be in the search path:
$ export CFLAGS_EXTRA=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

2. disable PTHREAD - the reason this doesn't compile may be a mac compiler error - online searches were confusing. I couldn't find a way around this.

in ports/unix/ set THREAD flag to 0
# _thread module using pthreads

3. the compiler makes something called "nullability" an error. I don't know what that is - sorry - but I added this:

in both ports/unix/Makefile and mpy-cross/Makefile
add to CWARN: "-Wno-nullability-completeness"
CWARN += -Wpointer-arith -Wuninitialized -Wno-nullability-completeness

4. repeated typedefs are an error

in lib/berkeley-db-1.xx/PORT/include/db.h
comment out the typedefs in the __BIT_TYPES_DEFINED__ ifndef block:
typedef __signed char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;

in py/misc.h
add #include <sys/types.h> and comment out the uint typedef
#include <sys/types.h>
typedef unsigned char byte;
//typedef unsigned int uint;

5. output of make test

$ make test

711 tests performed (19439 individual testcases)
711 tests passed
38 tests skipped: builtin_help builtin_next_arg2 builtin_range_binop class_delattr_setattr io_buffered_writer memoryview_itemsize namedtuple_asdict sys_getsizeof cmd_parsetree framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass ucryptolib_aes128_ctr urandom_extra urandom_extra_float ure_debug ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_fat_ramdisklarge vfs_userfs math_factorial_intbig module_getattr mpy_invalid mpy_native resource_stream schedule extra_coverage

6. run it
$ micropython
MicroPython v1.11-240-g519746cae-dirty on 2019-09-01; darwin version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> print('hello')
>>> 2+2

Post Reply