Last active
April 28, 2022 13:02
-
-
Save langston-barrett/67863fa789cd66e69af971644c28e04a to your computer and use it in GitHub Desktop.
Linux Kernel LLVM Bitcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker build -t gllvm-linux . | |
# docker run --rm --workdir=/work --mount type=bind,src=$PWD,target=/work -it gllvm-linux | |
FROM ubuntu:21.10 | |
# Configuration | |
ARG LLVM_VERSION=11 | |
ARG KERNEL_MAJOR_VERSION=5 | |
ARG KERNEL_MINOR_VERSION=17 | |
# Environment | |
ENV KERNEL_VERSION=${KERNEL_MAJOR_VERSION}.${KERNEL_MINOR_VERSION} | |
ENV LLVM_VERSION=${LLVM_VERSION} | |
ENV LLVM_COMPILER=clang | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install build dependencies | |
RUN apt-get update -qq -y | |
RUN apt-get install -qq -y build-essential curl dbus-x11 file git golang-go flex bison bc libncurses5-dev libelf-dev libssl-dev | |
RUN apt-get install -qq -y llvm-${LLVM_VERSION} clang-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev lld-${LLVM_VERSION} | |
# Get the kernel | |
RUN curl -O "https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_MAJOR_VERSION}.x/linux-${KERNEL_VERSION}.tar.xz" | |
RUN tar xf linux-${KERNEL_VERSION}.tar.xz | |
WORKDIR linux-${KERNEL_VERSION} | |
# Build it | |
ENV GOPATH=/gopath | |
ENV PATH=$PATH:$GOPATH/bin:/usr/lib/llvm-${LLVM_VERSION}/bin | |
RUN go get github.com/SRI-CSL/gllvm/cmd/... | |
RUN make -j CC=gclang HOSTCC=gclang LLVM=1 CONFIG_CC_IS_CLANG=1 tinyconfig | |
RUN make -j CC=gclang HOSTCC=gclang LLVM=1 CONFIG_CC_IS_CLANG=1 | |
CMD get-bc -o /work/vmlinux-${KERNEL_VERSION}-llvm-${LLVM_VERSION}.bc -m /linux-${KERNEL_VERSION}/vmlinux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
for llvm in 13 12 11 10 9 8; do | |
docker build \ | |
--tag=gllvm-linux \ | |
--build-arg LLVM_VERSION="${llvm}" \ | |
--tag=gllvm-linux \ | |
. | |
docker run \ | |
--rm \ | |
--workdir=/work \ | |
--mount type=bind,src="${PWD}",target=/work \ | |
--interactive \ | |
--tty \ | |
gllvm-linux | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment