JavaScript backend doesn't build on Apple Silicon (M1)
Summary
Building ghc with JavaScript backend doesn't work on M1 Macs while it's possible to build the standard backend
~/git/ghc on master
% ./hadrian/build --bignum=native -j9 --docs=none --flavour=quickest
Up to date
| Run Hsc2Hs Stage1: libraries/unix/System/Posix/Resource.hsc => _build/stage1/libraries/unix/build/System/Posix/Resource.hs
| Run Hsc2Hs Stage1: libraries/unix/System/Posix/Terminal/Common.hsc => _build/stage1/libraries/unix/build/System/Posix/Terminal/Common.hs
| Run Ghc CompileHs Stage1: libraries/containers/containers/src/Data/Tree.hs => _build/stage1/libraries/containers/containers/build/Data/Tree.o
| Copy package 'base'
# cabal-copy (for _build/stage1/lib/package.conf.d/base-4.18.0.0.conf)
| Run Ghc CompileHs Stage1: libraries/ghc-heap/GHC/Exts/Heap.hs => _build/stage1/libraries/ghc-heap/build/GHC/Exts/Heap.o
| Run GhcPkg Recache Stage1: none => none
Command line: _build/stage0/bin/javascript-unknown-ghcjs-ghc -Wall -Wcompat -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage1/inplace/package.conf.d' '-this-unit-id ghc-heap-9.7' '-package-id base-4.18.0.0' '-package-id containers-0.6.7' '-package-id ghc-prim-0.10.0' '-package-id rts-1.0.2' -i -i/Users/local/git/ghc/_build/stage1/libraries/ghc-heap/build -i/Users/local/git/ghc/_build/stage1/libraries/ghc-heap/build/autogen -i/Users/local/git/ghc/libraries/ghc-heap -Irts/include -I_build/stage1/libraries/ghc-heap/build -I/Users/local/git/ghc/libraries/containers/containers/include -I/Users/local/git/ghc/_build/stage1/libraries/containers/containers/build/include -I/Users/local/git/ghc/libraries/base/include -I/Users/local/git/ghc/_build/stage1/libraries/base/build/include -I/Users/local/git/ghc/libraries/ghc-bignum/include/ -I/Users/local/git/ghc/_build/stage1/libraries/ghc-bignum/build/include/ -I/Users/local/git/ghc/rts/include -I/Users/local/git/ghc/_build/stage1/rts/build/include -optP-include -optP_build/stage1/libraries/ghc-heap/build/autogen/cabal_macros.h -outputdir _build/stage1/libraries/ghc-heap/build -fdiagnostics-color=always -Wnoncanonical-monad-instances -optc-Wno-unknown-pragmas -optP-Wno-nonportable-include-path -c libraries/ghc-heap/GHC/Exts/Heap.hs -o _build/stage1/libraries/ghc-heap/build/GHC/Exts/Heap.o -O0 -H64m -Wall -XHaskell2010 -XNoImplicitPrelude -no-global-package-db -package-db=/Users/local/git/ghc/_build/stage1/inplace/package.conf.d -ghcversion-file=rts/include/ghcversion.h -ghcversion-file=rts/include/ghcversion.h -Wno-deprecated-flags
===> Command failed with error code: 1
javascript-unknown-ghcjs-ghc: panic! (the 'impossible' happened)
GHC version 9.7.20230321:
allocUnboxedCon: not an unboxed constructor
(I#,
[h$$ghczmheapzm9zi7ZCGHCziExtsziHeapzix_1_s_15c7,
h$$ghczmheapzm9zi7ZCGHCziExtsziHeapzix_2_s_15c7])
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/StgToJS/DataCon.hs:89:9 in ghc:GHC.StgToJS.DataCon
CallStack (from HasCallStack):
panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Command failed
Build failed.
Steps to reproduce
Build any version of ghc with JavaScript backend support, for example, you can follow this article https://engineering.iog.io/2023-01-24-javascript-browser-tutorial/
Expected behavior
GHC that targets JavaScript backend should be able to be built
Environment
- GHC version used: 9.4.4
Optional:
- Operating System: macOS Ventura 13.2.1
- System Architecture: Apple Silicon