Enable postprocess in Crisp#131
Conversation
thedataking
left a comment
There was a problem hiding this comment.
Please clean up commit history so you don't make changes in one commit that is later undone in a later commit before we review the non-draft version.
For example, you add and then remove a postprocess parameter to the transpile function. You probably planned on doing this anyway, sorry to belabor the point.
8244ede to
7f76a49
Compare
5512cd4 to
c02264f
Compare
|
Divided up the commit into two: one that bumps deps/c2rust (and its associated fixes), and the other that integrates postprocess. The postprocess commit requires immunant/c2rust#1838 before landing. On the topic of forwarding CRISP_API_KEY as OPENAI_API_KEY to postprocess: I can do this, but it would mean if CRISP_API_KEY is set, we can't have postprocess use Gemini, unless OPENAI is forawrded explicitly as empty. We should probably introduce the equivalent API_KEY/API_MODEL to postprocess so its not as mess? I can get a PR going for that if you'd like. I can also add forwarding of --codex-login for support that as well, I have a prototype already thrown together for testing. Thoughts? |
c02264f to
f6d731d
Compare
|
This should be about good to go. Last thing I need to do is fix the commit message, and bump |
f6d731d to
f34db9d
Compare
|
Current this is blocked by immunant/c2rust#1851 and immunant/c2rust#1852. Once those two PRs are merged, I want to do one final test before this can be merged. |
f34db9d to
0c6e922
Compare
There was a problem hiding this comment.
Branden, please revisit this comment:
Couldn't we pass the CRISP_API_KEY to the postprocessor? If it is an OpenAI key (likely), the postprocessor should be able to use it provided that we tell the postprocessor to use the model selected in CRISP_API_MODEL.
I opened immunant/c2rust#1853 so c2rust-postprocess picks up the CRISP_API_MODEL/KEY/BASE env variables. With this change you should not have to copy env keys around here, everything should just work.
Please simplify and then test this PR with C2Rust PRs 1851 and 1853.
f6b5a3a to
aa4b437
Compare
aa4b437 to
4cda5b5
Compare
|
Ready for review. Tests are passing, I'm just mucking with the commit message. Edit edit: nevermind, tests passing again after rebase. |
4cda5b5 to
2cc93d7
Compare
b252139 to
53fc942
Compare
|
If everything is acceptable, we can merge this. |
| "--output-dir", | ||
| sb.join(output_path), | ||
| "--emit-build-files", | ||
| "--emit-c-decl-map", |
There was a problem hiding this comment.
This is on the not hayroll arm of the conditional. How do you get this flag passed to the transpiler on the other arm?
There was a problem hiding this comment.
Does Hayroll have support for this? I couldn't find anything.
Edit: My understanding is, hayroll=True transpiles invoke Hayroll, which invokes c2rust. I have two possible concerns:
- Hayroll does not appear to expose any way to forward --emit-c-decl-map.
- Can Hayroll transform the c2rust output in a way that breaks the decl maps? Codex suggests it can.
| n_op = EditOpNode.new( | ||
| mvir, | ||
| old_code=n_tree.node_id(), | ||
| new_code=n_new_tree.node_id(), |
There was a problem hiding this comment.
I haven't looked closely into how this works but I wonder: we don't need the *.c_decls.json files after postprocessing. Do you do anything to stop carrying them around in the MVIR nodes after postprocessing?
There was a problem hiding this comment.
They were just left before, I added a cleaning pass. Should keeping or cleaning them be decided by a flag?
thedataking
left a comment
There was a problem hiding this comment.
We need postprocess to work independently of whether Hayroll is on or off; I'm not sure this is currently true.
53fc942 to
f4e5dc4
Compare
Add support for a postprocess pass in Crisp. Postprocess parameters are controlled via CRISP_* env variables.
f4e5dc4 to
0a6fc10
Compare
Introduces c2rust transpile postprocess to the Crisp loop. Postprocess occurs after transpile with a separate sandbox invocation. If postprocess fails, or the subsequent cargo check, we discard the node and fall back to just the transpile output. Postprocess runs with
--on-error warn, to produce a best-guess output, so we get something on an imperfect run rather than nothing.The key/base/model used by postprocess are inherited from
CRISP_API_{KEY|BASE|MODEL}respectively.