ghc-wasm-meta instructions fail on ffi.h on Mac ARM
Summary
Following the instructions in ghc-wasm-meta
fails on my Mac M2 machine. It's specific to Mac, as it works fine building in Docker on aarch64 ubuntu. Specifically, the ./configure $CONFIGURE_ARGS
step fails with
Cannot find ffi.h for system libffi
Looking at the log, the failure is coming from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi/ffi.h
which includes os/availibility.h
, which ~/.ghc-wasm/wasi-sdk/bin/clang
can't find. Adding /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
to CPATH
(where os/availability.h
exists) gives different errors. Setting CPATH
to ~/.ghc-wasm/wasi-sdk/share/wasi-sysroot/include
(with the newly downloaded ffi.h
) also doesn't help:
$ echo '#include <ffi.h>' > foo.c
$ (export CPATH=~/.ghc-wasm/wasi-sdk/share/wasi-sysroot/include; source ~/.ghc-wasm/env; $CC -v foo.c)
ignoring nonexistent directory "/Users/bchinn/.ghc-wasm/wasi-sdk/bin/../share/wasi-sysroot/include/wasm32-wasi"
ignoring duplicate directory "/Users/bchinn/.ghc-wasm/wasi-sdk/share/wasi-sysroot/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi
/Users/bchinn/.ghc-wasm/wasi-sdk/lib/clang/15.0.7/include
/Users/bchinn/.ghc-wasm/wasi-sdk/share/wasi-sysroot/include
I got it working by pointing to some other ffi.h
file I have, but I also found a better workaround: removing --with-system-libffi
seems to work.
Steps to reproduce
- Download
wasi-sdk
artifacts perghc-wasm-meta
steps - Download
wasm-libffi
artifacts perghc-wasm-meta
steps - Add
~/.ghc-wasm/env
perghc-wasm-meta
steps bash -c 'source ~/.ghc-wasm/env && ./boot && ./configure $CONFIGURE_ARGS'
Expected behavior
The last step should be successful.
Environment
- GHC version used:
Optional:
- Operating System:
- System Architecture: