12

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?

oarfish
  • 4,116
  • 4
  • 37
  • 66
Etienne Bernard
  • 123
  • 1
  • 5
  • 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`). – Raveline May 17 '18 at 10:03
  • Did you try updating Xcode to the latest version (this will also update clang)? – David Young May 17 '18 at 18:49
  • 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. :) – Etienne Bernard May 18 '18 at 18:25

1 Answers1

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

Searge
  • 465
  • 1
  • 9
  • 14
  • 1
    Spend 3 days on it and still can't make SublimeHaskell works properly – Searge May 20 '18 at 20:30
  • 1
    Just setting -no-pie to "NO" did it for me (everything else works with clang). Thanks! – Felixyz May 20 '18 at 21:45
  • 3
    managed to fix that warning by editing `settings` in `~/.stack/programs/...` folder. This is where stack installs `ghc` to isolate it from system `ghc` – oluckyman Jun 20 '18 at 10:36