1. Compile a recent version of LLVM & Clang.
2. Save the following bash script, fixing LLVM_ROOT to point to your installation.
#! /bin/sh
if [ -z $1 ] ; then
echo "usage: $0 <dirname>"
elif [ -d $1 ] ; then
echo "directory $1 already exists"
else
autoconf2.13
mkdir $1
cd $1
LLVM_ROOT="/home/vagrant/llvm"
SANFLAG="-fsanitize=alignment,bool,bounds,enum,float-cast-overflow,integer-divide-by-zero,null,object-size,return,shift,signed-integer-overflow,unreachable,vla-bound -Dxmalloc=myxmalloc" \
CC="$LLVM_ROOT/build/Release+Asserts/bin/clang" \
CXX="$LLVM_ROOT/build/Release+Asserts/bin/clang++" \
CFLAGS="$SANFLAG" \
CXXFLAGS="$SANFLAG" \
MOZ_LLVM_HACKS=1 \
../configure --enable-debug --disable-optimize
make -j 8
fi
3. Use the script to compile SpiderMonkey.
The sanitize options chosen above are all of the cheap undefined behavior checks other than:
- vptr, which requires RTTI, disabled by default in SpiderMonkey
- float-divide-by-zero, which Jesse doesn't think is actually undefined behavior
Known bugs. Please file new bugs with [-fsanitize=X] in the status whiteboard, where X is the relevant sanitize option.