Setting up a development environment
- Using Vagrant.
- .
- Manually, as explained below.
The previous two options automatically install all prerequisites during provisioning. You can also provision a macOS or Linux system manually.
If you are on a Debian-based OS, you can run to do so.
If you are on macOS, install the Xcode command-line tools (e.g.,
xcode-select —install
) and homebrew first. Then runscripts/provision_mac.sh
.-
- dirmngr
- curl
- git
- gnupg2
- gperf
- ninja
- unzip
- clang 5.0+
- intercept-build or bear - see why
- python 3.6+
- python dependencies
- rustc
- rustfmt-preview component for the above rustc version
- libssl (development library, dependency of the refactoring tool)
Building with system LLVM libraries
The quickest way to build the C2Rust transpiler is with LLVM and clang system libraries (LLVM 6 and 7 are currently supported). If you have libLLVM.so
and the libclang
libraries (libclangAST.a
, libclangTooling.a
, etc. or their shared variants) installed, you can build the transpiler with:
You can customize the location where the build system will look for LLVM using the following environment variables at compile time:
- = Path to the
llvm-config
tool of the LLVM installation LLVM_LIB_DIR
= Path to thelib
directory of the LLVM installation (not necessary if you useLLVM_CONFIG_PATH
)LLVM_SYSTEM_LIBS
= Additional system libraries LLVM needs to link against (e.g.-lz -lrt -ldl
). Not necessary with .CLANG_PATH
= Path to a clang that is the same version as yourlibclang.so
. If this is necessary the build system will return an error message explaining as much.
C2Rust (indirectly) uses the clang-sys crate which can be configured with its own environment variables.
Building dependencies from source
The following from source full build script has been tested on recent versions of macOS and Ubuntu:
This downloads and builds LLVM under a new top-level folder named build
. Use the C2RUST_BUILD_SUFFIX
variable to do multiple side-by-side builds against a local copy of LLVM like this:
NOTE: Set if building inside and outside of the provided Docker or Vagrant environments from a single C2Rust checkout.
Testing (Optional)
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 .