building micropython on mac os x - YMMV

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
sanandak
Posts: 1
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]https://github.com/micropython/micropyt ... on-Mac-OSX[/url]

Mac OSX v10.14.5
[code]
$ 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/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
[/code]

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

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/mpconfigport.mk set THREAD flag to 0
[code]
# _thread module using pthreads
MICROPY_PY_THREAD = 0
[/code]

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"
[code]
CWARN += -Wpointer-arith -Wuninitialized -Wno-nullability-completeness
[/code]

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:
[code]
/*
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;
*/
[/code]

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

5. output of make test

[code]
$ 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
[/code]

6. run it
[code]
$ 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')
hello
>>> 2+2
4
>>>
[/code]

Post Reply