
Also add unit tests. This is the first of several transformation (optimization/lowering) passes that I'd like to move to the new transform package. This separates the compiler from the optimizer. Also, it finally adds unit tests for the compiler, not just end-to-end compilation tests. This should improve robustness and should make it easier to change these transformation passes in the future. While the heap-to-stack transform is relatively simple, other passes are much more complex. Adding unit tests not only helps robustness over time, but also doubles as documentation as to what these transformation passes do exactly.
258 строки
7,9 КиБ
YAML
258 строки
7,9 КиБ
YAML
version: 2.1
|
|
|
|
commands:
|
|
submodules:
|
|
steps:
|
|
- run:
|
|
name: "Pull submodules"
|
|
command: git submodule update --init
|
|
apt-dependencies:
|
|
parameters:
|
|
llvm:
|
|
type: string
|
|
steps:
|
|
- run:
|
|
name: "Install apt dependencies"
|
|
command: |
|
|
echo 'deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch<<parameters.llvm>> main' | sudo tee /etc/apt/sources.list.d/llvm.list
|
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
|
|
sudo apt-get update
|
|
sudo apt-get install \
|
|
python3 \
|
|
llvm<<parameters.llvm>>-dev \
|
|
clang<<parameters.llvm>> \
|
|
libclang<<parameters.llvm>>-dev \
|
|
lld<<parameters.llvm>> \
|
|
gcc-arm-linux-gnueabihf \
|
|
libc6-dev-armel-cross \
|
|
gcc-aarch64-linux-gnu \
|
|
libc6-dev-arm64-cross \
|
|
qemu-system-arm \
|
|
qemu-user \
|
|
gcc-avr \
|
|
avr-libc
|
|
install-node:
|
|
steps:
|
|
- run:
|
|
name: "Install node.js"
|
|
command: |
|
|
wget https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
|
|
sudo tar -C /usr/local -xf node-v10.15.1-linux-x64.tar.xz
|
|
sudo ln -s /usr/local/node-v10.15.1-linux-x64/bin/node /usr/bin/node
|
|
rm node-v10.15.1-linux-x64.tar.xz
|
|
llvm-source-linux:
|
|
steps:
|
|
- restore_cache:
|
|
keys:
|
|
- llvm-source-8-v5
|
|
- run:
|
|
name: "Fetch LLVM source"
|
|
command: make llvm-source
|
|
- save_cache:
|
|
key: llvm-source-8-v5
|
|
paths:
|
|
- llvm-project
|
|
test-linux:
|
|
steps:
|
|
- checkout
|
|
- submodules
|
|
- apt-dependencies:
|
|
llvm: "-8"
|
|
- install-node
|
|
- restore_cache:
|
|
keys:
|
|
- go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
|
|
- go-cache-v2-{{ checksum "go.mod" }}
|
|
- llvm-source-linux
|
|
- run: go install .
|
|
- run: go test -v ./transform .
|
|
- run: make gen-device -j4
|
|
- run: make smoketest RISCV=0
|
|
- save_cache:
|
|
key: go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
|
|
paths:
|
|
- ~/.cache/go-build
|
|
- ~/.cache/tinygo
|
|
- /go/pkg/mod
|
|
- run: make fmt-check
|
|
build-linux:
|
|
steps:
|
|
- checkout
|
|
- submodules
|
|
- run:
|
|
name: "Install apt dependencies"
|
|
command: |
|
|
sudo apt-get install \
|
|
python3 \
|
|
gcc-arm-linux-gnueabihf \
|
|
binutils-arm-none-eabi \
|
|
libc6-dev-armel-cross \
|
|
gcc-aarch64-linux-gnu \
|
|
libc6-dev-arm64-cross \
|
|
qemu-system-arm \
|
|
qemu-user \
|
|
gcc-avr \
|
|
avr-libc
|
|
- install-node
|
|
- restore_cache:
|
|
keys:
|
|
- go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
|
|
- go-cache-v2-{{ checksum "go.mod" }}
|
|
- llvm-source-linux
|
|
- restore_cache:
|
|
keys:
|
|
- llvm-build-8-linux-v7
|
|
- run:
|
|
name: "Build LLVM"
|
|
command: |
|
|
if [ ! -f llvm-build/lib/liblldELF.a ]
|
|
then
|
|
# install dependencies
|
|
sudo apt-get install cmake clang ninja-build
|
|
# make build faster
|
|
export CC=clang
|
|
export CXX=clang++
|
|
# hack ninja to use less jobs
|
|
echo -e '#!/bin/sh\n/usr/bin/ninja -j3 "$@"' > /go/bin/ninja
|
|
chmod +x /go/bin/ninja
|
|
# build!
|
|
make llvm-build
|
|
fi
|
|
- save_cache:
|
|
key: llvm-build-8-linux-v7
|
|
paths:
|
|
llvm-build
|
|
- run:
|
|
name: "Create LLVM symlinks"
|
|
command: |
|
|
ln -s $PWD/llvm-build/bin/clang-8 /go/bin/clang-8
|
|
ln -s $PWD/llvm-build/bin/ld.lld /go/bin/ld.lld-8
|
|
ln -s $PWD/llvm-build/bin/wasm-ld /go/bin/wasm-ld-8
|
|
- run:
|
|
name: "Test TinyGo"
|
|
command: make test
|
|
- run:
|
|
name: "Build TinyGo release"
|
|
command: |
|
|
make release -j3
|
|
cp -p build/release.tar.gz /tmp/tinygo.linux-amd64.tar.gz
|
|
- store_artifacts:
|
|
path: /tmp/tinygo.linux-amd64.tar.gz
|
|
- save_cache:
|
|
key: go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
|
|
paths:
|
|
- ~/.cache/go-build
|
|
- ~/.cache/tinygo
|
|
- /go/pkg/mod
|
|
- run:
|
|
name: "Extract release tarball"
|
|
command: |
|
|
mkdir -p ~/lib
|
|
tar -C ~/lib -xf /tmp/tinygo.linux-amd64.tar.gz
|
|
ln -s ~/lib/tinygo/bin/tinygo /go/bin/tinygo
|
|
tinygo version
|
|
- run:
|
|
name: "Download SiFive GNU toolchain"
|
|
command: |
|
|
curl -O https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14.tar.gz
|
|
sudo tar -C /usr/local --strip-components=1 -xf riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14.tar.gz
|
|
- run: make smoketest
|
|
build-macos:
|
|
steps:
|
|
- checkout
|
|
- submodules
|
|
- run:
|
|
name: "Install dependencies"
|
|
command: |
|
|
curl https://dl.google.com/go/go1.12.5.darwin-amd64.tar.gz -o go1.12.5.darwin-amd64.tar.gz
|
|
sudo tar -C /usr/local -xzf go1.12.5.darwin-amd64.tar.gz
|
|
ln -s /usr/local/go/bin/go /usr/local/bin/go
|
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu
|
|
- restore_cache:
|
|
keys:
|
|
- llvm-source-8-macos-v5
|
|
- run:
|
|
name: "Fetch LLVM source"
|
|
command: make llvm-source
|
|
- save_cache:
|
|
key: llvm-source-8-macos-v5
|
|
paths:
|
|
- llvm-project
|
|
- restore_cache:
|
|
keys:
|
|
- llvm-build-8-macos-v6
|
|
- run:
|
|
name: "Build LLVM"
|
|
command: |
|
|
if [ ! -f llvm-build/lib/liblldELF.a ]
|
|
then
|
|
# install dependencies
|
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja
|
|
# build!
|
|
make llvm-build
|
|
fi
|
|
- save_cache:
|
|
key: llvm-build-8-macos-v6
|
|
paths:
|
|
llvm-build
|
|
- run:
|
|
name: "Create LLVM symlinks"
|
|
command: |
|
|
ln -s $PWD/llvm-build/bin/clang-8 /usr/local/bin/clang-8
|
|
- run:
|
|
name: "Test TinyGo"
|
|
command: make test
|
|
- run:
|
|
name: "Build TinyGo release"
|
|
command: |
|
|
make release -j3
|
|
cp -p build/release.tar.gz /tmp/tinygo.darwin-amd64.tar.gz
|
|
- store_artifacts:
|
|
path: /tmp/tinygo.darwin-amd64.tar.gz
|
|
- run:
|
|
name: "Extract release tarball"
|
|
command: |
|
|
mkdir -p ~/lib
|
|
tar -C /usr/local/opt -xf /tmp/tinygo.darwin-amd64.tar.gz
|
|
ln -s /usr/local/opt/tinygo/bin/tinygo /usr/local/bin/tinygo
|
|
tinygo version
|
|
- run:
|
|
name: "Download SiFive GNU toolchain"
|
|
command: |
|
|
curl -O https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-apple-darwin.tar.gz
|
|
sudo tar -C /usr/local --strip-components=1 -xf riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-apple-darwin.tar.gz
|
|
- run: make smoketest AVR=0
|
|
|
|
|
|
jobs:
|
|
test-llvm8-go111:
|
|
docker:
|
|
- image: circleci/golang:1.11-stretch
|
|
steps:
|
|
- test-linux
|
|
test-llvm8-go112:
|
|
docker:
|
|
- image: circleci/golang:1.12-stretch
|
|
steps:
|
|
- test-linux
|
|
build-linux:
|
|
docker:
|
|
- image: circleci/golang:1.12-stretch
|
|
steps:
|
|
- build-linux
|
|
build-macos:
|
|
macos:
|
|
xcode: "10.1.0"
|
|
steps:
|
|
- build-macos
|
|
|
|
|
|
|
|
|
|
workflows:
|
|
test-all:
|
|
jobs:
|
|
- test-llvm8-go111
|
|
- test-llvm8-go112
|
|
- build-linux
|
|
- build-macos
|