<div dir="ltr">The behavior of `-hidir` and `-i` changed in response to this issue:<div><br></div><div><a href="https://gitlab.haskell.org/ghc/ghc/-/issues/16500">https://gitlab.haskell.org/ghc/ghc/-/issues/16500</a><br></div><div><br></div><div>We just ran into this and I think the change is unfortunate. I don't think `-hidir` (a flag about output) should override the input search flag. I would like it to at least merge the two so it searches both the `-hidir` and the `-i`s rather than overriding. Reverting the change would be fine too (I think) because you can always specify the same path as `-hidir` and `-i`. As it is now, you can control *both* the input and the output.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 23, 2021 at 4:26 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Could be! I’m far from a computer much of this week</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 23, 2021 at 2:36 PM Brandon Allbery <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I would expect that to be -I and for -i to specify module paths (which might well mean .hi).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 23, 2021 at 2:32 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">I would assume the -i is for include c header search paths but I could be wrong</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 23, 2021 at 6:00 AM Oleg Grenrus <<a href="mailto:oleg.grenrus@iki.fi" target="_blank">oleg.grenrus@iki.fi</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>This looks like a bug.<br>
<br>
-hidir documentation says<br>
<br>
> Redirects all generated interface files into ⟨dir⟩, instead
of the default.<br>
> Please also note that when doing incremental compilation (by
ghc --make or ghc -c), this directory is where GHC looks into to
find interface files.<br>
<br>
And documentation for -i doesn't mention looking for interface
files.<br>
<br>
So by doing<br>
<br>
% ghc -dynamic-too -c lib/Lib.hs -odir odir -hidir hidir_Lib<br>
% ghc -dynamic-too -c Main.hs -odir odir -hidir hidir_Main
-ihidir_Lib<br>
1<br>
% ghc odir/Lib.o odir/Main.o -o
Demo <br>
%
./Demo
<br>
True<br>
<br>
everything compiles, TH is run, and demo works. The result files
are<br>
<br>
% find .<br>
.<br>
./Demo<br>
./Main.hs<br>
./hidir_Main<br>
./hidir_Main/Main.dyn_hi<br>
./hidir_Main/Main.hi<br>
./odir<br>
./odir/Main.dyn_o<br>
./odir/Main.o<br>
./odir/Lib.dyn_o<br>
./odir/Lib.o<br>
./hidir_Lib<br>
./hidir_Lib/Lib.dyn_hi<br>
./hidir_Lib/Lib.hi<br>
./lib<br>
./lib/Lib.hs<br>
<br>
---<br>
<br>
The confusing error is caused by Lib module in libiserv:<br>
<a href="https://hackage.haskell.org/package/libiserv" target="_blank">https://hackage.haskell.org/package/libiserv</a><br>
which GHC picks!<br>
<br>
If we rename your Lib module to Library, the error is way better:
Could not find module ‘Library’<br>
<br>
I also tried using same -hidir when compiling both modules, then
GHC still cannot find the Library interface, even the
documentation says it should.<br>
<br>
Please open a GHC issue at
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/issues</a></p></div><div><p><br>
<br>
- Oleg<br>
</p>
<div>On 22.10.2021 19.16, Domínguez, Facundo
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Dear devs,
<div><br>
</div>
<div>I'm confused about the meaning of -hidir and -i. Here's my
experiment with both ghc-9.2.0 and ghc-8.10.4.</div>
<div><br>
</div>
<div>> $ find</div>
<div>> ./Main.hs<br>
> ./lib/Lib.hs</div>
<div>></div>
<div>> $ ghc -dynamic-too -c lib/Lib.hs -odir odir -hidir
hidir_Lib</div>
<div>></div>
<div>> $ ghc -dynamic-too -c Main.hs -odir odir -ihidir_Lib
-hidir hidir_Main</div>
<div>></div>
<div>> Main.hs:3:1: error:<br>
> Bad interface file: hidir_Main/Lib.hi<br>
> hidir_Main/Lib.hi: openBinaryFile: does not exist
(No such file or directory)<br>
> |<br>
> 3 | import Lib<br>
> | ^^^^^^^^^^<br>
</div>
<div><br>
</div>
<div>If I only use -hidir, it still fails with another error</div>
<div><br>
</div>
<div>> $ ghc -dynamic-too -c Main.hs -odir odir -hidir
hidir_Lib</div>
><br>
> Main.hs:7:29: error: Variable not in scope: f<br>
> |<br>
> 7 | main = print $(runIO (print f) >> [| True |])<br>
> | ^<br>
<div><br>
</div>
<div>If I use both -i and -hidir pointing to the same folder,
then it works!</div>
<div><br>
</div>
<div>> $ ghc -dynamic-too -c Main.hs -odir odir -ihidir_Lib
-hidir hidir_Lib<br>
</div>
<div><br>
</div>
<div>Now, is this behavior a bug or a feature? And if it is a
bug, what is the expected behavior?</div>
<div><br>
</div>
<div>Programs copied below.</div>
<div><br>
</div>
<div>Thank you!</div>
<div>Facundo</div>
<div><br>
</div>
<div>> $ cat lib/Lib.hs<br>
> module Lib where<br>
><br>
> f :: Int<br>
> f = 1<br>
</div>
<div>></div>
<div>> $ cat Main.hs<br>
> {-# LANGUAGE TemplateHaskell #-}<br>
><br>
> import Lib<br>
> import <a href="http://language.haskell.th/" target="_blank">Language.Haskell.TH</a><br>
><br>
> main :: IO ()<br>
> main = print $(runIO (print f) >> [| True |])</div>
</div>
<br>
<fieldset></fieldset>
<pre style="font-family:monospace">_______________________________________________
ghc-devs mailing list
<a href="mailto:ghc-devs@haskell.org" style="font-family:monospace" target="_blank">ghc-devs@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" style="font-family:monospace" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
</blockquote>
</div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>
</blockquote></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>