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

Regression in 2.15.7 #6621

Closed
lehins opened this issue Jul 12, 2024 · 7 comments
Closed

Regression in 2.15.7 #6621

lehins opened this issue Jul 12, 2024 · 7 comments

Comments

@lehins
Copy link
Contributor

lehins commented Jul 12, 2024

General summary/comments (optional)

I suspect #6542 introduced a regression, although I might be wrong. Problem happens with LTS-18 and older (was able to reproduce all the way to LTS-11)

Problem happens when building a package that depends on doctest, which depends on ghc-paths and that is where problem seems to pop up:

ghc-paths  > [1 of 2] Compiling Main             ( /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/Setup.hs, /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/Main.o )
ghc-paths  > [2 of 2] Compiling StackSetupShim   ( /home/lehins/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs, /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/StackSetupShim.o )
ghc-paths  > 
ghc-paths  > /home/lehins/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs:10:1: error:
ghc-paths  >     parse error on input ‘import’
ghc-paths  >    |
ghc-paths  > 10 | import Data.List ( stripPrefix )
ghc-paths  >    | ^^^^^^

I was able to confirm that stack-2.15.5 and earlier do not have this problem

Steps to reproduce

$ ghcup install stack 2.15.7
$ ghcup set stack 2.15.7
$ git clone https://github.com/lehins/massiv
$ cd massiv
$ git reset --hard 026df670503ef7d7de77fa8a8691782c62618039
$ stack test --no-run-tests --stack-yaml stack.ghc-8.10.7.yaml 
....
        
ghc-paths  > configure
ghc-paths  > [1 of 2] Compiling Main             ( /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/Setup.hs, /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/Main.o )
ghc-paths  > [2 of 2] Compiling StackSetupShim   ( /home/lehins/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs, /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/StackSetupShim.o )
ghc-paths  > 
ghc-paths  > /home/lehins/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs:10:1: error:
ghc-paths  >     parse error on input ‘import’
ghc-paths  >    |
ghc-paths  > 10 | import Data.List ( stripPrefix )
ghc-paths  >    | ^^^^^^
Progress 1/6

Error: [S-7282]
       Stack failed to execute the build plan.
       
       While executing the build plan, Stack encountered the error:
       
       [S-7011]
       While building package ghc-paths-0.1.0.12 (scroll up to its section to see the error) using:
       /home/lehins/.ghcup/ghc/8.10.7/bin/ghc --make -odir /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup -hidir /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup -i -i. -clear-package-db -global-package-db -package-db=/home/lehins/.stack/snapshots/x86_64-linux/68fff3243d98d9c862e3c86021fe4f03a8d73b9a01c3c73a570ab9f0b84b1e6e/8.10.7/pkgdb -package-db=/home/lehins/tmp/massiv/.stack-work-root/install/x86_64-linux/68fff3243d98d9c862e3c86021fe4f03a8d73b9a01c3c73a570ab9f0b84b1e6e/8.10.7/pkgdb -hide-all-packages -package-id=Cabal-3.2.1.0 -package-id=base-4.14.3.0 -package-id=directory-1.3.6.0 -optP-include -optP/tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/setup_macros.h /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/Setup.hs /home/lehins/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs -main-is StackSetupShim.mainOverride -o /tmp/stack-078a762c6f3e0bc1/ghc-paths-0.1.0.12/.stack-work-root/dist/x86_64-linux/ghc-8.10.7/setup/setup -threaded -haddock
       Process exited with code: ExitFailure 1 

Expected

No build failure.

Actual

Build failure

If you suspect that a Stack command misbehaved, please include the output of
that command in --verbose mode. If the output is larger than a page please
paste the output in a Gist.

stack <your command here> <args> --verbose
<output>

Stack version

$ stack --version
Version 2.15.7, Git revision 75bb479f04755c1daf91ec8f445e17e2ba2ab7a3 x86_64 hpack-0.36.0

Method of installation

  • Via GHCup

Platform

Linux x86_64

@mpilgrem
Copy link
Member

@lehins, thanks for reporting. I can reproduce with stack --snapshot lts-18.28 build ghc-paths, which fails with (extracts, reformatted):

ghc-paths>
ghc-paths> D:\\\\sr\setup-exe-src\setup-shim-LRiJ_wrZ.hs:10:1: error:
ghc-paths>     parse error on input ‘import’
ghc-paths>    |
ghc-paths> 10 | import Data.List ( stripPrefix )
ghc-paths>    | ^^^^^^

D:\sr\programs\x86_64-windows\ghc-8.10.7\bin\ghc-8.10.7.exe
--make 
-odir C:\Users\mike\AppData\Local\Temp\stack-622eaa695368b24d\ghc-paths-0.1.0.12\.stack-work\dist\ed8db9df\setup 
-hidir C:\Users\mike\AppData\Local\Temp\stack-622eaa695368b24d\ghc-paths-0.1.0.12\.stack-work\dist\ed8db9df\setup 
-i 
-i. 
-clear-package-db 
-global-package-db 
-package-db=D:\sr\snapshots\22467f89\pkgdb 
-package-db=D:\sr\global-project\.stack-work\install\728c597c\pkgdb 
-hide-all-packages 
-package-id=Cabal-3.2.1.0 
-package-id=base-4.14.3.0 
-package-id=directory-1.3.6.0 
-optP-include -optPC:\Users\mike\AppData\Local\Temp\stack-622eaa695368b24d\ghc-paths-0.1.0.12\.stack-work\dist\ed8db9df\setup\setup_macros.h 
C:\Users\mike\AppData\Local\Temp\stack-622eaa695368b24d\ghc-paths-0.1.0.12\Setup.hs 
D:\sr\setup-exe-src\setup-shim-LRiJ_wrZ.hs 
-main-is StackSetupShim.mainOverride 
-o C:\Users\mike\AppData\Local\Temp\stack-622eaa695368b24d\ghc-paths-0.1.0.12\.stack-work\dist\ed8db9df\setup\setup 
-threaded 
-haddock

D:\\sr\setup-exe-src\setup-shim-LRiJ_wrZ.hs seems unobjectionable (extract):

{-# LANGUAGE CPP            #-}
{-# LANGUAGE PackageImports #-}

module StackSetupShim where

-- | Stack no longer supports Cabal < 1.24 and, consequently, GHC versions
-- before GHC 8.0 or base < 4.9.0.0. Consequently, we do not need to test for
-- the existence of the MIN_VERSION_Cabal macro (provided from GHC 8.0).

import Data.List ( stripPrefix )
import Distribution.ReadE ( ReadE (..) )
...
mainOverride :: IO ()
mainOverride = do
  ...

@mpilgrem
Copy link
Member

mpilgrem commented Jul 12, 2024

LTS 18.28 specifies GHC 8.10.7 and (which is revision 3)

  • ghc-paths-0.1.0.12@sha256:5b99848c5d6e8ae3105aee803e6e67100affca05d0cbe09b4e9a44a9ddf32a81,657

and GHC 8.10.7 specifies base-4.14.3.0, Cabal-3.2.1.0 and directory-1.3.6.0.

GHC 8.10.7 definitely provides the MIN_VERSION_Cabal macro:

@mpilgrem
Copy link
Member

Something like the following does not fail (reformatted):

stack --snapshot lts-18.28 exec -- ghc
--make 
-clear-package-db 
-global-package-db 
-hide-all-packages 
"-package-id=Cabal-3.2.1.0" 
"-package-id=base-4.14.3.0" 
"-package-id=directory-1.3.6.0" 
"C:\Users\mike\AppData\Local\Temp\stack-d068a4c7f68044fc\ghc-paths-0.1.0.12\Setup.hs" 
"D:\sr\setup-exe-src\setup-shim-LRiJ_wrZ.hs" 
-main-is "StackSetupShim.mainOverride" 
-threaded

@mpilgrem
Copy link
Member

The GHC error parse error on input ‘import’ is usually because an import statement has come after other definitions - but I can't see that there are any other possible prior definitions.

@mpilgrem
Copy link
Member

It seems to be something with the CPP directives in setup-shim-LRiJ_wrZ.hs - if I delete them all, GHC 8.10.7 does not complain about the resulting code. Now to try deleting them one at a time ...

@mpilgrem
Copy link
Member

@lehins, I have found the cause. It was rather obscure. The combination of (a) the -- | -style Haskell comments before import statements and (b) the GHC -haddock option was causing GHC 8.10.7 and earlier to complain.

mpilgrem added a commit that referenced this issue Jul 12, 2024
mpilgrem added a commit that referenced this issue Jul 12, 2024
@mpilgrem
Copy link
Member

@lehins, this fix will be included in Stack 3.1.1.

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

No branches or pull requests

2 participants