JavaScript: emscripten's clang ignores --sysroot argument
When building ghcjs-base
's testsuite with the JS backend, I ran into the following error.
I'm building on mac, but I suspect this error is just being missed on Linux since the regular system headers are already on the path there - and we don't use the build outputs for it to cause a real problem.
I believe that the --sysroot=/Users/joshmeredith/projects/emsdk/upstream/emscripten/cache/sysroot
argument should be making all of emscripten's headers available, but for some reason this isn't working.
I can work around this problem by setting the C_INCLUDE_PATH
and LIBRARY_PATH
environment variables (I haven't tested which one of these is actually necessary).
Failed to build regex-posix-0.96.0.1.
Build log (
/Users/joshmeredith/.cache/cabal/logs/ghc-9.9.20230703/rgx-psx-0.96.0.1-a323fbc9.log
):
Configuring library for regex-posix-0.96.0.1..
Preprocessing library for regex-posix-0.96.0.1..
Wrap.hsc:89:10: fatal error: 'sys/types.h' file not found
89 | #include <sys/types.h>
| ^~~~~~~~~~~~~
1 error generated.
emcc: error: '/Users/joshmeredith/projects/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/Users/joshmeredith/projects/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c --target=arm64-apple-darwin -Qunused-arguments -D__GLASGOW_HASKELL__=909 -Ddarwin_BUILD_OS=1 -Daarch64_BUILD_ARCH=1 -Dghcjs_HOST_OS=1 -Djavascript_HOST_ARCH=1 -Icbits -Idist/build/cbits -Idist/build/autogen -Idist/build/global-autogen -include dist/build/autogen/cabal_macros.h -I/Users/joshmeredith/projects/ghc/ghcjs-libraries/ghc/_build/stage1/lib/../lib/javascript-ghcjs-ghc-9.9.20230703/bytestring-0.11.4.0-inplace/include -I/Users/joshmeredith/projects/ghc/ghcjs-libraries/ghc/_build/stage1/lib/../lib/javascript-ghcjs-ghc-9.9.20230703/base-4.18.0.0-inplace/include -I/Users/joshmeredith/projects/ghc/ghcjs-libraries/ghc/_build/stage1/lib/../lib/javascript-ghcjs-ghc-9.9.20230703/rts-1.0.2/include -I/Users/joshmeredith/.ghcup/ghc/9.6.2/include/ dist/build/Text/Regex/Posix/Wrap_hsc_test0.c -o dist/build/Text/Regex/Posix/Wrap_hsc_test0.o' failed (returned 1)