Use custom LLVM (#1971)

BPF SDK uses custom LLVM
This commit is contained in:
jackcmay 2018-11-30 14:33:29 -08:00 committed by GitHub
parent 3ca826a480
commit b00011a3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 50 additions and 117 deletions

View File

@ -1 +1,2 @@
/criterion-*
/llvm/native-*

View File

@ -13,12 +13,9 @@ TEST_DIR ?= ./test
OUT_DIR ?= ./out
ifeq ($(DOCKER),1)
LLVM_DIR = $(LOCAL_PATH)llvm/llvm-docker
LLVM_DIR = $(LOCAL_PATH)llvm/docker
else
OS=$(shell uname)
ifeq ($(OS),Darwin)
LLVM_DIR ?= $(shell brew --prefix llvm)
endif
LLVM_DIR = $(LOCAL_PATH)llvm/native-v0.0.1
endif
ifdef LLVM_DIR
@ -26,14 +23,11 @@ CC := $(LLVM_DIR)/bin/clang
CXX := $(LLVM_DIR)/bin/clang++
LLC := $(LLVM_DIR)/bin/llc
OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump
else
CC := clang-7
CXX := clang++-7
LLC := llc-7
OBJ_DUMP := llvm-objdump-7
endif
SYSTEM_INC_DIRS := $(LOCAL_PATH)inc
SYSTEM_INC_DIRS := \
$(LOCAL_PATH)inc \
$(LLVM_DIR)lib/clang/8.0.0/include \
C_FLAGS := \
-Werror \
@ -110,7 +104,6 @@ help:
@echo ' - Show commands while building: V=1'
@echo ' V=$(V)'
@echo ' - Use LLVM from docker: DOCKER=1'
@echo ' Docker image must be pulled first: docker pull solanalabs/llvm'
@echo ' DOCKER=$(DOCKER)'
@echo ' - List of include directories:'
@echo ' INC_DIRS=$(INC_DIRS)'

View File

@ -3,8 +3,10 @@
cd "$(dirname "$0")"/..
# Install Criterion for all supported platforms
# if changing version here must also change in bpf.mk
version=v2.3.2
(
if [[ ! -d criterion-$version ]]; then
(
[[ ! -d criterion-$version ]] || exit 0
set -ex
wget https://github.com/Snaipe/Criterion/releases/download/$version/criterion-$version-osx-x86_64.tar.bz2
@ -15,9 +17,38 @@ version=v2.3.2
[[ ! -f criterion-$version/README.md ]]
echo "https://github.com/Snaipe/Criterion/releases/tag/$version" > criterion-$version/README.md
)
# shellcheck disable=SC2181
if [[ $? -ne 0 ]]; then
)
# shellcheck disable=SC2181
if [[ $? -ne 0 ]]; then
rm -rf criterion-$version*
exit 1
fi
fi
# Install LLVM
# if changing version here must also change in bpf.mk
version=v0.0.1
if [ "$(uname)" == "Darwin" ]; then
machine=macos
else
machine=linux
fi
if [[ ! -d llvm/native-$version ]]; then
(
set -ex
mkdir -p llvm/native-$version
cd llvm/native-$version
wget https://github.com/solana-labs/llvm-builder/releases/download/$version/solana-llvm-$machine.tgz
tar xzf solana-llvm-$machine.tgz
rm -rf solana-llvm-$machine.tgz
[[ ! -f llvm/native-$version/README.md ]]
echo "https://github.com/solana-labs/solana-web3.js/releases/tag/$version" > README.md
)
fi
# shellcheck disable=SC2181
if [[ $? -ne 0 ]]; then
rm -rf llvm/native-$version
exit 1
fi

View File

@ -12,8 +12,7 @@ mkdir bpf-sdk/
git rev-parse HEAD
) > bpf-sdk/version.txt
"$SOLANA_ROOT"/programs/bpf/c/sdk/scripts/install.sh
cp -ra "$SOLANA_ROOT"/programs/bpf/c/sdk/* bpf-sdk/
rm -rf bpf-sdk/scripts/
rm -rf bpf-sdk/scripts/package.sh
tar jvcf bpf-sdk.tar.bz2 bpf-sdk/

View File

@ -1,68 +0,0 @@
# This docker file is based on the llvm docker file example located here:
# https://github.com/llvm-mirror/llvm/blob/master/utils/docker/debian8/Dockerfile
FROM launcher.gcr.io/google/debian8:latest as builder
LABEL maintainer "Solana Maintainers"
# Install build dependencies of llvm.
# First, Update the apt's source list and include the sources of the packages.
RUN grep deb /etc/apt/sources.list | \
sed 's/^deb/deb-src /g' >> /etc/apt/sources.list
# Install compiler, python and subversion.
RUN apt-get update && \
apt-get install -y \
--no-install-recommends \
ca-certificates gnupg \
build-essential \
python \
wget \
unzip \
git \
ssh && \
rm -rf /var/lib/apt/lists/*
# Install a newer ninja release. It seems the older version in the debian repos
# randomly crashes when compiling llvm.
RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" && \
echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" \
| sha256sum -c && \
unzip ninja-linux.zip -d /usr/local/bin && \
rm ninja-linux.zip
# Import public key required for verifying signature of cmake download.
RUN gpg --no-tty --keyserver hkp://pgp.mit.edu --recv 0x2D2CEF1034921684
# Download, verify and install cmake version that can compile clang into /usr/local.
# (Version in debian8 repos is too old)
RUN mkdir /tmp/cmake-install && cd /tmp/cmake-install && \
wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt.asc" && \
wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt" && \
gpg --verify cmake-3.7.2-SHA-256.txt.asc cmake-3.7.2-SHA-256.txt && \
wget "https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" && \
( grep "cmake-3.7.2-Linux-x86_64.tar.gz" cmake-3.7.2-SHA-256.txt | \
sha256sum -c - ) && \
tar xzf cmake-3.7.2-Linux-x86_64.tar.gz -C /usr/local --strip-components=1 && \
cd / && \
rm -rf /tmp/cmake-install
# ADD checksums /tmp/checksums
# ADD scripts /tmp/scripts
# Checkout the source code
RUN git clone https://github.com/solana-labs/llvm.git && \
git clone https://github.com/solana-labs/clang.git llvm/tools/clang && \
git clone https://github.com/solana-labs/clang-tools-extra.git llvm/tools/clang/tools/extra && \
git clone https://github.com/solana-labs/lld.git llvm/tools/lld && \
git clone https://github.com/solana-labs/compiler-rt.git llvm/projects/compiler-rt
RUN mkdir /llvm/build && \
cd /llvm/build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=$HOME/local -G "Ninja" .. && \
ninja -j6 && \
ninja install
# Produce stage 2 docker with just the peices needed
FROM launcher.gcr.io/google/debian8:latest
LABEL maintainer "Solana Maintainers"
COPY --from=builder root/local/bin /usr/local/bin

View File

@ -1,16 +0,0 @@
## Solana Customized LLVM
This Docker contains LLVM binaries that incorporate customizations and fixes required
by Solana but not yet upstreamed into the LLVM mainline.
https://hub.docker.com/r/solanalabs/llvm/
### Usage:
This Docker is optionally used by the SDK BPF build system.
For more information:
```bash
$ make help
```

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "$0")"
docker build -t solanalabs/llvm .
docker push solanalabs/llvm