tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

Ormolu 0.5.0.0 fails to build on M1 Macs #898

Closed i-am-tom closed 2 years ago

i-am-tom commented 2 years ago

Describe the bug

... Or, at least, I think it does. I've so far checked it on an M1 Pro, and received much the same output as this. Specifically, everything seems to build happily until the executable:

Configuring executable 'ormolu' for ormolu-0.5.0.0..
Preprocessing executable 'ormolu' for ormolu-0.5.0.0..
Building executable 'ormolu' for ormolu-0.5.0.0..
[1 of 2] Compiling Paths_ormolu     ( /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/autogen/Paths_ormolu.hs, /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/ormolu-tmp/Paths_ormolu.o, /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/ormolu-tmp/Paths_ormolu.dyn_o )
[2 of 2] Compiling Main             ( app/Main.hs, /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/ormolu-tmp/Main.o, /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/ormolu-tmp/Main.dyn_o )
Linking /Users/tom/Git/ormolu/dist-newstyle/build/aarch64-osx/ghc-8.10.7/ormolu-0.5.0.0/x/ormolu/build/ormolu/ormolu ...
clang-11: error: unable to execute command: Segmentation fault: 11
clang-11: error: linker command failed due to signal (use -v to see invocation)
`clang' failed in phase `Linker'. (Exit code: 254)

To Reproduce

Assuming I'm correct, then run the following on an M1 Mac:

Expected behavior The build should complete successfully.

Environment

Additional context The error was originally encountered after finding the linked homebrew error when 0.5.0.0 wasn't found on Brew.

asarkar commented 2 years ago

+1, same issue using an M1 Pro.

hvpaiva commented 2 years ago

+1 too, same with an M1.

using cabal install ormolu

Configuring executable 'ormolu' for ormolu-0.5.0.0..
Preprocessing executable 'ormolu' for ormolu-0.5.0.0..
Building executable 'ormolu' for ormolu-0.5.0.0..
[1 of 2] Compiling Paths_ormolu     ( dist/build/ormolu/autogen/Paths_ormolu.hs, dist/build/ormolu/ormolu-tmp/Paths_ormolu.o, dist/build/ormolu/ormolu-tmp/Paths_ormolu.dyn_o )
[2 of 2] Compiling Main             ( app/Main.hs, dist/build/ormolu/ormolu-tmp/Main.o, dist/build/ormolu/ormolu-tmp/Main.dyn_o )
Linking dist/build/ormolu/ormolu ...
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 254)
cabal: Failed to build exe:ormolu from ormolu-0.5.0.0. See the build log above
for details.

and using stack install ormolu :

Linking /Users/XXX/.stack/setup-exe-cache/aarch64-osx/tmp-Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 ...
ld: warning: ignoring file /Users/XXX/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ld: warning: ignoring file /Users/XXX/.stack/setup-exe-src/setup-mPHDZzAJ.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
Undefined symbols for architecture arm64:
  "_ZCMain_main_closure", referenced from:
      _main in ghc_2.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building simple Setup.hs (scroll up to its section to see the error) using:
      /Users/XXX/.stack/programs/aarch64-osx/ghc-9.0.2/bin/ghc-9.0.2 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.4.1.0 /Users/XXX/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/XXX/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/XXX/.stack/setup-exe-cache/aarch64-osx/tmp-Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2
    Process exited with code: ExitFailure 1

To Reproduce

Assuming we are correct, then run the following on an M1 Mac:

cabal install ormolu or stack install ormolu

Expected behavior

The build should complete successfully.

Environment

Apple macOS Monterey 12.4 on an M1 chip Tested with 0.5.0.0 and HEAD

amesgen commented 2 years ago

Just to make sure: Is this Ormolu-specific, or does this also happen with other tools (i.e. hlint, stylish-haskell, etc.)?

asarkar commented 2 years ago

hlint is fine for me, haven't tried stylish-haskell.

hvpaiva commented 2 years ago

Just to make sure: Is this Ormolu-specific, or does this also happen with other tools (i.e. hlint, stylish-haskell, etc.)?

Just Ormolu for me. I installed both HLint and stylish-haskell successfully.

sourabhxyz commented 2 years ago

Just to make sure: Is this Ormolu-specific, or does this also happen with other tools (i.e. hlint, stylish-haskell, etc.)?

Just Ormolu for me. I installed both HLint and stylish-haskell successfully.

Exactly same here.

sourabhxyz commented 2 years ago

Though, latest binary on release page is working fine on my M1 system ✌️

hvpaiva commented 2 years ago

I managed to install today via cabal install ormolu too! 🙌

i-am-tom commented 2 years ago

Looks good for me, too! Thanks!