Safe C

Building Safe C

How it is built

cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_ENABLE_PROJECTS=clang -DCLANG_ENABLE_CIR=ON -DLLVM_TARGETS_TO_BUILD=AArch64
ninja -C build clang
build/bin/clang -fsafe-c -isysroot $(xcrun --show-sdk-path) example.c

What -fsafe-c turns on

One flag; no other flags are needed:

Prior work

Cyclone and Checked C made C dialects; Fil-C makes C safe at run time with a garbage collector. Safe C stays plain C, checked inside Clang: at compile time where it can be proven, with a trap where it cannot.

View the source of this page on GitHub