building NACL stuff on OS X

this wasn’t too much fun as it is a constantly moving target and documentation slides by the side… So no doubt by the time someone else reads this it’ll be obsolete.

Some of the steps you can follow from here…

https://developers.google.com/native-client/sdk/download

the output will be completely different though.  Something like this:

$ ./naclsdk list
Bundles:
I: installed
*: update available

I sdk_tools (stable)
vs_addin (dev)
pepper_27 (post_stable)
pepper_28 (post_stable)
pepper_29 (post_stable)
pepper_30 (post_stable)
pepper_31 (stable)
pepper_32 (dev)
pepper_canary (canary)

All installed bundles are up-to-date.

I chose to install the stable branch, pepper_31 in this case (the google page talks about version 14 being stable, so a LOT has changed).

./naclsdk update pepper_31

And two big files will download and unpack in your directory.

You will also need depot_tools, a collection of scripts google uses for git/svn.  Be sure to setup your path & environment for NACL building:

$ cat /Users/neozeed/.profile
NACL_SDK_ROOT=/Users/neozeed/src/nacl_sdk/pepper_31/
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/neozeed/src/depot_tools

export NACL_SDK_ROOT PATH

And of course you’ll want to check out the nacl ports.  With everything in place the download should at least work correctly

mkdir naclports
cd naclports
gclient config –name=src https://chromium.googlesource.com/external/naclports.git
gclient config http://naclports.googlecode.com/svn/trunk/src
gclient sync

And then before you go racing off trying to build something, as it stands right now (December 2013, pepper v.31), there is a big ‘libc’ change going on, and most of the nacl stuff will not build.  You’ll need to issue something like this:

NACL_GLIBC=1 make nethack

The other major roadblock I’ve seen so far is that zlib will not build correctly, it’ll want to build a static version of itself, because the configure script is still seeing your PC as OS X, not as a nacl build.  I found the easier way was to rename the Darwin section, and then remove all the Linux bits in the OS detection and rename that to Darwin…

Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-“$cc -shared -Wl,-soname,libz.so.1”};;

becomes

Darwin*) LDSHARED=${LDSHARED-“$cc -shared -Wl,-soname,libz.so.1”};;

And further down just rename

Darwin*) shared_ext=’.dylib’

to

XXXDarwin*) shared_ext=’.dylib’

And rebuilt zlib and now you should get the dynamic library everything else hinges on.

I hope this helps someone else..