GHC / GCC编译器从Stg.h发出__STDC_VERSION__ w / C99,每个包都失败了

问题描述 投票:1回答:1

每当我尝试在OSX 10.12.6和GCC 4.8.0上安装带有cabal(2.0.0)的软件包时,我遇到了关于GHC 8.2.1的Stg.h文件的以下错误,错误非常神秘。我无法在OSX上安装任何软件包。

预期行为:

cabal install $packagename应该在OSX上安装$packagename,因为cabal和cabal-install已正确安装。

观察到的行为:

由于与一个名为cabal install $packagename的变量相关的低级别GHC / GCC问题,__STDC_VERSION__失败。我不是C程序员,我不希望我正确安装GHC和cabal无法安装软件包。 AFAICT此问题与用户错误无关。

Matthew@Mattmac 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
haskell gcc cabal
1个回答
2
投票

错误非常神秘

实际上,它看起来很清楚:

error: #error __STDC_VERSION__ does not advertise C99 or later

C头文件Stg.h正在使用标准宏__STDC_VERSION__检查编译器是否支持C99(1999版标准ISO C)。由于没有相应设置,编译器不符合C99,并且C源触发错误。

基本上,Stg.h拒绝使用C编译器编译,该编译器甚至不支持18年的C标准。非常合理。

GCC 4.8确实看起来很古老:最新的海湾合作委员会是7.1。我试着将GCC升级到更新的版本,如果不是最新的版本。


更新:正如Keith Thompson在下面指出的那样,GCC 4.8,尽管它的年龄,如果通过旗帜-std=c99可以支持C99。应该有一些方法来指示cabal将这面旗帜传递给gcc,但我不记得是怎么回事。应该有一些名为cflags的选项,有些选项。

© www.soinside.com 2019 - 2024. All rights reserved.