2017-12-31 266 views
0

OSX 10.12.6とGCC 4.8.0でcabal(2.0.0)を使用してパッケージをインストールしようとするたびに、 GHC 8.2.1のStg.hファイルに関する次のエラーは、このエラーは非常に謎です。私はOSXにパッケージをインストールすることはできません。GHC/GCCコンパイラの問題Stg.hのC99と__STDC_VERSION__、すべてのパッケージで失敗する

期待される動作:秘密結社と徒党を組んで、インストールが正しくインストールされているので、

cabal install $packagenameは、OSX上$packagenameをインストールする必要があります。

観察された行動:

cabal install $packagenameが原因__STDC_VERSION__という変数に関連する低レベルGHC/GCCの問題に失敗しました。私はCのプログラマーではないし、GHCとcabalを正しくインストールしてもパッケージをインストールできないとは思わない。 AFAICTこの問題はユーザーエラーとは関係ありません。

[email protected] git:the_D*+ ~/Projects/kata/euler>cabal update && cabal 
install optparse-applicative 
Downloading the latest package list from hackage.haskell.org 
gcc: warning: couldn’t understand kern.osversion ‘16.7.0 
gcc: warning: couldn’t understand kern.osversion ‘16.7.0 
Warning: --root-cmd is no longer supported, see 
https://github.com/haskell/cabal/issues/3353 (if you didn't type --root-cmd, 
comment out root-cmd in your ~/.cabal/config file) 
Resolving dependencies... 
Downloading transformers-compat-0.5.1.4... 
Configuring colour-2.3.4... 
Configuring transformers-compat-0.5.1.4... 
Building colour-2.3.4... 
Building transformers-compat-0.5.1.4... 
Failed to install transformers-compat-0.5.1.4 
Build log (/Users/Matthew/.cabal/logs/ghc-8.2.1/transformers-compat-0.5.1.4-HHfl4KyHCH71PMx2CRgdve.log): 
cabal: Entering directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91946/transformers-compat-0.5.1.4' 
Configuring transformers-compat-0.5.1.4... 
gcc: warning: couldn’t understand kern.osversion ‘16.7.0 
Preprocessing library for transformers-compat-0.5.1.4.. 
Building library for transformers-compat-0.5.1.4.. 
[1 of 2] Compiling Control.Monad.Trans.Instances (src/Control/Monad/Trans/Instances.hs, dist/build/Control/Monad/Trans/Instances.o) 
[2 of 2] Compiling Paths_transformers_compat (dist/build/autogen/Paths_transformers_compat.hs, dist/build/Paths_transformers_compat.o) 
[1 of 2] Compiling Control.Monad.Trans.Instances (src/Control/Monad/Trans/Instances.hs, dist/build/Control/Monad/Trans/Instances.p_o) 
In file included from /Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Rts.h:30:0: error: 
    0, 
        from /var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/ghc92089_0/ghc_7.c:2: 

/Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Stg.h:30:3: error: 
    error: #error __STDC_VERSION__ does not advertise C99 or later 
    # error __STDC_VERSION__ does not advertise C99 or later 
    ^
    | 
30 | # error __STDC_VERSION__ does not advertise C99 or later 
    | ^
`gcc' failed in phase `C Compiler'. (Exit code: 1) 
cabal: Leaving directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91946/transformers-compat-0.5.1.4' 
Failed to install colour-2.3.4 
Build log (/Users/Matthew/.cabal/logs/ghc-8.2.1/colour-2.3.4-9c0ktEQZfar3Wigr5kT6BU.log): 
cabal: Entering directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91945/colour-2.3.4' 
Configuring colour-2.3.4... 
Preprocessing library for colour-2.3.4.. 
Building library for colour-2.3.4.. 
[ 1 of 14] Compiling Data.Colour.CIE.Chromaticity ( 
Data/Colour/CIE/Chromaticity.hs, dist/build/Data/Colour/CIE/Chromaticity.o) 
... 
[ 1 of 14] Compiling Data.Colour.CIE.Chromaticity (Data/Colour/CIE/Chromaticity.hs, dist/build/Data/Colour/CIE/Chromaticity.p_o) 

In file included from /Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Rts.h:30:0: error: 
    0, 
        from /var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/ghc92201_0/ghc_3.c:2: 

/Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Stg.h:30:3: error: 
    error: #error __STDC_VERSION__ does not advertise C99 or later 
    # error __STDC_VERSION__ does not advertise C99 or later 
    ^
    | 
30 | # error __STDC_VERSION__ does not advertise C99 or later 
    | ^
`gcc' failed in phase `C Compiler'. (Exit code: 1) 
cabal: Leaving directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91945/colour-2.3.4' 
cabal: Error: some packages failed to install: 
ansi-terminal-0.7.1.1-3eOIKoB8mo97DkHMJ6AgBw depends on ansi-terminal-0.7.1.1 
which failed to install. 
ansi-wl-pprint-0.6.8.1-Ctcte9oFd5tFGoIV7u576g depends on 
ansi-wl-pprint-0.6.8.1 which failed to install. 
colour-2.3.4-9c0ktEQZfar3Wigr5kT6BU failed during the building phase. The 
exception was: 
ExitFailure 1 
optparse-applicative-0.14.0.0-Iaq7kOKFg2Z4XsKvk269H6 depends on 
optparse-applicative-0.14.0.0 which failed to install. 
transformers-compat-0.5.1.4-HHfl4KyHCH71PMx2CRgdve failed during the building phase. The exception was: 
ExitFailure 1 

答えて

2

エラーが実際に、それはかなり明確に見える

非常に不可解です:

error: #error __STDC_VERSION__ does not advertise C99 or later 

CヘッダファイルStg.hは、コンパイラはC99(1999バージョンをサポートしているかどうかをチェックしています標準ISO Cの)を使用して、標準マクロ__STDC_VERSION__を使用します。それに応じて設定されていないので、コンパイラはC99に準拠しておらず、Cソースはエラーをトリガします。

基本的に、Stg.hは、18歳のC標準をサポートしていないCコンパイラでコンパイルするのを拒否します。かなり合理的。

GCC 4.8は確かに古く見えます。最新のGCCは7.1です。私は、最新ではないにしても、GCCをより新しいバージョンにアップグレードしようとしています。


更新:キース・トンプソンは、以下の指摘するようにフラグ-std=c99を渡された場合、GCC 4.8は、その年齢にもかかわらず、C99をサポートすることができます。 にこのフラグをgccに渡すように指示する方法があるはずですが、どのように覚えていないのですか。これにはcflagsという名前のオプションがいくつかあります。

+0

エラーはHaskellやインストールとは関係がないので、インストールされているシステムの周辺にエラーがあると私は主張します。 GCC 4.2/4.8はエンタープライズシステムでは日常的に使用されており、バージョン要件はHaskellシステムのドキュメントには記載されていません(古いバージョンのGHCではghciスタンドアロンで、新しいスタンドアロンではLLVMがあります)。 'brew upgrade gcc'とエイリアシングgccがこの問題を解決しました。ありがとう@chi – W4t3randWind

+2

gccをアップグレードする必要はありません。 gcc 4.8.0は2013年にリリースされました。デフォルトではC99 *をサポートしていません。 '-std = c99'(C99をサポートする)または' -std = gnu99'(GNU拡張を使ってC99をサポートする)で呼び出すだけです。デフォルトの言語バージョンは '-std = gnu89'です。最近のリリースでは、デフォルトは '-std = gnu11'です。 (しかし、とにかくgccをアップグレードしたのであれば、それも解決するはずです。) –

+0

@KeithThompsonああ、そうです。それは素晴らしいアドバイスです。私はカバルをその旗を渡すように説得する方法を覚えていないが、それは実行可能でなければならない。 – chi

関連する問題