├── .gitignore ├── .travis.yml ├── osx ├── README.md └── build.sh ├── shellcheck.sh ├── linux ├── README.md ├── build.sh ├── .travis.yml.unused └── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | deploy 2 | osx/out 3 | linux/out 4 | 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: c 3 | os: linux 4 | compiler: gcc 5 | services: docker 6 | 7 | notifications: 8 | email: false 9 | 10 | script: 11 | - ./shellcheck.sh 12 | -------------------------------------------------------------------------------- /osx/README.md: -------------------------------------------------------------------------------- 1 | ## Solana Customized LLVM MacOS 2 | 3 | Builds natively on MacOS 4 | 5 | ### Dependencies 6 | 7 | * clang by Xcode6 or later 8 | * cmake 9 | * ninja 10 | 11 | To install cmake and ninja you can use https://brew.sh 12 | 13 | ```bash 14 | brew update 15 | brew install cmake 16 | brew install ninja 17 | ``` 18 | 19 | 20 | -------------------------------------------------------------------------------- /shellcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Reference: https://github.com/koalaman/shellcheck/wiki/Directive 4 | set -e 5 | 6 | cd "$(dirname "$0")" 7 | 8 | set -x 9 | docker pull koalaman/shellcheck 10 | find . -name "*.sh" \ 11 | -not -regex ".*/llvm/.*" \ 12 | -print0 \ 13 | | xargs -0 \ 14 | docker run --workdir /llvm-builder --volume "$PWD:/llvm-builder" --rm koalaman/shellcheck --color=always --external-sources --shell=bash 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /linux/README.md: -------------------------------------------------------------------------------- 1 | ## Solana Customized LLVM for Linux 2 | 3 | This Docker contains LLVM binaries that incorporate customizations and fixes required 4 | by Solana but not yet upstreamed into the LLVM mainline. 5 | 6 | https://hub.docker.com/r/solanalabs/llvm/ 7 | 8 | ### Usage: 9 | 10 | This Docker is optionally used by the Solana SDK BPF build system. 11 | 12 | ### Notes: 13 | 14 | Attempting to build llvm im travis-ci takes too long and times out, leaving .travis.yml file here for reference and possibly using CI in the future. 15 | 16 | -------------------------------------------------------------------------------- /linux/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | cd "$(dirname "$0")" 5 | 6 | docker build --no-cache -t solanalabs/llvm . 7 | 8 | rm -rf out 9 | mkdir -p out 10 | cd out 11 | 12 | # Copy out and bundle release products 13 | mkdir -p deploy 14 | id=$(docker create solanalabs/llvm) 15 | docker cp "$id":/usr/local/version.md deploy 16 | docker cp "$id":/usr/local/bin deploy 17 | docker cp "$id":/usr/local/lib deploy 18 | docker rm -v "$id" 19 | tar -C deploy -jcf solana-llvm-linux.tar.bz2 . 20 | 21 | docker push solanalabs/llvm 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Customized LLVM binaries for Solana 2 | 3 | Builds LLVM binaries that incorporate customizations and fixes required 4 | by Solana but not yet upstreamed into the LLVM mainline. 5 | 6 | * Builds LLVM for Linux (Debian) 7 | * Builds LLVM for MacOS natively therefore skipped if not building on a Mac 8 | * Results in tarballs in `/deploy` that can be released 9 | 10 | ### Building 11 | 12 | ```bash 13 | $ ./build.sh 14 | ``` 15 | 16 | * Builds LLVM for Linux in Docker, tags and pushes `solanalabs/llvm` 17 | * Copies LLVM for Linux out of Docker the zips the products into `/deploy` 18 | * Builds LLVM for MacOS natively and zips the products into `/deploy` 19 | 20 | ### Releases 21 | 22 | This repo depends on the following: 23 | 24 | * https://github.com/solana-labs/llvm 25 | * https://github.com/solana-labs/clang 26 | * https://github.com/solana-labs/clang-tools-extra 27 | * https://github.com/solana-labs/compiler-rt 28 | * https://github.com/solana-labs/lld 29 | 30 | Any changes that need to go into an LLVM release must be made in the appropriate repos listed above. 31 | 32 | * See `linux/Dockerfile` for an example of how to sync and build for Linux 33 | * See `macos/build.sh` for an example of how to sync and build for MacOS 34 | -------------------------------------------------------------------------------- /osx/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | cd "$(dirname "$0")" 5 | 6 | rm -rf out 7 | mkdir -p out 8 | cd out 9 | 10 | git clone https://github.com/solana-labs/llvm.git 11 | echo "$( cd llvm && git rev-parse HEAD ) https://github.com/solana-labs/llvm.git" >> version.md 12 | git clone https://github.com/solana-labs/clang.git llvm/tools/clang 13 | echo "$( cd llvm/tools/clang && git rev-parse HEAD ) https://github.com/solana-labs/clang.git" >> version.md 14 | git clone https://github.com/solana-labs/clang-tools-extra.git llvm/tools/clang/tools/extra 15 | echo "$( cd llvm/tools/clang/tools/extra && git rev-parse HEAD ) https://github.com/solana-labs/clang-tools-extra.git" >> version.md 16 | git clone https://github.com/solana-labs/compiler-rt.git llvm/projects/compiler-rt 17 | echo "$( cd llvm/projects/compiler-rt && git rev-parse HEAD ) https://github.com/solana-labs/compiler-rt.git" >> version.md 18 | git clone https://github.com/solana-labs/lld.git llvm/tools/lld 19 | echo "$( cd llvm/tools/lld && git rev-parse HEAD ) https://github.com/solana-labs/lld.git" >> version.md 20 | 21 | mkdir -p llvm/build 22 | pushd llvm/build 23 | cmake -DCMAKE_BUILD_TYPE="Release" -G "Ninja" .. 24 | ninja llvm-ar 25 | ninja clang 26 | ninja llc 27 | ninja lld 28 | ninja llvm-objcopy 29 | ninja llvm-objdump 30 | 31 | popd 32 | 33 | rm -rf deploy 34 | mkdir -p deploy/lib 35 | cp version.md deploy 36 | cp -rf llvm/build/bin deploy 37 | cp -rf llvm/build/lib/clang deploy/lib 38 | tar -C deploy -jcf solana-llvm-osx.tar.bz2 . 39 | -------------------------------------------------------------------------------- /linux/.travis.yml.unused: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: c 3 | os: linux 4 | compiler: gcc 5 | services: docker 6 | 7 | notifications: 8 | email: false 9 | 10 | install: 11 | # - cat /etc/apt/sources.list 12 | # - grep deb /etc/apt/sources.list | sed 's/^deb/deb-src /g' >> /etc/apt/sources.list 13 | # - cat /etc/apt/sources.list 14 | - sudo apt-get update 15 | - | 16 | sudo apt-get install -y \ 17 | --no-install-recommends \ 18 | ca-certificates gnupg \ 19 | build-essential \ 20 | python \ 21 | wget \ 22 | unzip \ 23 | git \ 24 | ssh \ 25 | clang \ 26 | llvm 27 | - sudo rm -rf /var/lib/apt/lists/* 28 | - wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" 29 | - echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" | sha256sum -c 30 | - sudo unzip ninja-linux.zip -d /usr/local/bin 31 | - rm ninja-linux.zip 32 | # - gpg --no-tty --keyserver hkp://pgp.mit.edu --recv 0x2D2CEF1034921684 33 | - mkdir /tmp/cmake-install 34 | - pushd /tmp/cmake-install 35 | - wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt.asc" 36 | - wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt" 37 | # - gpg --verify cmake-3.7.2-SHA-256.txt.asc cmake-3.7.2-SHA-256.txt 38 | - wget "https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" 39 | - ( grep "cmake-3.7.2-Linux-x86_64.tar.gz" cmake-3.7.2-SHA-256.txt | sha256sum -c - ) 40 | - sudo tar xzf cmake-3.7.2-Linux-x86_64.tar.gz -C /usr/local --strip-components=1 41 | - popd 42 | - rm -rf /tmp/cmake-install 43 | 44 | script: 45 | - git clone https://github.com/solana-labs/llvm.git 46 | - git clone https://github.com/solana-labs/clang.git llvm/tools/clang 47 | - git clone https://github.com/solana-labs/clang-tools-extra.git llvm/tools/clang/tools/extra 48 | - git clone https://github.com/solana-labs/compiler-rt.git llvm/projects/compiler-rt 49 | # - git clone https://github.com/solana-labs/lld.git llvm/tools/lld 50 | - mkdir llvm/build 51 | - cd llvm/build 52 | # - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=$HOME/local -G "Ninja" .. 53 | - CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_USE_LINKER=gold -DCMAKE_INSTALL_PREFIX=$HOME/local -G "Ninja" .. 54 | - ninja -j2 clang 55 | # - ninja install 56 | # - ls /root/local/bin 57 | 58 | before_deploy: 59 | - rm -rf deploy 60 | - mkdir -p deploy 61 | - cp -r /usr/local/bin deploy/solana-llvm-$TRAVIS_BRANCH 62 | - ( cd deploy; tar zcf solana-llvm.tgz solana-llvm-$TRAVIS_BRANCH ) 63 | - git config --local user.name jackcmay 64 | - git config --local user.email jack@solana.com 65 | - export TRAVIS_TAG=${TRAVIS_TAG:-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)} 66 | - git tag $TRAVIS_TAG 67 | 68 | deploy: 69 | - provider: releases 70 | skip_cleanup: true 71 | api_key: 72 | secure: $GITHUB_TOKEN 73 | file: deploy/solana-llvm.tgz 74 | draft: true 75 | on: 76 | repo: solanalabs/llvm-builder 77 | branch: master 78 | tags: true 79 | -------------------------------------------------------------------------------- /linux/Dockerfile: -------------------------------------------------------------------------------- 1 | # This docker file is based on the llvm docker file example located here: 2 | # https://github.com/llvm-mirror/llvm/blob/master/utils/docker/debian8/Dockerfile 3 | 4 | FROM launcher.gcr.io/google/debian9:latest as builder 5 | LABEL maintainer "Solana Maintainers" 6 | 7 | # Install build dependencies of llvm. 8 | # First, Update the apt's source list and include the sources of the packages. 9 | RUN grep deb /etc/apt/sources.list | \ 10 | sed 's/^deb/deb-src /g' >> /etc/apt/sources.list 11 | 12 | # Install compiler, python and subversion. 13 | RUN apt-get update && \ 14 | apt-get install -y \ 15 | --no-install-recommends \ 16 | ca-certificates gnupg \ 17 | build-essential \ 18 | python \ 19 | wget \ 20 | unzip \ 21 | git \ 22 | ssh && \ 23 | rm -rf /var/lib/apt/lists/* 24 | 25 | # Install a newer ninja release. It seems the older version in the debian repos 26 | # randomly crashes when compiling llvm. 27 | RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" && \ 28 | echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" \ 29 | | sha256sum -c && \ 30 | unzip ninja-linux.zip -d /usr/local/bin && \ 31 | rm ninja-linux.zip 32 | 33 | # Import public key required for verifying signature of cmake download. 34 | #RUN gpg --no-tty --keyserver hkp://pgp.mit.edu:80 --recv 0x2D2CEF1034921684 35 | 36 | # Download, verify and install cmake version that can compile clang into /usr/local. 37 | # (Version in debian8 repos is too old) 38 | RUN mkdir /tmp/cmake-install && cd /tmp/cmake-install && \ 39 | wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt.asc" && \ 40 | wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt" && \ 41 | #gpg --verify cmake-3.7.2-SHA-256.txt.asc cmake-3.7.2-SHA-256.txt && \ 42 | wget "https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" && \ 43 | ( grep "cmake-3.7.2-Linux-x86_64.tar.gz" cmake-3.7.2-SHA-256.txt | \ 44 | sha256sum -c - ) && \ 45 | tar xzf cmake-3.7.2-Linux-x86_64.tar.gz -C /usr/local --strip-components=1 && \ 46 | cd / && \ 47 | rm -rf /tmp/cmake-install 48 | 49 | # ADD checksums /tmp/checksums 50 | # ADD scripts /tmp/scripts 51 | 52 | # Checkout the source code 53 | RUN git clone https://github.com/solana-labs/llvm.git && \ 54 | echo "$( cd llvm && git rev-parse HEAD ) https://github.com/solana-labs/llvm.git" >> version.md && \ 55 | git clone https://github.com/solana-labs/clang.git llvm/tools/clang && \ 56 | echo "$( cd llvm/tools/clang && git rev-parse HEAD ) https://github.com/solana-labs/clang.git" >> version.md && \ 57 | git clone https://github.com/solana-labs/clang-tools-extra.git llvm/tools/clang/tools/extra && \ 58 | echo "$( cd llvm/tools/clang/tools/extra && git rev-parse HEAD ) https://github.com/solana-labs/clang-tools-extra.git" >> version.md && \ 59 | git clone https://github.com/solana-labs/compiler-rt.git llvm/projects/compiler-rt && \ 60 | echo "$( cd llvm/projects/compiler-rt && git rev-parse HEAD ) https://github.com/solana-labs/compiler-rt.git" >> version.md && \ 61 | git clone https://github.com/solana-labs/lld.git llvm/tools/lld && \ 62 | echo "$( cd llvm/tools/lld && git rev-parse HEAD ) https://github.com/solana-labs/lld.git" >> version.md 63 | 64 | 65 | RUN mkdir /llvm/build && \ 66 | cd /llvm/build && \ 67 | cmake -DCMAKE_BUILD_TYPE=Release \ 68 | -DLLVM_USE_LINKER=gold \ 69 | -DCMAKE_INSTALL_PREFIX=$HOME/local \ 70 | -G "Ninja" \ 71 | .. && \ 72 | ninja llvm-ar && \ 73 | ninja clang && \ 74 | ninja llc && \ 75 | ninja lld && \ 76 | ninja llvm-objcopy && \ 77 | ninja llvm-objdump 78 | 79 | # Produce stage 2 docker with just the peices needed 80 | FROM launcher.gcr.io/google/debian9:latest 81 | LABEL maintainer "Solana Maintainers" 82 | COPY --from=builder version.md /usr/local 83 | COPY --from=builder llvm/build/bin /usr/local/bin 84 | COPY --from=builder llvm/build/lib/clang /usr/local/lib/clang 85 | 86 | # Install ld 87 | RUN apt-get update && \ 88 | apt-get install -y --no-install-recommends build-essential && \ 89 | rm -rf /var/lib/apt/lists/* 90 | --------------------------------------------------------------------------------