Avoid fingerprinting the absolute path to the source file
In #16956 it is mentioned that Hadrian build artifacts are path sensitive. Unsurprisingly, this also affects other cloud build systems.
Solving this problem in full generality will probably involve replacing absolute paths with relative paths as suggested in #16956, but that is quite tricky. This MR is much less ambitious - just prevent one of those absolute paths from being included in the "flags" fingerprint.
The path of the directory of the source file being compiled is implicitly added to the set of include dirs by the driver pipeline. But since this is implicit and done always, there is no need to include it in the flags fingerprint.
Test plan
A very simple experiment can be used to validate that this works:
$ mkdir A B
$ cat > A/A.hs
module A where
a = ()
^D
$ cp A/A.hs B
$ ghc -S A/A.hs B/A.hs
Before this patch, the flag hash
values for A/A.hi
and B/A.hi
are different:
[nix-shell:~/scratch/ide/sigma-ide]$ ghc --show-iface A/A.hi
Warning: the following files would be used as linker inputs, but linking is not being done: B/A.hi
Magic: Wanted 33214052,
got 33214052
Version: Wanted 8104,
got 8104
Way: Wanted [],
got []
interface A 8104
interface hash: 51d691354a3f9fde3d2f0cae4f181362
ABI hash: 7982b65a2191f94ded1a470b647a3962
export-list hash: 71dff2feca09bbfdff954a3e3b32d10c
orphan hash: 693e9af84d3dfcc71e640e005bdc5e2e
flag hash: ddd171a9db4a7627bd64651e5180899c
...
After this patch, the flag hash
values are the same.
I can automate this test if this patch is accepted.
Api changes
I added a new field to IncludeSpecs
in order to make the code as explicit as possible, but the downside is that IncludeSpecs
is exposed through the ghc api so this will be an api breaking change. This is a concern since I would like to backport it to 9.0. A simpler fix would be to take the init
of the includePathsQuote
field, but that could break silently if we change the driver logic in the future. Any suggestions to preserve api compatibility are welcome.
Pending
[x] - automate the test plan