-
Notifications
You must be signed in to change notification settings - Fork 156
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
Fix ordering issues in Manifest files (#2325, #2334) #2347
Conversation
723c34e
to
a3d2d4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for fixing this!
I wonder if there is still some way to get files wrongly sorted. I had a whole manifesto in the commit msg for my attempt:
We don't track dependency information for include files and memory
files. Include files are generated from
`Clash.Netlist.BlackBox.Types.bbIncludes` or YAML/JSON `includes` keys,
and memory files are generated from `~TEMPLATE` holes in the primitive
template language. We should actually track these dependencies to
maintain a proper reverse topological sort order in our manifest files.
However, this commit makes the problem less severe. We used to list
these include and memory files last in the list, but it is extremely
likely that the HDL file that caused the include/memory file to be
generated depends on it. So by listing them first instead of last, we
fix the sort order for the common case that the include/memory files
_themselves_ do not depend on anything else.
To be precise, we sort the include files after the memory files because
it is probably difficult to impossible to construct a memory file that
depends on an include file, but the reverse is easily achieved.
What could happen, I think, is that a primitive can reference another HDL file (because it refers to something that is generated in a separate HDL file). And if that primitive generates an include file that also references that HDL file, you'd want the include file to be in between the two HDL files in the dependency sort.
So maybe we still need a little warning somewhere that not every conceivable dependency is sorted, because that would require us to group HDL files and include files as they come to life rather than first listing all include files.
I had this FIXME in clash-lib/src/Clash/Driver.hs
line 483:
-- FIXME: We should track dependencies of `mfiles` and `dfiles` and
-- maintain the proper topological sort of all these.
Now that Ah, also: you can re-enable the "Parameters" test ( |
We don't track dependency information for include files and memory files. Include files are generated from `Clash.Netlist.BlackBox.Types.bbIncludes` or YAML/JSON `includes` keys, and memory files are generated from `~TEMPLATE` holes in the primitive template language. We should actually track these dependencies to maintain a proper reverse topological sort order in our manifest files. However, this commit makes the problem less severe. We used to list these include and memory files last in the list, but it is extremely likely that the HDL file that caused the include/memory file to be generated depends on it. So by listing them first instead of last, we fix the sort order for the common case that the include/memory files _themselves_ do not depend on anything else. To be precise, we sort the include files after the memory files because it is probably difficult to impossible to construct a memory file that depends on an include file, but the reverse is easily achieved. Fixes #2334 Co-authored-by: Peter Lebbing <[email protected]>
Although 'sortTop' returned a reverse topologically sorted list of 'TopEntityT', the values in the returned map were not sorted the same way. Code using 'sortTop' erroneously assumed this was the case, leading to the ordering issues in Manifest files. Fixes #2325
a3d2d4f
to
8e8bc47
Compare
8e8bc47
to
87ddd5b
Compare
Done, that works now. The others still segfault unfortunately. |
Also, manifesto added to the relevant commit. |
@@ -367,7 +367,7 @@ runClashTest = defaultMain $ clashTestRoot | |||
-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment also needs to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I thought CI would take a while, it was done in under 32 minutes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah flip, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 jobs for
fix-2325-2334
in 18 minutes and 50 seconds
GitLab :-). GHA usually takes longer, but it was feeling generous today!
Fixes #2325
Fixes #2334
Still TODO:
update_compile_order
anymore.