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

Lack of support for simple projects or the cc crate #1033

Closed
kornelski opened this issue Oct 21, 2023 · 3 comments · Fixed by #1037
Closed

Lack of support for simple projects or the cc crate #1033

kornelski opened this issue Oct 21, 2023 · 3 comments · Fixed by #1037

Comments

@kornelski
Copy link

I find the the requirement to use compile_commands.json incredibly annoying, because it never fits the types of projects I want to convert to Rust, and also requires use of clunky 3rd party non-Rust dependencies and non-Rust build systems.

It so happens that all C code that I dare to port to Rust is small — only a handful of .c files, sometimes literally just a single .c file or a header-only dependency. And for such trivial code I use the cc crate, not something complicated like meson.

If a project is too hard to build with the cc crate, I consider it also too big and complex to convert to Rust. So I'm frustrated that c2rust only supports the types of projects I don't want to convert. When I want to convert literally a single .c file that has zero dependencies and compiles with gcc *.c without issues, I have to jump through so many hoops. I need to re-learn how to use cmake, and I need to deal with series of issues in installing the right version of python, and installing its dependencies, and venvs and whatever else it requires. All of that to pass a single file path to c2rust.

Please, support c2rust *.c.

@fish4terrisa-MSDSM
Copy link

Have ever tried bear to generate the compile_commands.json on your project? Maybe you can just use bear -- clang ${PUT_YOUR_ARGS_HERE} ? or you may write a Makefile and run bear -- make instead?

@thedataking
Copy link
Contributor

thedataking commented Oct 25, 2023

@kornelski can you let us know whether bear would solve your issue?

If not, I suppose we could make c2rust transpile work in single file mode without a compile_commands.json.

@kornelski
Copy link
Author

I'd be happy if it transpiled file(s) directly specified on the command line, without the JSON build indirection. Like bindgen, for example.

aneksteind added a commit that referenced this issue Nov 17, 2023
)

* Fixes #1033.

This adds support for transpiling C sources without needing to generate
a `compile_commands.json` with something such as `bear` or `cmake`. The
way it works is that a temporary `temp_compile_commands` file is
created. One alternative to this approach would have been to alter the
AST exporter to use a `FixedCompilationDatabase` but it seemed simpler
to support this feature from the front end.
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 a pull request may close this issue.

3 participants