search path doesn't work for build artifacts
Summary
It doesn't seem to be possible anymore to reference build artifacts (*.o/*.hi) outside of the -outputdir
folder.
The following works with GHC-8.8 and earlier but fails with 8.10 and 9.0.
#!/bin/bash
#GHC=~/.stack/programs/x86_64-osx/ghc-8.8.4/bin/ghc
#GHC=~/.stack/programs/x86_64-osx/ghc-8.10.3/bin/ghc
GHC=~/Downloads/ghc-9.0/bin/ghc
rm -rf build
$GHC -outputdir build/objs -c lib/Foo/Bar.hs
$GHC -outputdir build/prog-objs/Test -ilib -ibuild/objs -c progs/Test.hs
progs/Test.hs:1:1: error:
Bad interface file: build/prog-objs/Test/Foo/Bar.hi
build/prog-objs/Test/Foo/Bar.hi: openBinaryFile: does not exist (No such file or directory)
|
1 | import Foo.Bar
| ^^^^^^^^^^^^^^
The file is present in the referenced directory (build/objs
), but isn't picked up:
% find build -type f
build/objs/Foo/Bar.hi
build/objs/Foo/Bar.o
Steps to reproduce
You can clone the following git-repository at https://github.com/tvh/ghc-search-path-reproducer and change the GHC-paths in the test.sh
to reproduce the error.