Skip to content
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

crux-mir: rerun mir-json when mir-json changes #1241

Open
sauclovian-g opened this issue Aug 20, 2024 · 2 comments
Open

crux-mir: rerun mir-json when mir-json changes #1241

sauclovian-g opened this issue Aug 20, 2024 · 2 comments
Labels
MIR Issues relating to Rust/MIR support testing UX

Comments

@sauclovian-g
Copy link
Contributor

crux-mir only regenerates the MIR dump produced by mir-json when it thinks it's out of date. The list of sources it uses for this does not include the mir-json executable. One consequence of this is that after changing mir-json one needs to manually clean the test suite (and if one forgets it's easy to chase down a rathole trying to figure out why your changes aren't changing anything, etc.) but since the code involved is apparently not used only in the test suite it presumably has other consequences as well, possibly more embarrassing.

The mtime of an executable isn't a great proxy for whether it's changed, but under normal circumstances it's a conservative approximation, and since there are already mtime checks happening, checking the executable that generated the output is a good plan.

The reason this is not completely trivial is that we run crux-mir off $PATH so we don't have the a readily accessible path to the executable. Unless there's a function to search for things on $PATH in the Haskell stdlib somewhere (I can't find one, but that doesn't prove anything) this probably should be done by fetching $PATH from the environment, splitting it, and looking for the program in each entry dir in order. Which is not actually a big deal.

The code in question appears in crux-mir/src/Mir/Generate.hs; there are two places to apply a test (one in maybeCompileMirJson for mir-json, one in maybeLinkJson for mir-json-dce).

@sauclovian-g sauclovian-g added testing UX MIR Issues relating to Rust/MIR support labels Aug 20, 2024
@RyanGlScott
Copy link
Contributor

RyanGlScott commented Aug 20, 2024

Some functions that may be helpful here:

  • findExecutable: look up an executable name in the current PATH
  • lookupEnv: look up the value of an environment variable
  • getExecutablePath: look up the full path of the current executable (i.e., the full path of crux-mir)

@sauclovian-g
Copy link
Contributor Author

ah hoogle failed to find me findExecutable, apparently because if you ask it for Foo -> Bar it will cheerfully return all sorts of probably-not-useful Foo -> a, but not Foo -> IO Bar. :-| oh well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MIR Issues relating to Rust/MIR support testing UX
Projects
None yet
Development

No branches or pull requests

2 participants