Repository: google-deepmind/meltingpot
Issue: build lab2d on m1 chip
Root cause: Documentation Deficiency

Hi guys, not sure if this issue should exist here or on [lab2d](https://github.com/deepmind/lab2d) - i'm happy to repost if necessary.

Running, as suggested by the readme, `bazel build -c opt --define=lua=5_1 --verbose_failures //dmlab2d:dmlab2d_wheel --sandbox_debug` - I get the following error message:

Seems like the bazel build is still trying to use `luajit`.
```                    
INFO: Analyzed target //dmlab2d:dmlab2d_wheel (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_akbirkhan/683a2f238f2fee5ed6a000bb83905b18/external/luajit_archive/BUILD.bazel:187:10: Compiling src/host/buildvm.c [for host] failed: (Aborted): sandbox-exec failed: error executing command
  (cd /private/var/tmp/_bazel_akbirkhan/683a2f238f2fee5ed6a000bb83905b18/sandbox/darwin-sandbox/68/execroot/org_deepmind_lab2d && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=12.1 \
    DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
    PATH=/Users/akbirkhan/lab2d/venv/bin:/opt/homebrew/opt/openjdk/bin:/Users/akbirkhan/miniforge3/condabin:/Users/akbirkhan/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin \
    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk \
    TMPDIR=/var/folders/y9/rn_jfyp116vghh2czk_zrsyh0000gr/T/ \
    XCODE_VERSION_OVERRIDE=13.2.1.13C100 \
    ZERO_AR_DATE=1 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_akbirkhan/683a2f238f2fee5ed6a000bb83905b18/sandbox/darwin-sandbox/68/sandbox.sb /var/tmp/_bazel_akbirkhan/install/aea2566887193b2d7f5a5c3a673ef137/process-wrapper '--timeout=0' '--kill_delay=15' external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' 'DEBUG_PREFIX_MAP_PWD=.' -iquote external/luajit_archive -iquote bazel-out/host/bin/external/luajit_archive -iquote external/bazel_tools -iquote bazel-out/host/bin/external/bazel_tools -isystem external/luajit_archive/src -isystem bazel-out/host/bin/external/luajit_archive/src -isystem external/luajit_archive/src/host -isystem bazel-out/host/bin/external/luajit_archive/src/host -MD -MF bazel-out/host/bin/external/luajit_archive/_objs/buildvm/buildvm.d '-frandom-seed=bazel-out/host/bin/external/luajit_archive/_objs/buildvm/buildvm.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks '-mmacosx-version-min=12.1' -no-canonical-prefixes -pthread -g0 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -target arm64-apple-macosx -c external/luajit_archive/src/host/buildvm.c -o bazel-out/host/bin/external/luajit_archive/_objs/buildvm/buildvm.o)
external/luajit_archive/src/host/buildvm.c:63:10: fatal error: '../dynasm/dasm_arm64.h' file not found
#include "../dynasm/dasm_arm64.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
Target //dmlab2d:dmlab2d_wheel failed to build
INFO: Elapsed time: 0.451s, Critical Path: 0.32s
INFO: 9 processes: 9 internal.
FAILED: Build did NOT complete successfully
```




Got this to build using the following command! 

`bazel build --config=lua5_2 --verbose_failures //dmlab2d:dmlab2d_wheel`

Can open a PR to fix in the README if authors are cool with this

Thank you for the heads up! Yes, it seems one needs 5_2 for the m1. It should be fine, as lab2d is compatible with that Lua version. We will update the docs to fix this for others.

Good luck!

Edgar

hey @duenez - i think the problem was the arguments need to be passed through via `--config` as opposed to `-c opt --define`! 

mentioned here: https://github.com/deepmind/lab2d/issues/14#issuecomment-1043306407

Hi, on my MacBook Prof M1, if you cannot build the wheel file, please uninstall lua and luajit by using brew. Then it can build the wheel file.