A differential testing framework for checking the semantic equivalence of C/C++ code in a native binary (e.g., x86-64) and WebAssembly using a test-driven approach. For more information, see the paper "Reusing Legacy Code in WebAssembly: Key Challenges of Cross-Compilation and Code Semantics Preservation".
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install 3.1.54
./emsdk activate 3.1.54
source ./emsdk_env.sh; cd ..
Note: We did the evaluation part using Emscripten version 3.1.54. However, WasmChecker can work with any arbitrary version.
wget https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.17.0/codeql-bundle-linux64.tar.gz
tar -xzf codeql-bundle-linux64.tar.gz
export PATH=$PATH:/path/to/codeql
codeql resolve qlpacks
Note: You can also use WasmChecker without using CodeQL as the static analyzer. In this case, the WasmChecker simply enables the most important flags. This may cause options conflicts and compile-time overhead. Also, the result of differential testing might be less accurate.
You can use WasmChecker in two ways. If you are going to test a codebase that is already in your system, simply use the following command:
python3 WasmChecker.py -p path_to_codebase -t test_flag
For example:
git clone https://github.com/fmtlib/fmt --recursive
python3 WasmChecker.py -p fmt -t FMT_TEST
You can also simply provide WasmChecker with the git url using the following command:
python3 WasmChecker.py -u repo_url -t test_flag
For example:
python3 WasmChecker.py -u https://github.com/taocpp/PEGTL -t PEGTL_BUILD_TESTS
python3 build-codebases.py compiler(i.e., clang/gcc/emcc)
python3 test-runner.py -p ./emcc-build/fmt
Using the dataset.csv and the script results.py, you can simply reproduce our results.
python3 results.py
This is the list of new bugs we found in Emscripten compiler toolchain by using WasmChecker:
- emscripten-core/emscripten#21382
- emscripten-core/emscripten#21603
- emscripten-core/emscripten#22014
- emscripten-core/emscripten#22259
- emscripten-core/emscripten#21604
- emscripten-core/emscripten#22050
- emscripten-core/emscripten#22040
- emscripten-core/emscripten#22033
- emscripten-core/emscripten#22030
- emscripten-core/emscripten#22202
- !emscripten-core/emscripten#21193
If you have any suggestions or found a bug, please contact us at sbaradar@usc.edu.