Passing hs-boot files as ghc arguments rarely works
Given a setup with `A.hs-boot`, `A.hs` and `B.hs` which contains `import {-# source #-} A` the current behaviour is:
In make mode:
`ghc A.hs-boot` produces `A.hi-boot` and `A.o` (instead of `A.o-boot`)
`ghc A.hs-boot B.hs` compiles as `A.hs-boot` as above and then throws
```
attempting to use module ‘main:A’ (A.hs-boot-boot) which is not loaded
```
`ghc A.hs-boot B.hs A.hs` throws
```
module ‘main:A’ is defined in multiple files: A.hs-boot A.hs
```
`ghc B.hs A.hs` works fine
In one-shot mode:
`ghc -c A.hs-boot` works: it produces `A.hi-boot` and `A.o-boot`
`ghc -c A.hs-boot B.hs` throws
```
Bad interface file: A.hi-boot-boot
A.hi-boot-boot: withBinaryFile: does not exist (No such file or directory)
```
`ghc -c A.hs-boot B.hs A.hs` throws the same
`ghc -c B.hs A.hs` throws
```
Could not find module ‘A’
```
So in make mode passing `A.hs-boot` never works. In one-shot mode passing `A.hs-boot` is required to get everything to compile, but you cannot also pass `A.hs` or another file that source-imports `A`. It would be nice if it all just works, especially without mentioning `hs-boot-boot` in messages!
@torsten.schmits diagnosed the issue as follows:
> In several locations, modules are added to the Finder without considering whether they are boot interfaces for all involved components.\
> This results in corrupt `ModLocation` values that have boot suffixes only on some paths, or a `.hs-boot-boot` suffix on some.\
> Additionally, it depends on the order of targets whether a lookup will return the `ModLocation` for the boot file or the source file.
and proposed this fix: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13237
issue