proteaaudio icon indicating copy to clipboard operation
proteaaudio copied to clipboard

Fail to build on M1 Mac

Open kristiansordal opened this issue 1 year ago • 9 comments

Running cabal install proteaaudio on M1 Mac gives the following error:

Resolving dependencies...
Build profile: -w ghc-9.4.2 -O1
In order, the following will be built (use -v for more details):
 - proteaaudio-0.9.4 (lib) (requires build)
Starting     proteaaudio-0.9.4 (lib)
Building     proteaaudio-0.9.4 (lib)

Failed to build proteaaudio-0.9.4.
Build log (
/Users/kristiansordal/.cabal/logs/ghc-9.4.2/prtd-0.9.4-c9cfa97b.log ):
Configuring library for proteaaudio-0.9.4..
Preprocessing library for proteaaudio-0.9.4..
Building library for proteaaudio-0.9.4..
[1 of 1] Compiling Sound.ProteaAudio ( dist/build/Sound/ProteaAudio.hs, dist/build/Sound/ProteaAudio.o, dist/build/Sound/ProteaAudio.dyn_o )
g++: error: unrecognized command-line option '--target=arm64-apple-darwin'
`g++' failed in phase `C++ Compiler'. (Exit code: 1)
Error: cabal: Failed to build proteaaudio-0.9.4. See the build log above for
details.

Unsure how to go about fixing this, any help is appreciated.

kristiansordal avatar Apr 25 '23 11:04 kristiansordal

It seems to be a GHC/GCC tooling issue. I do not have a mac, but I'd suggest to google this error message: g++: error: unrecognized command-line option '--target=arm64-apple-darwin'

csabahruska avatar Apr 25 '23 12:04 csabahruska

I tried compiling a regular C++ file with this flag, and got the same error, but I can't seem to find much information on google.

Compiling with the flag -march=native seems to be a better flag to use in this case, but I'm unsure how to change it.

kristiansordal avatar Apr 25 '23 12:04 kristiansordal

Try to use stack. It seems to work for others: https://www.reddit.com/r/haskell/comments/w3o6vg/m1_mac_with_ghc/

csabahruska avatar Apr 25 '23 12:04 csabahruska

~~Seems that stack doesn't recognize proteaaudio. This occured after running stack update.~~

~~Using Cabal would be ideal, as the project I need this project for is a Cabal project. If theres a workaround to get cabal to see packages downloaded from stack, then using stack is not a problem.~~

~~I appreciate the quick help given so far! Hopefully this works out :)~~

EDIT: I wrote the package name wrong lol

kristiansordal avatar Apr 25 '23 12:04 kristiansordal

Do you know how to use stack? Did it work?

csabahruska avatar Apr 25 '23 13:04 csabahruska

Sadly did not work. I was met with the following error.

After specifying the suggested flags -O0 and -passes='default<O#>,other-pass, it still didnt' work.

❯ stack install proteaaudio
alex       > configure
alex       > Configuring alex-3.2.7.1...
alex       > build
dlist      > configure
alex       > Preprocessing executable 'alex' for alex-3.2.7.1..
alex       > Building executable 'alex' for alex-3.2.7.1..
dlist      > Configuring dlist-1.0...
dlist      > build
happy      > configure
dlist      > Preprocessing library for dlist-1.0..
dlist      > Building library for dlist-1.0..
alex       > [ 1 of 22] Compiling Data.Ranged.Boundaries
dlist      > [1 of 5] Compiling Data.DList.Internal
alex       > Cannot specify -O# and --passes=/--foo-pass, use -passes='default<O#>,other-pass'
alex       > `opt' failed in phase `LLVM Optimiser'. (Exit code: 1)
happy      > Configuring happy-1.20.0...
happy      > build
dlist      > Cannot specify -O# and --passes=/--foo-pass, use -passes='default<O#>,other-pass'
dlist      > `opt' failed in phase `LLVM Optimiser'. (Exit code: 1)
happy      > Preprocessing executable 'happy' for happy-1.20.0..
happy      > Building executable 'happy' for happy-1.20.0..
happy      > [ 1 of 19] Compiling AbsSyn
happy      > Cannot specify -O# and --passes=/--foo-pass, use -passes='default<O#>,other-pass'
happy      > `opt' failed in phase `LLVM Optimiser'. (Exit code: 1)
Progress 3/6

--  While building package happy-1.20.0 (scroll up to its section to see the error) using:
      /Users/kristiansordal/.stack/setup-exe-cache/aarch64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --verbose=1 --builddir=.stack-work/dist/aarch64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1


--  While building package dlist-1.0 (scroll up to its section to see the error) using:
      /Users/kristiansordal/.stack/setup-exe-cache/aarch64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --verbose=1 --builddir=.stack-work/dist/aarch64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1


--  While building package alex-3.2.7.1 (scroll up to its section to see the error) using:
      /Users/kristiansordal/.stack/setup-exe-cache/aarch64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --verbose=1 --builddir=.stack-work/dist/aarch64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    

I'll keep trying and update if I manage to fix it.

kristiansordal avatar Apr 25 '23 13:04 kristiansordal

Could please you try the following commands?

git clone https://github.com/csabahruska/proteaaudio
cd proteaaudio/proteaaudio
stack build
stack exec proteaaudio-play

csabahruska avatar Apr 26 '23 07:04 csabahruska

how is it going?

csabahruska avatar Apr 28 '23 14:04 csabahruska

I couldn't get it working. I ended up using SDL and SDL Mixer along with Data.WAVE instead.

kristiansordal avatar Apr 28 '23 15:04 kristiansordal