You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+16-12
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,15 @@
3
3
# What is C2Rust?
4
4
5
5
C2Rust helps you migrate C99-compliant code to Rust. It provides:
6
-
- a C to Rust translator,
7
-
- a Rust code refactoring tool, and
8
-
-a way to cross-check the C code against the new Rust code.
6
+
- a C to Rust translator
7
+
- a Rust code refactoring tool
8
+
-tools to cross-check execution of the C code against the new Rust code
9
9
10
-
The translator (or transpiler), produces unsafe Rust code that closely mirrors the input C code. The primary goal of the translator is to produce code that is functionally identical to the input C code. Generating safe or idomatic Rust is *not* a goal for the translator. Rather, we think the best approach is to gradually clean up the translator using dedicated refactoring tools. See the `c2rust-refactor` directory to learn about the `c2rust-refactor` tool that we are working on.
11
-
Some refactoring will have to be done by hand which may introduce errors. We provide plugins for `clang` and `rustc` so you can compile and run two binaries and check that they behave identically (at the level of function calls).
12
-
See details in the `cross-checks` directory and in the cross checking [tutorial](docs/cross-check-tutorial.md). Here's the big picture:
10
+
The translator (or transpiler), produces unsafe Rust code that closely mirrors the input C code. The primary goal of the translator is to produce code that is functionally identical to the input C code. Generating safe or idomatic Rust is *not* a goal for the translator. Rather, we think the best approach is to gradually rewrite the translated Rust code using dedicated refactoring tools. To this end, we are building a refactoring tool that rewrites unsafe auto-translated Rust into safer idioms (see [c2rust-refactor](c2rust-refactor/)).
11
+
12
+
Some refactoring will have to be done by hand which may introduce errors. We provide plugins for `clang` and `rustc` so you can compile and run two binaries and check that they behave identically (at the level of function calls). For details on cross-checking see the [cross-checks](cross-checks) directory and the cross checking [tutorial](docs/cross-check-tutorial.md).
@@ -30,13 +32,13 @@ C2Rust requires LLVM 6 or 7 and its corresponding libraries and clang compiler.
30
32
pacman -S base-devel llvm clang cmake
31
33
32
34
33
-
-**OS X:**(XCode command-line tools and recent LLVM (we recommend the Homebrew version) are required.)
35
+
-**OS X:** XCode command-line tools and recent LLVM (we recommend the Homebrew version) are required.
34
36
35
37
xcode-select --install
36
38
brew install llvm python3 cmake
37
39
38
40
39
-
A rust installation with [Rustup](https://rustup.rs/) is also required on all platforms.
41
+
Finally, a rust installation with [Rustup](https://rustup.rs/) is required on all platforms.
40
42
41
43
42
44
## Building C2Rust
@@ -53,7 +55,9 @@ If you have trouble with cargo build, the [developer docs](docs/README-developer
53
55
54
56
# Translating C to Rust
55
57
56
-
The translation tool first needs to know the existing compiler commands used to build the C code. To provide this information, you will need to generate a [standard](https://clang.llvm.org/docs/JSONCompilationDatabase.html)`compile_commands.json` file. Many build systems can automatically generate this file, as it is used by many other tools, but see [below](#generating-compile_commandsjson-files) for recommendations on how to generate this file for common build processes.
58
+
The translator needs access to the exact compiler commands used to build the C code. To provide this information, you will need a [standard](https://clang.llvm.org/docs/JSONCompilationDatabase.html)`compile_commands.json` file. Many build systems can automatically generate this file, as it is used by many other tools, but see [below](#generating-compile_commandsjson-files) for recommendations on how to generate this file for common build processes.
59
+
60
+
Once you have a `compile_commands.json` file describing the C build, translate the C code to Rust with the following command:
Copy file name to clipboardexpand all lines: docs/README-developers.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
There are three ways to build the C2Rust project:
4
4
5
-
- Using **Vagrant**. See our [vagrant README](../vagrant/README.md).
6
-
- Using **Docker**. See our [docker README](../docker/README.md).
5
+
-[Using **Vagrant**](../vagrant/).
6
+
-[Using **Docker**](../docker/).
7
7
-**Manually**, as explained below.
8
8
9
9
The previous two options automatically install all prerequisites during provisioning. You can also provision a macOS or Linux system manually.
@@ -49,7 +49,7 @@ C2Rust (indirectly) uses the [clang-sys](https://crates.io/crates/clang-sys) cra
49
49
50
50
# Building dependencies from source
51
51
52
-
To develop on components that interact with LLVM, we recommend building against a local copy of LLVM. This will ensure that you have debug symbols and IDE integration for both LLVM and C2Rust. However, building C2Rust from source with LLVM takes a while. For a shorter build that links against prebuilt LLVM and clang system libraries, you should be able to `cargo build` in the `c2rust-transpile` directory (see the general [README](../README.md)).
52
+
To develop on components that interact with LLVM, we recommend building against a local copy of LLVM. This will ensure that you have debug symbols and IDE integration for both LLVM and C2Rust. However, building C2Rust from source with LLVM takes a while. For a shorter build that links against prebuilt LLVM and clang system libraries, you should be able to `cargo build` in the `c2rust-transpile` directory (see the general [README](../)).
53
53
54
54
The following from source full build script has been tested on recent versions of macOS and Ubuntu:
55
55
@@ -58,9 +58,9 @@ The following from source full build script has been tested on recent versions o
58
58
59
59
# Testing (Optional)
60
60
61
-
Tests are found in the [`tests`](../tests) folder. If you build the translator successfully, you should be able to run the tests with:
61
+
Tests are found in the [`tests`](../tests/) folder. If you build the translator successfully, you should be able to run the tests with:
62
62
63
63
$ ./scripts/test_translator.py tests
64
64
65
-
This basically tests that the original C file and translated Rust file produce the same output when compiled and run. More details about tests are in [this README](../tests/README.md).
65
+
This basically tests that the original C file and translated Rust file produce the same output when compiled and run. More details about tests can be found in the [tests folder](../tests/).
0 commit comments