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

Make c2rust-analyze be a cargo and rustc wrapper like c2rust-instrument is now #709

Closed
kkysen opened this issue Oct 18, 2022 · 0 comments · Fixed by #1036
Closed

Make c2rust-analyze be a cargo and rustc wrapper like c2rust-instrument is now #709

kkysen opened this issue Oct 18, 2022 · 0 comments · Fixed by #1036
Assignees

Comments

@kkysen
Copy link
Contributor

kkysen commented Oct 18, 2022

It appears this is now necessary to analyze the full, amalgamated (#871) (or not, just full) lighttpd. Full lighttpd has bitfields, and thus depends on c2rust-bitfields. Having a crate dependency that's not the bundled libc (which we can get away with an extern crate libc and no cargo) complicates things a lot, as the rustc invocation we pass to c2rust-analyze gets way more complex, and depends on previous rustc invocations for dependencies. Thus, I think the best way forward to is to wrap cargo and let it does what it's meant to do instead of trying to re-implement any of that. We can base this on how c2rust-instrument is currently wrapping rustc, which itself was based on miri, clippy, and other rustc-wrappers.

@kkysen kkysen self-assigned this Oct 30, 2023
kkysen added a commit that referenced this issue Nov 1, 2023
…n main` (#1035)

This is to prepare for putting the `cargo` wrapper in `main.rs` (#709).
kkysen added a commit that referenced this issue Nov 3, 2023
* Fixes #709.
* Fixes #708.

This adds an MVP of a `cargo` wrapper for `c2rust-analyze` so that it
can be run on a whole crate like `cargo`. This copies the approach from
`c2rust-instrument`, with some minor adjustments:
* We don't care about the instrumentation and metadata
`c2rust-instrument` need, so that code is gone.
* We still allow `c2rust-analyze` to be called as a `rustc_wrapper`
directly. More specifically, the `cargo` wrapper is supposed to set
`RUST_SYSROOT`. `c2rust-instrument` requires this, while
`c2rust-analyze` will re-calculate it if it wasn't.

This allows us to keep using the `rustc` wrapper in tests,
as the tests are all set up as single files meant to be compiled with
`rustc` directly.
We can change this, but that'll come later. The exception is the
`lighttpd_minimal` and `with_pdg_file` tests, as those run on full
crates. I converted `lighttpd_minimal` to use the `cargo` wrapper as a
proof of concept to show it works. I tried to do the same for
`with_pdg_file`, but it updated some of the hashes or something so now
the PDG binary has out-of-date `DefPathHash`es, and I'm not sure how to
regenerate a new one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant