Skip to content

Commit

Permalink
main: switch to LLVM 10
Browse files Browse the repository at this point in the history
This commit also adds a bit of version independence, in particular for
external commands. It also adds the LLVM version to the `tinygo version`
command, which might help while debugging.
  • Loading branch information
aykevl authored and deadprogram committed Apr 9, 2020
1 parent 584e94c commit 0afd42c
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 118 deletions.
42 changes: 21 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,32 @@ commands:
steps:
- restore_cache:
keys:
- llvm-source-9-v0
- llvm-source-10-v0
- run:
name: "Fetch LLVM source"
command: make llvm-source
- save_cache:
key: llvm-source-9-v0
key: llvm-source-10-v0
paths:
- llvm-project
build-wasi-libc:
steps:
- restore_cache:
keys:
- wasi-libc-sysroot-v1
- wasi-libc-sysroot-v2
- run:
name: "Build wasi-libc"
command: make wasi-libc
- save_cache:
key: wasi-libc-sysroot-v1
key: wasi-libc-sysroot-v2
paths:
- lib/wasi-libc/sysroot
test-linux:
steps:
- checkout
- submodules
- apt-dependencies:
llvm: "-9"
llvm: "-10"
- install-node
- restore_cache:
keys:
Expand All @@ -76,10 +76,10 @@ commands:
- run: go install .
- restore_cache:
keys:
- wasi-libc-sysroot-systemclang-v0
- wasi-libc-sysroot-systemclang-v1
- run: make wasi-libc
- save_cache:
key: wasi-libc-sysroot-systemclang-v0
key: wasi-libc-sysroot-systemclang-v1
paths:
- lib/wasi-libc/sysroot
- run: go test -v ./cgo ./compileopts ./interp ./transform .
Expand Down Expand Up @@ -117,7 +117,7 @@ commands:
- llvm-source-linux
- restore_cache:
keys:
- llvm-build-9-linux-v0-assert
- llvm-build-10-linux-v0-assert
- run:
name: "Build LLVM"
command: |
Expand All @@ -135,7 +135,7 @@ commands:
make ASSERT=1 llvm-build
fi
- save_cache:
key: llvm-build-9-linux-v0-assert
key: llvm-build-10-linux-v0-assert
paths:
llvm-build
- run: make ASSERT=1
Expand Down Expand Up @@ -176,7 +176,7 @@ commands:
- llvm-source-linux
- restore_cache:
keys:
- llvm-build-9-linux-v0
- llvm-build-10-linux-v0
- run:
name: "Build LLVM"
command: |
Expand All @@ -194,7 +194,7 @@ commands:
make llvm-build
fi
- save_cache:
key: llvm-build-9-linux-v0
key: llvm-build-10-linux-v0
paths:
llvm-build
- build-wasi-libc
Expand Down Expand Up @@ -239,17 +239,17 @@ commands:
- go-cache-macos-v2-{{ checksum "go.mod" }}
- restore_cache:
keys:
- llvm-source-9-macos-v0
- llvm-source-10-macos-v0
- run:
name: "Fetch LLVM source"
command: make llvm-source
- save_cache:
key: llvm-source-9-macos-v0
key: llvm-source-10-macos-v0
paths:
- llvm-project
- restore_cache:
keys:
- llvm-build-9-macos-v0
- llvm-build-10-macos-v0
- run:
name: "Build LLVM"
command: |
Expand All @@ -261,7 +261,7 @@ commands:
make llvm-build
fi
- save_cache:
key: llvm-build-9-macos-v0
key: llvm-build-10-macos-v0
paths:
llvm-build
- restore_cache:
Expand Down Expand Up @@ -306,17 +306,17 @@ commands:


jobs:
test-llvm9-go111:
test-llvm10-go111:
docker:
- image: circleci/golang:1.11-buster
steps:
- test-linux
test-llvm9-go112:
test-llvm10-go112:
docker:
- image: circleci/golang:1.12-buster
steps:
- test-linux
test-llvm9-go113:
test-llvm10-go113:
docker:
- image: circleci/golang:1.13-buster
steps:
Expand All @@ -343,9 +343,9 @@ jobs:
workflows:
test-all:
jobs:
- test-llvm9-go111
- test-llvm9-go112
- test-llvm9-go113
- test-llvm10-go111
- test-llvm10-go112
- test-llvm10-go113
- build-linux
- build-macos
- assert-test-linux
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# TinyGo base stage installs Go 1.13, LLVM 9 and the TinyGo compiler itself.
# TinyGo base stage installs Go 1.13, LLVM 10 and the TinyGo compiler itself.
FROM golang:1.13 AS tinygo-base

RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >> /etc/apt/sources.list && \
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-10 main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y llvm-9-dev libclang-9-dev git
apt-get install -y llvm-10-dev libclang-10-dev git

COPY . /tinygo

Expand All @@ -28,9 +28,9 @@ COPY --from=tinygo-base /tinygo/src /tinygo/src
COPY --from=tinygo-base /tinygo/targets /tinygo/targets

RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >> /etc/apt/sources.list && \
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-10 main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y libllvm9 lld-9
apt-get install -y libllvm10 lld-10

# tinygo-avr stage installs the needed dependencies to compile TinyGo programs for AVR microcontrollers.
FROM tinygo-base AS tinygo-avr
Expand Down Expand Up @@ -61,7 +61,7 @@ COPY --from=tinygo-base /tinygo/lib /tinygo/lib

RUN cd /tinygo/ && \
apt-get update && \
apt-get install -y apt-utils make clang-9 && \
apt-get install -y apt-utils make clang-10 && \
make gen-device-nrf && make gen-device-stm32

# tinygo-all stage installs the needed dependencies to compile TinyGo programs for all platforms.
Expand All @@ -73,7 +73,7 @@ COPY --from=tinygo-base /tinygo/lib /tinygo/lib

RUN cd /tinygo/ && \
apt-get update && \
apt-get install -y apt-utils make clang-9 binutils-avr gcc-avr avr-libc && \
apt-get install -y apt-utils make clang-10 binutils-avr gcc-avr avr-libc && \
make gen-device

CMD ["tinygo"]
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
ifneq (, $(shell command -v llvm-build/bin/clang 2> /dev/null))
CLANG ?= $(abspath llvm-build/bin/clang)
else
CLANG ?= clang-9
CLANG ?= clang-10
endif
ifneq (, $(shell command -v llvm-build/bin/llvm-ar 2> /dev/null))
LLVM_AR ?= $(abspath llvm-build/bin/llvm-ar)
else ifneq (, $(shell command -v llvm-ar-9 2> /dev/null))
LLVM_AR ?= llvm-ar-9
else ifneq (, $(shell command -v llvm-ar-10 2> /dev/null))
LLVM_AR ?= llvm-ar-10
else
LLVM_AR ?= llvm-ar
endif
ifneq (, $(shell command -v llvm-build/bin/llvm-nm 2> /dev/null))
LLVM_NM ?= $(abspath llvm-build/bin/llvm-nm)
else ifneq (, $(shell command -v llvm-nm-9 2> /dev/null))
LLVM_NM ?= llvm-nm-9
else ifneq (, $(shell command -v llvm-nm-10 2> /dev/null))
LLVM_NM ?= llvm-nm-10
else
LLVM_NM ?= llvm-nm
endif
Expand Down Expand Up @@ -53,7 +53,7 @@ endif

.PHONY: all tinygo test $(LLVM_BUILDDIR) llvm-source clean fmt gen-device gen-device-nrf gen-device-avr

LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfodwarf executionengine instrumentation interpreter ipo irreader linker lto mc mcjit objcarcopts option profiledata scalaropts support target
LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfodwarf executionengine frontendopenmp instrumentation interpreter ipo irreader linker lto mc mcjit objcarcopts option profiledata scalaropts support target

ifeq ($(OS),Windows_NT)
EXE = .exe
Expand Down Expand Up @@ -103,8 +103,8 @@ LLD_LIBS = $(START_GROUP) -llldCOFF -llldCommon -llldCore -llldDriver -llldELF -
# For static linking.
ifneq ("$(wildcard $(LLVM_BUILDDIR)/bin/llvm-config*)","")
CGO_CPPFLAGS=$(shell $(LLVM_BUILDDIR)/bin/llvm-config --cppflags) -I$(abspath $(LLVM_BUILDDIR))/tools/clang/include -I$(abspath $(CLANG_SRC))/include -I$(abspath $(LLD_SRC))/include
CGO_CXXFLAGS=-std=c++11
CGO_LDFLAGS+=$(LIBCLANG_PATH) -std=c++11 -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
CGO_CXXFLAGS=-std=c++14
CGO_LDFLAGS+=$(LIBCLANG_PATH) -std=c++14 -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
endif


Expand Down Expand Up @@ -148,7 +148,7 @@ gen-device-stm32: build/gen-device-svd

# Get LLVM sources.
$(LLVM_PROJECTDIR)/README.md:
git clone -b release/9.x https://github.com/llvm/llvm-project $(LLVM_PROJECTDIR)
git clone -b release/10.x https://github.com/llvm/llvm-project $(LLVM_PROJECTDIR)
llvm-source: $(LLVM_PROJECTDIR)/README.md

# Configure LLVM.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ The original reasoning was: if [Python](https://micropython.org/) can run on mic

This project is licensed under the BSD 3-clause license, just like the [Go project](https://golang.org/LICENSE) itself.

Some code has been copied from the LLVM project and is therefore licensed under [a variant of the Apache 2.0 license](http://releases.llvm.org/9.0.0/LICENSE.TXT). This has been clearly indicated in the header of these files.
Some code has been copied from the LLVM project and is therefore licensed under [a variant of the Apache 2.0 license](http://releases.llvm.org/10.0.0/LICENSE.TXT). This has been clearly indicated in the header of these files.
12 changes: 4 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
steps:
- task: GoTool@0
inputs:
version: '1.13.8'
version: '1.13.8'
- checkout: self
- task: CacheBeta@0
displayName: Cache LLVM source
inputs:
key: llvm-source-9-windows-v0
key: llvm-source-10-windows-v0
path: llvm-project
- task: Bash@3
displayName: Download LLVM source
Expand All @@ -27,7 +27,7 @@ jobs:
- task: CacheBeta@0
displayName: Cache LLVM build
inputs:
key: llvm-build-9-windows-v0
key: llvm-build-10-windows-v0
path: llvm-build
- task: Bash@3
displayName: Build LLVM
Expand All @@ -37,10 +37,6 @@ jobs:
if [ ! -f llvm-build/lib/liblldELF.a ]
then
choco install ninja
# LLVM 9 cannot be built with MinGW 8.
# For details: https://reviews.llvm.org/D70266
choco uninstall mingw
choco install mingw --version=7.3.0
make llvm-build
fi
- task: Bash@3
Expand All @@ -51,7 +47,7 @@ jobs:
- task: CacheBeta@0
displayName: Cache wasi-libc sysroot
inputs:
key: wasi-libc-sysroot-v1
key: wasi-libc-sysroot-v2
path: lib/wasi-libc/sysroot
- task: Bash@3
displayName: Build wasi-libc
Expand Down
Loading

0 comments on commit 0afd42c

Please sign in to comment.