Skip to content

Conversation

@jgreenbaum
Copy link

Since Stefan's pull request in the main repo wasn't merged, I've based my work on this branch. Perhaps this isn't much of interest, I see from commits that perhaps moore/llhd development has moved into the CIRCT repo in C++. But I was curious about Moore so here it is.

There are three commits. The first (f4abc83) just makes it build with no warnings with the latest stable rust, which is 1.87.0 at the time of this PR. The second (3cfd5ad) fixes the stack overflows -- the default derived PartialEq and Hash for &dyn *Node references don't work without pinned memory. The final commit (a774e03) just marks up the build commands for LLVM and CIRCT in the Readme.md to use Ninja.

I hope this is useful.

jgreenbaum added 3 commits June 24, 2025 18:49
But tests fail as mentioned in the comments to the existing pull
request: "Building moore with v1.67 or newer results in stack
overflows at runtime (e.g. when running the tests). I think fixing
this can be deferred for now.":
	fabianschuiki#252
All the tests in `test/run.sh` pass now.

Using procout I was able to debug the output of
derive::query::derive_query_db. What I saw was that key
comparison functions were "aliasing" in the caches, so it kept
retrieving the same scope over and over until the stack
overflowed. Looking at the code I saw PartialEq and Hash being
derived for keys with the arg signature of `&dyn *Node`, so any
of the different Node traits. While debugging I could see that
the references were identical for different `Node::id` values.
This makes some sense, Rust doesn't guarantee that a reference
to an object remains unchanged unless you `Pin` it. It looks
like it kept reusing the same memory in different iterations
of a loop. The solution I implemented replaces the derived
`PartialEq` and `Hash` for keys with a single arg that is a
`&dyn *Node`, and instead generates implementations that use the
`Node::id()` instead of the reference.

I'm not sure this is what is expected. I see comments in the code
about moving away from node ids. But unless you put `Box::pin`
objects into the cache you need to use a memory independent
id like `Node::id()`.
@stefanlippuner
Copy link
Owner

Hi @jgreenbaum

Thanks for taking the time to update the toolchain and fixing the issues! For me, it's ok to merge your changes here. However, as Fabian has merged fabianschuiki#252, would it perhaps make sense to open a PR there s.t. the central repo has the most recent version? (it's not really like this is a maintained fork....). Let me know what you would prefer.

(The rustfmt CI job also appears to fail due to some whitespace issues, but that can be resolved easily)

@jgreenbaum
Copy link
Author

However, as Fabian has merged fabianschuiki#252, would it perhaps
make sense to open a PR there s.t. the central repo has the most recent version? (it's not really like this is a maintained
fork....). Let me know what you would prefer.

That makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants