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

port c2rust-transpile to syn, disable c2rust-refactor, llvm_asm! -> asm! #374

Merged
merged 92 commits into from
Apr 13, 2022

Conversation

fw-immunant
Copy link
Contributor

This makes it possible to build c2rust with a current nightly (and one as old as a few months ago probably works, but I'm not sure of the exact compat range).

The caveats:

  • The c2rust-refactor tool has not been ported, as it depends not just on rustc's libsyntax but also on lots of other rustc internals, and the point of this is to separate the most useful part of c2rust from being tied to a specific rustc version. But don't give up all hope for cleaning up your unsafe c2rust-generated Rust code--good things may show up on this front in the future.
  • Comments are no longer preserved in translated code. This is not a permanent change (expect a follow-up PR to reintroduce comments in most AST positions), but comment translation has to be implemented in a substantially different way when using syn+prettyplease for AST generation and pretty-printing, and this is still WIP.

if this var is set, binaries are in a different location than we expect

setting CARGO_TARGET_DIR can save disk space by sharing target dirs between Cargo projects
fd 9 was getting used by something when doing a nested build; instead simply write to the output file directly

this was also fixed upstream by intel/tinycbor@6176e0a
we likely need to redo how this handles spans, because spans are required for comment reinsertion
this fork is unfortunate but maybe can be avoided as it merely exposes more entrypoints to prettyplease's printer
this is deprecated and has no effect for foreign functions, which are no longer mangled by default
this is no longer needed and just produces unnecessary warnings
this follows upstream dropping support; see #369
@fw-immunant fw-immunant force-pushed the fw/syn-port branch 2 times, most recently from 592307c to 9bcff61 Compare March 18, 2022 17:46
@XVilka
Copy link

XVilka commented Mar 18, 2022

Will it be possible to generate Rust code using this port, and then use the c2rust-refactor from older commits of the c2rust?

@fw-immunant
Copy link
Contributor Author

Will it be possible to generate Rust code using this port, and then use the c2rust-refactor from older commits of the c2rust?

Yes, the rust code generated by the new c2rust-transpile should still work with the old c2rust-refactor, though that workflow isn't something with test coverage, so your mileage may vary as c2rust-transpile evolves with language and compiler changes.

@fw-immunant fw-immunant force-pushed the fw/syn-port branch 4 times, most recently from e4faab6 to 2086cb2 Compare March 18, 2022 21:04
@nacaclanga
Copy link

I assume this compleately breaks c2rust-refactor. Maybe we can rewrite c2rust-refactor and c2rust transpiler into two entierly different programms, that can be installed individually with c2rust itself, just checking for them to exist and call them. We can do so by adding a feature to c2rust-ast-printer and c2rust-ast-builder that switches from syn to a libsyntax version for now. This allows for people to still be able to use the unstable old refactor tool, if they want to.

the empty string is no longer a legal path segment; use mk().abs_path() to specify that the path begins with `::`
this replaces LitIntType::Unsuffixed enum variant from libsyntax
@rinon
Copy link
Contributor

rinon commented Apr 12, 2022

I assume this compleately breaks c2rust-refactor. Maybe we can rewrite c2rust-refactor and c2rust transpiler into two entierly different programms, that can be installed individually with c2rust itself, just checking for them to exist and call them. We can do so by adding a feature to c2rust-ast-printer and c2rust-ast-builder that switches from syn to a libsyntax version for now. This allows for people to still be able to use the unstable old refactor tool, if they want to.

Maintaining both with a feature flag seems infeasible, given the extent of these changes. Building c2rust-refactor is still easy, however, with the skew in nightly versions between the transpiler and the refactoring tool, it's more complicated than just a feature flag. You're welcome to still build and use the refactoring tool, either by modifying the cargo configuration or just pinning to an old commit, but I don't see a good way to support both concurrently for the moment.

Keep in mind that code from the new transpiler will probably not parse with the old nightly (and vice versa, because we use too many nightly features in the transpiled output code).

this is necessary to make the testsuite pass; otherwise, curl and libxml hit rust-lang/rust#87813 now that we translate their inline asm (which only appears from transitive includes on ubuntu 18.04)
@fw-immunant fw-immunant changed the title port c2rust-transpile to syn, disable c2rust-refactor port c2rust-transpile to syn, disable c2rust-refactor, llvm_asm! -> asm! Apr 12, 2022
@fw-immunant fw-immunant merged commit 1f53baf into master Apr 13, 2022
@fw-immunant fw-immunant mentioned this pull request Apr 13, 2022
@fw-immunant fw-immunant deleted the fw/syn-port branch May 2, 2022 17:41
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.

Stop using rustc_private libraries
4 participants