Skip to content

Instantly share code, notes, and snippets.

@nathanchance
Created April 18, 2020 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanchance/9a9be43ee4eb393952f6ac18e77fb7e2 to your computer and use it in GitHub Desktop.
Save nathanchance/9a9be43ee4eb393952f6ac18e77fb7e2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Where the script is located
BASE=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
TC_BLD=${BASE}/tc-build
LINUX_SRC=${BASE}/linux
# Build the compiler.
# Explanation of flags:
# * '--assertions': The bug only happens with assertions.
# * '--build-stage1-only': Speeds up the build since the script is
# the script is two stage by default.
# * '--no-update': We do not want the script trying to checkout a
# revision different from the one we are currently testing.
# * '--projects clang': by default, the script builds clang, compiler-rt,
# lld, and polly. We know this bug lies only in clang.
# * '--targets "RISCV;X86"': We only need the RISC-V (target) and X86 (host)
# backends. Avoid building the others to speed up the build (slightly).
# If the compiler cannot be built, exit 125 because it is untestable.
"${TC_BLD}"/build-llvm.py \
--assertions \
--build-stage1-only \
--no-update \
--projects clang \
--targets "RISCV;X86" || exit 125
# Build the Linux kernel (specifically 'crypto/jitterentropy.o' because that
# is the translation unit with the error)
# Removing the out folder is to avoid potential issues with distclean
# PATH is needed so that the toolchain we built above is used, as well as
# having access to riscv64 binutils
# Being the last line of the script means that its exit code will be the
# exit code of the script
rm -rf "${LINUX_SRC}"/out && \
PATH=${TC_BLD}/build/llvm/stage1/bin:${TC_BLD}/install/bin:${PATH} \
make -C "${LINUX_SRC}" \
-j"$(nproc)" \
-s \
ARCH=riscv \
CC=clang \
CROSS_COMPILE=riscv64-linux-gnu- \
LD=riscv64-linux-gnu-ld \
LLVM=1 \
LLVM_IAS=1 \
O=out/riscv64 \
allyesconfig \
crypto/jitterentropy.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment