CheckedC Compiler & 3C
Building
Basics
You first have to clone the CheckedC clang repo from https://github.com/Vedaant-Rajoo/checkedc-llvm-project.git.
git clone https://github.com/Vedaant-Rajoo/checkedc-llvm-project.git
cd checkedc-llvm-project
# Get a copy of the Checked C system headers. Use Microsoft's
# "checkedc" repository regardless of which "checkedc-clang"
# repository you use.
git clone https://github.com/microsoft/checkedc llvm/projects/checkedc-wrapper/checkedc
mkdir build && cd build
cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_USE_SPLIT_DWARF=ON -DLLVM_OPTIMIZED_TABLEGEN=ON
ninja clang 3c 3Cclangd
PATH Instructions
If you want to use any of the tools you built above to work on your terminal window, you will need to add them to your PATH
environment variable.
- After sucessfully building do the following:
cd bin pwd
- This will return the
PATH
(something likecheckedc-llvm-project/build/bin
at the end) of your build files (If you didn’t change the directory after building). - And then set the variable using the command:
export PATH=$PATH:the/path/you/got
Caution
If you already have the normal legacy version of clang
compiler installed on your system, the new checked version might interfere with its operation. This new version of clang
is backward-compatible, i.e it works with checked and unchecked C code. So remove the old clang
from your system and set the PATH to your new clang
compiler using the steps above.
TARGETS
clang
: This is the checkedC version of clang compiler. You need this to compile and run your converted code.3c
: This is the conversion library our tool is build on top of.3Cclangd
: The LSP server that works with your editor to leverage automated feedback supported conversion.
Extra Build Options
- The above instructions already assume the use of the [Ninja](https://ninja-build.org/) build tool; you may have to install it. You can alternatively use `make` (remove `-G Ninja` from the `cmake` command and replace `ninja` with `make`), but Ninja is much faster in our experience.
- Pass `-DLLVM_USE_LINKER=lld`. This requires a sufficiently recent version of `lld` to be installed on your system.
- Pass `-DLLVM_APPEND_VC_REV=OFF` to turn off embedding of your Git head commit ID in the executables and thus avoid the need to re-link all of them every time the commit ID changes.
- You might want to use `-DCMAKE_BUILD_TYPE=RelWithDebInfo` if you are running 3C enough between builds