Use one of the following two options to install Chisel:
This is the easiest way to get started with Chisel since you will not need to install anything (except Docker) on your system. You can install Docker on macOS, Windows 10, or Linux.
After installing the Docker engine, simply copy the Dockerfile from here, and run the following commands in the directory in which the Dockerfile is located.
$ docker build -t chisel . $ docker run --privileged -it chisel
You can obtain Chisel's source code by cloning this repository. Next, refer to the step-by-step guide to install the dependencies. Finally, refer to the installation guide to build Chisel.
The test script is a core part of the debloating. It is where you specify multiple instances of the desired, and undesired features. Desired features, as the name implies, are those that you want to keep, and undesired features are those you want to remove.
Let's see how you can write test scripts for your project:
Once your test scripts are ready, you can run Chisel. Your program must be compilable using one of the following compilers or compile systems:
Chisel can be run in one of two different ways depending on how your program is compiled.
If your program is compiled directly, run Chisel as follows:
$ chisel --build ./test.sh -- CC -c X.c Y.c Z.cwhere X.c, Y.c, and Z.c are source files of the program, and
CC
is
one of gcc
, g++
, clang
, or clang++
.
If the input program is compiled via make
, run Chisel as follows:
$ chisel --build ./test.sh -- make
Once you have the reduced program, you can use Chisel to visualize the results in HTML format. The visualization contains the following features:
In order to visualize the results, the following steps should be taken:
file.c
) and the reduced program (e.g.,
file.c.chisel.c
) exist.clang-format
(for reformatting the programs to generate pretty output)llvm-profdata
and llvm-cov
(for computing the covered lines -- optional)file.c
, this file should be named file.c.coverage
.Finally, run the following command to generate the HTML visualization:
$ chisel --xref ./test.sh file.c
By default, you can find the output in xref-output
under the same directory.
$ chisel [OPTIONS]... TestScript Program
-h, --help
-t, --output_dir OUTDIR
-b, --build
clang
, clang++
, gcc
, g++
,
and make
. For example usages, please refer to
this section.
-s, --save_temp
-D, --skip_learning
-d, --skip_delay_learning
-g, --skip_global
-l, --skip_local
if
and switch
statements)while
and do-while
){ body; }
)label_test: statement;
)-c, --no_cache
-L, --skip_local_dep
-G, --skip_global_dep
main
function should be kept.-C, --skip_dce
-p, --no_profile
==================================================== Report ==================================================== Total Time : 996.1s Oracle Time : 988.4s Learning Time : 2.3s Global Success Ratio : 83% ( 51 / 61) Local Success Ratio : 14% ( 171 / 1148) #Functions (Original) : 43 #Statements (Original) : 1804 #Functions (Reduced) : 13 #Statements (Reduced) : 160
-v, --debug
-S, --stat
-X, --xref
If you wish to extend Chisel, refer to the developer's documentation.