Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 431769 of Building SpiderMonkey with UBSan

  • Revision slug: Building_SpiderMonkey_with_UBSan
  • Revision title: Building SpiderMonkey with UBSan
  • Revision id: 431769
  • Created:
  • Creator: Jesse
  • Is current revision? No
  • Comment

Revision Content

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

Please file bugs with [-fsanitize=X] in the status whiteboard, where X is the relevant sanitize option.

Revision Source

<p>1. <a href="https://developer.mozilla.org/en-US/docs/Building_Firefox_with_Address_Sanitizer#LLVM.2FClang" title="https://developer.mozilla.org/en-US/docs/Building_Firefox_with_Address_Sanitizer#LLVM.2FClang">Compile a recent version of LLVM &amp; Clang</a>.</p>
<p>2. Save the following bash script, fixing LLVM_ROOT to point to your installation.</p>
<pre>
#! /bin/sh

if [ -z $1 ] ; then
    echo "usage: $0 &lt;dirname&gt;"
elif [ -d $1 ] ; then
    echo "directory $1 already exists"
else
    autoconf2.13
    mkdir $1
    cd $1
    <strong>LLVM_ROOT="<span style="color:#ff0000;">/home/vagrant/llvm</span>"</strong>
    SANFLAG="<strong>-fsanitize=alignment,bool,bounds,enum,float-cast-overflow,integer-divide-by-zero,null,object-size,return,shift,signed-integer-overflow,unreachable,vla-bound</strong> -Dxmalloc=myxmalloc" \
    CC="$LLVM_ROOT/build/Release+Asserts/bin/clang" \
    CXX="$LLVM_ROOT/build/Release+Asserts/bin/clang++" \
    CFLAGS="$SANFLAG" \
    CXXFLAGS="$SANFLAG" \
    <strong>MOZ_LLVM_HACKS=1</strong> \
            ../configure --enable-debug --disable-optimize
    make -j 8
fi</pre>
<p>3. Use the script to compile SpiderMonkey.</p>
<p>The <strong><a href="https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation" title="https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation">sanitize options</a></strong> chosen above are all of the cheap undefined behavior checks other than:</p>
<ul>
  <li><strong>vptr</strong>, which requires RTTI, disabled by default in SpiderMonkey</li>
  <li><strong>float-divide-by-zero</strong>, which Jesse doesn't think is actually undefined behavior</li>
</ul>
<p>Please file bugs with [-fsanitize=X] in the status whiteboard, where X is the relevant sanitize option.</p>
Revert to this revision