- M1 맥북프로에서, elm-format이 때로 느리게 반응한다.
- 찾아보니, 기본 설치되는 elm-format은 x86바이너리다.
- M1용으로 바이너리를 만들면 빨라지지 않을까?
- 해당 이슈를 검색해보니 avh4/elm-format#723 여기에 이미 언급됨.
- 여러 이유로 아직 m1바이너리는 배포되고 있지 않지만, 로컬에서 따로 빌드할 수는 있겠다.
# Install ghc
ghcup install ghc 9.0.2
ghcup set ghc 9.0.2
# Get elm-format source code
git clone https://github.com/avh4/elm-format
cd elm-format
git switch --detach 15578927a7fd327abd9c619031243c0abe96c57b
# Build elm-format
./build.sh -- build
위, elm-format개발자의 설명을 보면, 로컬에서 elm-format을 빌드하는 방법이 안내되어있다. 내 M1 맥북의 경우, 해당 커맨드를 실행하면,
- cabal이 없었다.
- #include "ffitarget_arm64.h" 가 없다고 나왔다.
- unhandled operating system: ("darwin","aarch64") 오류가 나왔다.
위 문제를 해결하기 위해
$ ghcup install cabal
$ export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi"
이렇게 해주면, cabal을 실행하는 것까지는 되고, 그다음 3번 문제를 해결하기 위해서는, Shakefiles/Platform.hs
파일의 22번째 줄을 아래와 같이 편집했다.
platform :: Platform
platform =
case (System.Info.os, System.Info.arch) of
("linux", "x86_64") -> Linux
("darwin", "x86_64") -> Mac
("darwin", "aarch64") -> Mac -- 이 라인 추가
("osx", "x86_64") -> Mac
("mingw32", "x86_64") -> Windows
("win32", "x86_64") -> Windows
other -> error ("unhandled operating system: " ++ show other)
그런 다음
$ ./build.sh -- build
로 elm-format을 빌드하면, 약 8분정도 소요해서 _build/elm-format
바이너리가 생성됨.
해당 바이너리를 /usr/local/bin/
등에 복사해두고 사용하자.
- 현재 작업하는 소스 기준, 기존 x86용 elm-format보다 약 4배 정도 빠르게 작동한다.