Skip to content

Copy .hie test fails with ghc-9.8.1 #9725

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

Open
philderbeast opened this issue Feb 17, 2024 · 8 comments · May be fixed by #9726
Open

Copy .hie test fails with ghc-9.8.1 #9725

philderbeast opened this issue Feb 17, 2024 · 8 comments · May be fixed by #9726

Comments

@philderbeast
Copy link
Collaborator

philderbeast commented Feb 17, 2024

While testing #9717, I found a test that fails locally with ghc-9.8.1 but passes with ghc-9.4.8. Here's the failure;

$ cabal run cabal-testsuite:cabal-tests -- --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.8.1/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal cabal-testsuite/PackageTests/CopyHie/setup.test.hs
...
- setup.test.hs: /home/<USERNAME>/.../cabal/cabal-testsuite/PackageTests/CopyHie/setup.dist/usr/lib/x86_64-linux-ghc-9.8.1/hie-local-0.1.0.0/extra-compilation-artifacts/hie/HieLocal.hie should exist
+ setup.test.hs: /tmp/cabal-testsuite-156428/setup.dist/usr/lib/x86_64-linux-ghc-9.8.1/hie-local-0.1.0.0/extra-compilation-artifacts/hie/HieLocal.hie should exist

Putting the tests into a temporary directory is definitely an improvement, if only because it puts the tests into a clean room away from whatever junk may be lying around in my working directory.

Originally posted by @philderbeast in #9717 (comment)

@philderbeast
Copy link
Collaborator Author

I have hls-2.6.0.0 installed and this supports ghc-9.8.1 according to its release.

@philderbeast
Copy link
Collaborator Author

The failing test was added in #9019.

@mpickering
Copy link
Collaborator

It seems to pass on 9.6.2 and 9.8.1 for me locally.

@philderbeast
Copy link
Collaborator Author

philderbeast commented Feb 17, 2024

More carefully this time, first with ghc-9.6.2;

$ tree -P 'HieLocal.hie' --prune
.

0 directories, 0 files

$ cabal run cabal-testsuite:cabal-tests -- \
  --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.6.2/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal \
  cabal-testsuite/PackageTests/CopyHie/setup.test.hs
...
OK

$tree -P 'HieLocal.hie' --prune
.
└── cabal-testsuite
    └── PackageTests
        └── CopyHie
            ├── setup.cabal.dist
            │   ├── usr
            │   │   └── lib
            │   │       └── x86_64-linux-ghc-9.6.2
            │   │           └── hie-local-0.1.0.0
            │   │               └── extra-compilation-artifacts
            │   │                   └── hie
            │   │                       └── HieLocal.hie
            │   └── work
            │       └── dist
            │           └── build
            │               └── extra-compilation-artifacts
            │                   └── hie
            │                       └── HieLocal.hie
            └── setup.dist
                ├── usr
                │   └── lib
                │       └── x86_64-linux-ghc-9.6.2
                │           └── hie-local-0.1.0.0
                │               └── extra-compilation-artifacts
                │                   └── hie
                │                       └── HieLocal.hie
                └── work
                    └── dist
                        └── build
                            └── extra-compilation-artifacts
                                └── hie
                                    └── HieLocal.hie

28 directories, 4 files

Then again with ghc-9.8.1;

$ tree -P 'HieLocal.hie' --prune
.

0 directories, 0 files

$ cabal run cabal-testsuite:cabal-tests -- \
  --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.8.1/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal \
  cabal-testsuite/PackageTests/CopyHie/setup.test.hs
...
setup.test.hs: /home/.../cabal/cabal-testsuite/PackageTests/CopyHie/setup.dist/usr/lib/x86_64-linux-ghc-9.8.1/hie-local-0.1.0.0/extra-compilation-artifacts/hie/HieLocal.hie should exist
CallStack (from HasCallStack)
...
(exit 1): failed

$ tree -P 'HieLocal.hie' --prune
.
└── cabal-testsuite
    └── PackageTests
        └── CopyHie
            └── setup.dist
                ├── usr
                │   └── lib
                │       └── x86_64-linux-ghc-9.8.1-eb95
                │           └── hie-local-0.1.0.0
                │               └── extra-compilation-artifacts
                │                   └── hie
                │                       └── HieLocal.hie
                └── work
                    └── dist
                        └── build
                            └── extra-compilation-artifacts
                                └── hie
                                    └── HieLocal.hie

16 directories, 2 files

@philderbeast
Copy link
Collaborator Author

The test is looking in the wrong place;

- setup.dist/usr/lib/x86_64-linux-ghc-9.8.1/hie-local-0.1.0.0/extra-compilation-artifacts/hie/HieLocal.hie
+ setup.dist/usr/lib/x86_64-linux-ghc-9.8.1-eb95/hie-local-0.1.0.0/extra-compilation-artifacts/hie/HieLocal.hie

@philderbeast
Copy link
Collaborator Author

@alt-romes could this be from the change in #9618 to use showCompilerIdWithAbi? I'm testing with master at fe82d9b.

@philderbeast
Copy link
Collaborator Author

philderbeast commented Feb 18, 2024

/home/<USERNAME>/.cache/hie-bios/dist-cabal-6d85a4e3f3d8c061527ba56a3e684653/build/x86_64-linux/ghc-9.8.1/cabal-testsuite-3/build/global-autogen/Test/Cabal/ScriptEnv0.hs has1;

lbiCompiler :: Compiler
lbiCompiler = Compiler {compilerId = CompilerId GHC (mkVersion [9,8,1]), compilerAbiTag = NoAbiTag, ...

Same lbiCompiler Compiler.compilerAbiTag for;

dist-newstyle/build/x86_64-linux/ghc-9.8.1/cabal-testsuite-3/build/global-autogen/Test/Cabal/ScriptEnv0.hs

$ ghc --info
...
 ,("Project version","9.8.1")
 ,("Project Git commit id","443e870d977b1ab6fc05f47a9a17bc49296adbd6")
...
 ,("Project Unit Id","ghc-9.8.1-eb95")
...

Footnotes

  1. HLS go to definiton for Test.Cabal.ScriptEnv0.lbiCompiler.

@philderbeast philderbeast linked a pull request Feb 18, 2024 that will close this issue
2 tasks
mpickering added a commit to mpickering/cabal that referenced this issue Feb 22, 2024
In the testsuite we generate a module `ScriptEnv0.hs` which records information about the compiler used to build the testsuite, the packages etc so that the test runner can then use this information to

However, this is very fragile because

* `ScriptEnv0.hs` is generated by a module compiled against `Cabal-3.10`
* The file is compiled against `Cabal-3.11`

So if any definition changes between 3.10 and 3.11 then the new version will fail to read the generated file.

Really we should record the information which needs to be persisted in a more generic way (ie only depending on `base`) so that you can be sure the serialisation/deserialisation will work.

This seems to have worked for a while because these data types never change.. but now `compilerAbiTag` is populated by `3.11` but not by `3.10`, which leads to bugs like haskell#9725

See haskell#9730
@mpickering
Copy link
Collaborator

A patch which fixes this immediate issue: https://github.com/mpickering/cabal/tree/wip/test-compiler-fix

I am still not happy with the overall approach (see #9730) so I will leave it here for when progress is forced on this issue.

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

Successfully merging a pull request may close this issue.

2 participants