3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stylish-haskell のインストールに手こずった件

Last updated at Posted at 2018-10-16

stylish-haskell のインストールに手こずった件

環境

  • macOS High Sierra 10.13.6
  • stack 1.7.1

経緯と対処

stylish-haskellをインストールしたい

stack install stylish-haskell

stylish-haskellを見て、上のように打って実行してみると...

問題1

  (中略)
`gcc' failed in phase `Assembler'. (Exit code: 1)

と表示されて止まってしまいました1

問題1の対処

そこで、~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルをいじります。

 [("GCC extra via C opts", " -fwrapv -fno-builtin"),
  ("C compiler command", "gcc"),
  ("C compiler flags", " -m64 -fno-stack-protector"), 
  ("C compiler link flags", " -m64 "),
- ("C compiler supports -no-pie", "YES"),
+ ("C compiler supports -no-pie", "NO"),
...

C compiler supports -no-pie の行の YESNO に変えて実行してみると...

問題2

今度は

  (中略)
   |
30 | # error __STDC_VERSION__ does not advertise C99 or later
   |   ^
`gcc' failed in phase `C Compiler'. (Exit code: 1)

と表示されて止まってしまいました。

問題2の対処

そこで再び、~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルをいじります。

 [("GCC extra via C opts", " -fwrapv -fno-builtin"),
  ("C compiler command", "gcc"),
- ("C compiler flags", " -m64 -fno-stack-protector"), 
+ ("C compiler flags", " -m64 -fno-stack-protector -std=c99"), 
  ("C compiler link flags", " -m64 "),
  ("C compiler supports -no-pie", "NO"),
...

C compiler flags の行に、 -std=c99 を追加します。
(参考) stackoverflow

問題3

さらに

Copying from /Users/user_name/.stack/global-project/.stack-work/install/x86_64-osx/lts-11.13/8.2.2/bin/stylish-haskell to /Users/tomo/.local/bin/stylish-haskell

Copied executables to /Users/user_name/.local/bin:
- stylish-haskell

Warning: Installation path /Users/user_name/.local/bin
         not found on the PATH environment variable.

と出てきてしまいました。

問題3の対処

~/.bashrc~/.zshrc 等に次の1行を追加します。

export PATH="/Users/user_name/.local/bin:$PATH"

(参考) github

まとめ

~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルの次の2行を以下のように変更すると解決しました。

変更前
 ("C compiler supports -no-pie", "YES"),
 ("C compiler flags", " -m64 -fno-stack-protector"), 
変更後
 ("C compiler supports -no-pie", "NO"),
 ("C compiler flags", " -m64 -fno-stack-protector -std=c99"), 
  1. 「問題1」のエラーメッセージが1行分しか残っていませんでした。申し訳ありません。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?