cabal install `gcc' failed in phase `C Compiler'
Asked Answered
A

1

13

I want to use parsec for a personal project. But when I invoke cabal install parsec, I get an error:

clang: error: unknown argument: '-no-pie'
gcc' failed in phase `C Compiler'. (Exit code: 1)

I am on OS X El Capitan, 10.11.6. If I have understood correctly he error message above, gcc seems to be the cause. When I check the version of gcc, I get

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Besides, I have read this `gcc.exe' failed in phase `C Compiler'. (Exit code: 1) and after stack setup--reinstall, stack install parsec worked very well. But cabal always not. Can you help me?

Allegiance answered 17/5, 2018 at 8:30 Comment(3)
If you can install through Slack, why are you trying to install it through cabal ? Have you put parsec as a dependency of your project ? (In the cabal file or package.yaml file, depending on which version of Slack you use) In which case, you should be able to use parsec as a dependency (or test it in an interpreter launched using stack ghci).Selmner
Did you try updating Xcode to the latest version (this will also update clang)?Heard
Thank you for your kind replies. David Young> I must update the computer system in order to update Xcode. I will try it after exam time. :)Allegiance
W
17

I had the same problem in the same time :-)

Most answers I’ve found on stackoverflow is about to update Xcode.

But! I’ve seen that suggestions since 2013, and in that case, I can’t update Xcode, because I have old Macbook and OS X 10.11 on it, i have tried: brew install gcc Next step I wondering how to setup Gnu C Compler over Xcode and found right now how. Open in terminal with your fav. editor:

mate /Library/Frameworks/GHC.framework/Versions/8.4.2-x86_64/usr/lib/ghc-8.4.2/settings

And change this:

, ("C compiler command","gcc")
, ("C compiler flags"," -fno-stack-protector")
, ("C compiler link flags"," ")
, ("C compiler supports -no-pie","YES")
, ("Haskell CPP command","gcc")

with /usr/local/bin/gcc-8 instead gcc & "NO" instead "YES»

Hope it helps <3

Waylan answered 18/5, 2018 at 20:51 Comment(3)
Spend 3 days on it and still can't make SublimeHaskell works properly 😓Waylan
Just setting -no-pie to "NO" did it for me (everything else works with clang). Thanks!Hadria
managed to fix that warning by editing settings in ~/.stack/programs/... folder. This is where stack installs ghc to isolate it from system ghcCarnotite

© 2022 - 2024 — McMap. All rights reserved.