简体   繁体   English

`gcc.exe' 在 /dist-newstyle/ 文件夹中的 `C 预处理器' 阶段失败错误消息

[英]`gcc.exe' failed in phase `C pre-processor' error message in /dist-newstyle/ folder

I have this project on a subject 'Languages and Compilers' Where we write parsers in Haskell.我有一个主题为“语言和编译器”的项目,我们用 Haskell 编写解析器。 At the moment I'm working on this 2-Arrow project where we use the 'alex' and 'happy' libraries to create a parser.hs and lexer.hs file from a lexer.x and parser.y file.目前我正在研究这个2-Arrow项目,我们使用“alex”和“happy”库从 lexer.x 和 parser.y 文件创建 parser.hs 和 lexer.hs 文件。 While trying to build my framework ( cabal build in the project directory) I get the following error message:在尝试构建我的框架(项目目录中的cabal build )时,我收到以下错误消息:

C:\\ ... \2-Arrow\dist-newstyle\build\x86_64-windows\ghc-9.2.4\assignment-arrow-0.1.0.0\x\arrow\build\arrow\arrow-tmp\Lexer.hs:1:1: error:
    `gcc.exe' failed in phase `C pre-processor'. (Exit code: 1)
  |
 1| {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}
  | ^

C:\\ ... \2-Arrow\dist-newstyle\build\x86_64-windows\ghc-9.2.4\assignment-arrow-0.1.0.0\x\arrow\build\arrow\arrow-tmp\Parser.hs:1:1: error:
    `gcc.exe' failed in phase `C pre-processor'. (Exit code: 1)
  |
1 | {-# OPTIONS_GHC -w #-}  
  | ^

If they were error messages originating from the code I wrote I would at least have a direction to look for solutions, but these errors come from the /dist-newstyle/ folder.如果它们是源自我编写的代码的错误消息,我至少会找到寻找解决方案的方向,但这些错误来自/dist-newstyle/文件夹。 Which, in my understanding, is a folder for intermediate files used in building the program.据我了解,这是用于构建程序的中间文件的文件夹。 So I'm kind of at a dead end at the moment, since reinstalling 'happy' and 'alex', and updating cabal to latest version all did not change anything.所以我现在有点陷入死胡同,因为重新安装“happy”和“alex”,并将 cabal 更新到最新版本都没有改变任何东西。 Does anyone have any advice for resolving this error?有人对解决此错误有任何建议吗? Any help is greatly appreciated!!任何帮助是极大的赞赏!!

(project framework from uni: https://www.cs.uu.nl/docs/vakken/b3tc/downloads-2018/2-Arrow.zip (depends on 'happy' and 'alex' packages). At first I thought the problem could lay in the framework, but I checked with the professor, he stated that others had no issues, so I don't think that's the problem) (来自uni的项目框架: https ://www.cs.uu.nl/docs/vakken/b3tc/downloads-2018/2-Arrow.zip(取决于'happy'和'alex'包)。起初我以为问题可能出在框架上,但我问了教授,他说其他人没有问题,所以我认为不是问题所在)

I wasn't able to duplicate the problem with a fresh GHCup installation on Windows 10, but the error message suggests there might be an issue with an installed version of the GNU C Compiler (GCC) which the Glasgow Haskell Compiler (GHC) invokes to apply the C pre-processor to certain Haskell source files, including the Lexer.hs source file that's being generated by Alex from the Lexer.x file, and the Parser.hs source file that's being generated by Happy from the Parser.y file.我无法通过在 Windows 10 上全新安装 GHCup 来重现该问题,但错误消息表明 Glasgow Haskell 编译器 (GHC) 调用的已安装 GNU C 编译器 (GCC) 版本可能存在问题将 C 预处理器应用于某些 Haskell 源文件,包括 Alex 从Lexer.x文件生成的Lexer.hs源文件,以及 Happy 从Parser.y文件生成的Parser.hs源文件。

Try creating a simple test.hs program that invokes the C pre-processor:尝试创建一个调用 C 预处理器的简单test.hs程序:

{-# LANGUAGE CPP #-}
#define HELLO "Hello, world!"
main = putStrLn HELLO

and try compiling with ghc test.hs .并尝试使用ghc test.hs进行编译。 Assuming that fails with the same error as above, try ghc -v test.hs , and you should find lines in the output starting with:假设失败并出现与上述相同的错误,请尝试ghc -v test.hs ,您应该在输出中找到以以下内容开头的行:

*** C pre-processor
"C:\...\gcc.exe" "-E" "-undef" ...blah blah blah...

An excerpt from my successful compilation follows.下面是我成功编译的摘录。 Maybe you can spot what's going wrong with your installation.也许您可以发现您的安装出了什么问题。 Note that mine invokes the GHCup-installed version of GCC and directs the output to a temporary file area where it's then compiled by GHC.请注意,我的调用 GHCup 安装版本的 GCC 并将输出定向到一个临时文件区域,然后由 GHC 对其进行编译。 If the wrong GCC is invoked or the temporary file area isn't writable for some reason, that might lead to the problem you're seeing.如果调用了错误的 GCC 或者临时文件区域由于某种原因不可写,这可能会导致您看到的问题。

*** C pre-processor:
"C:\ghcup\ghc\9.2.5\lib\../mingw/bin/gcc.exe" "-E" "-undef" "-traditional" "-IC:\ghcup\ghc\9.2.5\lib\x86_64-windows-ghc-9.2.5\base-4.16.4.0\include" "-IC:\ghcup\ghc\9.2.5\lib\x86_64-windows-ghc-9.2.5\ghc-bignum-1.2\include" "-IC:\ghcup\ghc\9.2.5\lib\x86_64-windows-ghc-9.2.5\rts-1.0.2\include" "-include" "C:\ghcup\ghc\9.2.5\lib\x86_64-windows-ghc-9.2.5\rts-1.0.2\include\ghcversion.h" "-Dmingw32_BUILD_OS" "-Dx86_64_BUILD_ARCH" "-Dmingw32_HOST_OS" "-Dx86_64_HOST_ARCH" "-D__GLASGOW_HASKELL_TH__" "-D__SSE__" "-D__SSE2__" "-D__IO_MANAGER_WINIO__=1" "-D__IO_MANAGER_MIO__=1" "-includeC:\Users\buhr\AppData\Local\Temp\ghc7128_0\ghc_2.h" "-x" "assembler-with-cpp" "test.hs" "-o" "C:\Users\buhr\AppData\Local\Temp\ghc7128_0\ghc_1.hscpp"
!!! systool:cpp: finished in 31.25 milliseconds, allocated 0.311 megabytes
!!! Chasing dependencies: finished in 46.88 milliseconds, allocated 2.719 megabytes
Stable obj: {}
Stable BCO: {}
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = 2022-12-18 20:54:57.2679991 UTC
         ms_mod = Main,
         ms_textual_imps = [(Nothing, Prelude)]
         ms_srcimps = []
      } []]
*** Deleting temp files:
Deleting: C:\Users\buhr\AppData\Local\Temp\ghc7128_0\ghc_2.h
compile: input file C:\Users\buhr\AppData\Local\Temp\ghc7128_0\ghc_1.hscpp
*** Checking old interface for Main (use -ddump-hi-diffs for more details):
[1 of 1] Compiling Main             ( test.hs, test.o )

I went to my seminar and asked the TA for help.我去了我的研讨会并向助教寻求帮助。 After some time he proposed that maybe the folder location was the problem.一段时间后,他提出也许文件夹位置是问题所在。 Lo and behold, after moving the folder from my OneDrive folder (which is also saved locally) to my C:\\ directory, the project finally compiled, I have no idea why this would be the case, so I have posted another question here Folder location makes Haskell project incompileable .你看,将文件夹从我的 OneDrive 文件夹(也保存在本地)移动到我的C:\\目录后,项目终于编译了,我不知道为什么会这样,所以我在这里发布了另一个问题文件夹位置使 Haskell 项目无法编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM