Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang.exe failed during stack build #6380

Closed
tupoiu opened this issue Dec 15, 2023 · 6 comments
Closed

Clang.exe failed during stack build #6380

tupoiu opened this issue Dec 15, 2023 · 6 comments

Comments

@tupoiu
Copy link

tupoiu commented Dec 15, 2023

General summary/comments (optional)

I am new user to Haskell, and was trying to setup a project with stack. I ran into an error using "stack build".

I am on Windows 11, and I installed the latest version of stack using ghcup.

image

Steps to reproduce

  1. ghcup stack install 2.13.1
  2. stack new project-name
  3. cd project-name
  4. stack build
  5. Clang error

I think it's likely caused by the fact that I have a space in my username (C://Peter Job/...). It could also be caused by a truncation of some PATH variable.

Expected

Stack to build me a nice little hello world executable.

Actual

This is the error

stack build -v
Version 2.13.1, Git revision 8102bb8afce90fc954f48efae38b87f37cabc988 x86_64 hpack-0.36.0
2023-12-15 21:57:28.143675: [debug] Checking for project config at: C:\Users\Peter Job\Documents\code\projects\database-project-haskell\stack.yaml
2023-12-15 21:57:28.145674: [debug] Loading project config file stack.yaml
2023-12-15 21:57:28.151330: [debug] Use of Casa server enabled: (CasaRepoPrefix "https://casa.stackage.org", 1280). 
2023-12-15 21:57:28.156345: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2023-12-14 21:57:28.156345 UTC]
2023-12-15 21:57:28.157357: [debug] Using package location completions from a lock file
2023-12-15 21:57:28.160883: [debug] Loaded snapshot from Pantry database.
2023-12-15 21:57:28.388095: [debug] Running Hpack on C:\Users\Peter Job\Documents\code\projects\database-project-haskell\package.yaml
2023-12-15 21:57:28.394998: [debug] Hpack output unchanged in C:\Users\Peter Job\Documents\code\projects\database-project-haskell\database-project-haskell.cabal
2023-12-15 21:57:28.397189: [debug] Prefetching git repos: []
2023-12-15 21:57:28.397349: [debug] []
2023-12-15 21:57:28.399893: [debug] Asking for a supported GHC version
2023-12-15 21:57:28.402894: [debug] Installed tools:
 - msys2-20230526
 - ghc-9.4.8
2023-12-15 21:57:28.402894: [debug] Potential GHC builds: standard
2023-12-15 21:57:28.403890: [debug] Found already installed GHC builds: standard
2023-12-15 21:57:28.403890: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "C:\\Users\\Peter Job\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-9.4.8\\bin\\ghc-9.4.8.exe"]
2023-12-15 21:57:28.472041: [debug] Loaded compiler information from cache
2023-12-15 21:57:28.472041: [debug] Asking for a supported GHC version
2023-12-15 21:57:28.472041: [debug] Resolving package entries
2023-12-15 21:57:28.472041: [debug] Parsing the targets
2023-12-15 21:57:28.479658: [debug] Checking flags
2023-12-15 21:57:28.480677: [debug] SourceMap constructed
2023-12-15 21:57:28.487679: [debug] Starting to execute command inside EnvConfig
2023-12-15 21:57:28.491214: [debug] Finding out which packages are already installed
2023-12-15 21:57:28.492221: [debug] Run process: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --global --no-user-package-db dump --expand-pkgroot
2023-12-15 21:57:28.562758: [debug] Process finished in 70ms: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --global --no-user-package-db dump --expand-pkgroot
2023-12-15 21:57:28.576746: [debug] Run process: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --user --no-user-package-db --package-db "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\snapshots\\f6e21c9e\\pkgdb" dump --expand-pkgroot
2023-12-15 21:57:28.616926: [debug] Process finished in 40ms: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --user --no-user-package-db --package-db "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\snapshots\\f6e21c9e\\pkgdb" dump --expand-pkgroot
2023-12-15 21:57:28.617931: [debug] Run process: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --user --no-user-package-db --package-db "C:\\Users\\Peter Job\\Documents\\code\\projects\\database-project-haskell\\.stack-work\\install\\92aec44e\\pkgdb" dump --expand-pkgroot
2023-12-15 21:57:28.656930: [debug] Process finished in 38ms: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-pkg-9.4.8.exe --user --no-user-package-db --package-db "C:\\Users\\Peter Job\\Documents\\code\\projects\\database-project-haskell\\.stack-work\\install\\92aec44e\\pkgdb" dump --expand-pkgroot
2023-12-15 21:57:28.657935: [debug] Constructing the build plan
2023-12-15 21:57:28.659459: [debug] Checking if we are going to build multiple executables with the same name       
2023-12-15 21:57:28.659459: [debug] Executing the build plan
2023-12-15 21:57:28.661476: [debug] Run process within C:\Users\Peter Job\AppData\Local\Temp\stack-3c77eb37934e8913\: C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-9.4.8.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.8.1.0 "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-src\\setup-9p6GVs8J.hs" "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-src\\setup-shim-9p6GVs8J.hs" -o "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-cache\\x86_64-windows\\tmp-Cabal-simple_9p6GVs8J_3.8.1.0_ghc-9.4.8.exe"
clang: error: no such file or directory: 'Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\lib\../mingw/include'

C:\Users\Peter Job\AppData\Roaming\stack\setup-exe-src\setup-shim-9p6GVs8J.hs:1:1: error:
    `clang.exe' failed in phase `C pre-processor'. (Exit code: 1)
  |
1 | {-# LANGUAGE CPP            #-}
  | ^
2023-12-15 21:57:29.193680: [debug] Checking for project config at: C:\Users\Peter Job\Documents\code\projects\database-project-haskell\stack.yaml
2023-12-15 21:57:29.194806: [debug] Loading project config file stack.yaml
2023-12-15 21:57:29.197471: [debug] Use of Casa server enabled: (CasaRepoPrefix "https://casa.stackage.org", 1280). 
2023-12-15 21:57:29.200987: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2023-12-14 21:57:29.2009879 UTC]
2023-12-15 21:57:29.202989: [error]
Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       C:\Users\Peter Job\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.8\bin\ghc-9.4.8.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.8.1.0 "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-src\\setup-9p6GVs8J.hs" "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-src\\setup-shim-9p6GVs8J.hs" -o "C:\\Users\\Peter Job\\AppData\\Roaming\\stack\\setup-exe-cache\\x86_64-windows\\tmp-Cabal-simple_9p6GVs8J_3.8.1.0_ghc-9.4.8.exe"
       Process exited with code: ExitFailure 1

Stack version

stack --version
Version 2.13.1, Git revision 8102bb8afce90fc954f48efae38b87f37cabc988 x86_64 hpack-0.36.0

Method of installation

  • Via GHCup

Platform

Omen Laptop 15, 16GB RAM, x64, Windows 11 Home

@mpilgrem
Copy link
Member

mpilgrem commented Dec 15, 2023

@tupoiu, I am also a Windows 11 user. I gave up a user name with a space on Windows some years ago, in order to be able to use Stack. See the last paragraph of https://docs.haskellstack.org/en/stable/faq/#how-to-get-a-working-executable-on-windows and #4726. EDIT: That paragraph was written before GHC on Windows moved (GHC 9.4.1) to a fully Clang-based C toolchain, which may be why it does not mention clang.exe expressly.

@mpilgrem
Copy link
Member

mpilgrem commented Dec 15, 2023

This looks to me like an upstream error with GHC. With paths with spaces in them, I suspect that GHC is not quoting them before passing them to clang.exe. I'll raise an issue at GHC's repository. EDIT: https://gitlab.haskell.org/ghc/ghc/-/issues/24265

@mpilgrem
Copy link
Member

mpilgrem commented Dec 15, 2023

I am going to close this issue, as there is nothing Stack itself can do. If you do not want to change your user name on Windows, the workaround is to configure Stack to put its 'programs' directory in a location that does not have a space on its path. See the non-project specific configuration option: https://docs.haskellstack.org/en/stable/yaml_configuration/#local-programs-path.

@tupoiu
Copy link
Author

tupoiu commented Dec 16, 2023

There is a simple workaround based on the documentation you've given me:

To the stack.yaml file in my project, I add the line:

local-programs-path: C://stack. This installs GHC at the top level.

image

@mpilgrem
Copy link
Member

@tupoiu, that is correct. However, because you want that non-project specific configuration option to apply to all of your Stack projects, you should put it in your config.yaml file in your Stack root (likely C:\sr\config.yaml).

@mpilgrem
Copy link
Member

The GHC issue https://gitlab.haskell.org/ghc/ghc/-/issues/24265 has been closed as fixed, so this should be resolved in some future version of GHC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants