8000 Initial support for c2rust by randomPoison · Pull Request #7475 · compiler-explorer/compiler-explorer · GitHub
[go: up one dir, main page]

Skip to content

Initial support for c2rust #7475

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

Merged
merged 6 commits into from
Mar 27, 2025

Conversation

randomPoison
Copy link
Contributor

Adds new compiler base for c2rust, a transpiler that converts C code to Rust.

There's one outstanding TODO in the code about incorrect default filters for the c2rust output. I wasn't sure how to address it, so help would be appreciated.

Fixes #6888 and #5900 (there are duplicate feature requests).

@dkm
Copy link
Member
dkm commented Mar 17, 2025

👋 thanks for the PR!
I guess you want to have the compiler available on the public site? So you also need changes in the infra repository to install the compiler, maybe you even need to have something to build it if there's no public binary archive we can use... And finally, you need corresponding changes in the config files (both the default and amazon ones).

Let us know if you need more guidance 👋

@randomPoison
Copy link
Contributor Author

I guess you want to have the compiler available on the public site? So you also need changes in the infra repository to install the compiler, maybe you even need to have something to build it if there's no public binary archive we can use

Yup, the goal is to add this to the public compiler explorer site! I currently have a few other PRs up that should be adding the necessary build support:

I think that's everything needed to get c2rust building for the public site, but please let me know if I missed something!

And finally, you need corresponding changes in the config files (both the default and amazon ones).

Ah, right! Let me add those.

@randomPoison
Copy link
Contributor Author

Okay, I have added what is I think the correct configuration for the amazon config file. I didn't add anything to the default config file because it doesn't seem like c2rust needs to be in the default config, but let me know if that's wrong. Is there a good way to test the config for the amazon file? I'm not 100% sure I got the path to the exe right and I'm not sure how to test that.

Also, the one other thing I could use some help with relates to the TODO comment in the PR. By default the Rust ouput is having it's first line removed by the comments filter, resulting in invalid Rust. Turning off the comments filter fixes this, but that's not going to be disabled by default for users. Is there a right way to fix this? It seems suspect that the comment filter is removing a line starting with # when that's not a valid comment for Rust. So maybe there's something about the output language setting that would fix that? Or is there a way to just disable the comment filter when running c2rust?

@mattgodbolt
Copy link
Member

Or is there a way to just disable the comment filter when running c2rust?
You could probably override the options and set them accorindgly (some of the other compilers do this for intel vs non-intel settings?) I'll have to take a look

group.c2rust.supportsBinary=false
group.c2rust.supportsBinaryObject=false

compiler.c2rust-master.exe=/opt/compiler-explorer/c2rust-master/c2rust
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this path is good:

$ /opt/compiler-explorer/c2rust-master/c2rust --help
C2Rust 0.20.0
The C2Rust Project Developers <c2rust@immunant.com>

USAGE:
    c2rust <SUBCOMMAND>

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    analyze       
    help          Print this message or the help of the given subcommand(s)
    instrument    
    pdg           
    transpile     

@mattgodbolt
Copy link
Member

I have a solution that I think is OK for now for the "don't hide comments" -- will push to your branch and merge

@mattgodbolt
Copy link
Member

Ah, I don't haev write-access but I'll push to main here instead.

@mattgodbolt mattgodbolt merged commit 9dae0ed into compiler-explorer:main Mar 27, 2025
10 checks passed
@mattgodbolt
Copy link
Member

ok I think we're good :)

@mattgodbolt
Copy link
Member

This is now live on the site: thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[COMPILER REQUEST]: c2rust
3 participants
0