Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tin-z/ef39f5a075d7fb17299319c0663459da to your computer and use it in GitHub Desktop.
Save tin-z/ef39f5a075d7fb17299319c0663459da to your computer and use it in GitHub Desktop.
Instructions for compiling browsers with custom llvm binaries

Chromium

Let's assume we're trying to build chromium with sancov. Although this is possible purely with gn arguments, I'll demonstrate this with system toolchain.

First, create a file at out/sancov/args.gn. The contents of the file should be as follows:

custom_toolchain="//build/toolchain/linux/unbundle:default"
host_toolchain="//build/toolchain/linux/unbundle:default"
is_clang = true
clang_use_chrome_plugins = false

Second, execute the following commands.

export LLVM_BIN_DIR="/usr/local/bin"
export CC="$LLVM_BIN_DIR/clang"
export CXX="$LLVM_BIN_DIR/clang++"
export AR="$LLVM_BIN_DIR/llvm-ar"
export SOLINK="$LLVM_BIN_DIR/lld"
export NM="$LLVM_BIN_DIR/llvm-nm"
export LDFLAGS="-fsanitize-coverage=trace-pc-guard"
gn gen out/sancov 
autoninja -C out/sancov chrome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment