Skip to content

Commit 8b26c62

Browse files
committed
Document additional instructions for installing stack or packages requiring C source compilation for Apple Silicon chip
1 parent 8966e2f commit 8b26c62

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/install_and_upgrade.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ see the linked FAQ entries:
114114
If you are on macOS 10.12 (Sierra) and encounter GHC panic while building, see
115115
this [issue](https://github.com/commercialhaskell/stack/issues/2577)
116116

117+
118+
On Apple silicon chip (`aarch64`/`arm64` architectures), the installation for stack itself or some packages (e.g. `network`) requiring C source compilation might fail with
119+
`configure: error: C compiler cannot build executables.` in which case you should pass `-arch arm64` as part of
120+
the `CFLAGS` environment variable, which will be then picked up by the c compiler of your choice.
121+
122+
```bash
123+
# Assuming BASH below
124+
125+
# passing CFLAGS in-line with the command involving the error
126+
CFLAGS="-arch arm64 ${CFLAGS:-}" some_command_to_install_stack
127+
CFLAGS="-arch arm64 ${CFLAGS:-}" stack [build|install]
128+
129+
# -- OR --
130+
131+
# ~/.bash_profile
132+
# NOTE: only do this if you do not have to cross-compile or remember to unset CFLAGS when needed
133+
export CFLAGS="-arch arm64 ${CFLAGS:-}"
134+
```
135+
136+
This instructs the C compiler to compile objects for `arm64`, which would be then successfully linked with the libraries built for `arm64`, otherwise the c compiler, invoked by `cabal` running in `x86_64`, would compile x86_64 objects and attempt to link them with existing arm64 libraries and resulting in the error above.
137+
117138
## Ubuntu
118139

119140
Use the [generic Linux option](#linux).

0 commit comments

Comments
 (0)