Skip to content

Commit 0afd42c

Browse files
aykevldeadprogram
authored andcommitted
main: switch to LLVM 10
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.
1 parent 584e94c commit 0afd42c

25 files changed

+165
-118
lines changed

.circleci/config.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,32 @@ commands:
4141
steps:
4242
- restore_cache:
4343
keys:
44-
- llvm-source-9-v0
44+
- llvm-source-10-v0
4545
- run:
4646
name: "Fetch LLVM source"
4747
command: make llvm-source
4848
- save_cache:
49-
key: llvm-source-9-v0
49+
key: llvm-source-10-v0
5050
paths:
5151
- llvm-project
5252
build-wasi-libc:
5353
steps:
5454
- restore_cache:
5555
keys:
56-
- wasi-libc-sysroot-v1
56+
- wasi-libc-sysroot-v2
5757
- run:
5858
name: "Build wasi-libc"
5959
command: make wasi-libc
6060
- save_cache:
61-
key: wasi-libc-sysroot-v1
61+
key: wasi-libc-sysroot-v2
6262
paths:
6363
- lib/wasi-libc/sysroot
6464
test-linux:
6565
steps:
6666
- checkout
6767
- submodules
6868
- apt-dependencies:
69-
llvm: "-9"
69+
llvm: "-10"
7070
- install-node
7171
- restore_cache:
7272
keys:
@@ -76,10 +76,10 @@ commands:
7676
- run: go install .
7777
- restore_cache:
7878
keys:
79-
- wasi-libc-sysroot-systemclang-v0
79+
- wasi-libc-sysroot-systemclang-v1
8080
- run: make wasi-libc
8181
- save_cache:
82-
key: wasi-libc-sysroot-systemclang-v0
82+
key: wasi-libc-sysroot-systemclang-v1
8383
paths:
8484
- lib/wasi-libc/sysroot
8585
- run: go test -v ./cgo ./compileopts ./interp ./transform .
@@ -117,7 +117,7 @@ commands:
117117
- llvm-source-linux
118118
- restore_cache:
119119
keys:
120-
- llvm-build-9-linux-v0-assert
120+
- llvm-build-10-linux-v0-assert
121121
- run:
122122
name: "Build LLVM"
123123
command: |
@@ -135,7 +135,7 @@ commands:
135135
make ASSERT=1 llvm-build
136136
fi
137137
- save_cache:
138-
key: llvm-build-9-linux-v0-assert
138+
key: llvm-build-10-linux-v0-assert
139139
paths:
140140
llvm-build
141141
- run: make ASSERT=1
@@ -176,7 +176,7 @@ commands:
176176
- llvm-source-linux
177177
- restore_cache:
178178
keys:
179-
- llvm-build-9-linux-v0
179+
- llvm-build-10-linux-v0
180180
- run:
181181
name: "Build LLVM"
182182
command: |
@@ -194,7 +194,7 @@ commands:
194194
make llvm-build
195195
fi
196196
- save_cache:
197-
key: llvm-build-9-linux-v0
197+
key: llvm-build-10-linux-v0
198198
paths:
199199
llvm-build
200200
- build-wasi-libc
@@ -239,17 +239,17 @@ commands:
239239
- go-cache-macos-v2-{{ checksum "go.mod" }}
240240
- restore_cache:
241241
keys:
242-
- llvm-source-9-macos-v0
242+
- llvm-source-10-macos-v0
243243
- run:
244244
name: "Fetch LLVM source"
245245
command: make llvm-source
246246
- save_cache:
247-
key: llvm-source-9-macos-v0
247+
key: llvm-source-10-macos-v0
248248
paths:
249249
- llvm-project
250250
- restore_cache:
251251
keys:
252-
- llvm-build-9-macos-v0
252+
- llvm-build-10-macos-v0
253253
- run:
254254
name: "Build LLVM"
255255
command: |
@@ -261,7 +261,7 @@ commands:
261261
make llvm-build
262262
fi
263263
- save_cache:
264-
key: llvm-build-9-macos-v0
264+
key: llvm-build-10-macos-v0
265265
paths:
266266
llvm-build
267267
- restore_cache:
@@ -306,17 +306,17 @@ commands:
306306

307307

308308
jobs:
309-
test-llvm9-go111:
309+
test-llvm10-go111:
310310
docker:
311311
- image: circleci/golang:1.11-buster
312312
steps:
313313
- test-linux
314-
test-llvm9-go112:
314+
test-llvm10-go112:
315315
docker:
316316
- image: circleci/golang:1.12-buster
317317
steps:
318318
- test-linux
319-
test-llvm9-go113:
319+
test-llvm10-go113:
320320
docker:
321321
- image: circleci/golang:1.13-buster
322322
steps:
@@ -343,9 +343,9 @@ jobs:
343343
workflows:
344344
test-all:
345345
jobs:
346-
- test-llvm9-go111
347-
- test-llvm9-go112
348-
- test-llvm9-go113
346+
- test-llvm10-go111
347+
- test-llvm10-go112
348+
- test-llvm10-go113
349349
- build-linux
350350
- build-macos
351351
- assert-test-linux

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# TinyGo base stage installs Go 1.13, LLVM 9 and the TinyGo compiler itself.
1+
# TinyGo base stage installs Go 1.13, LLVM 10 and the TinyGo compiler itself.
22
FROM golang:1.13 AS tinygo-base
33

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

99
COPY . /tinygo
1010

@@ -28,9 +28,9 @@ COPY --from=tinygo-base /tinygo/src /tinygo/src
2828
COPY --from=tinygo-base /tinygo/targets /tinygo/targets
2929

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

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

6262
RUN cd /tinygo/ && \
6363
apt-get update && \
64-
apt-get install -y apt-utils make clang-9 && \
64+
apt-get install -y apt-utils make clang-10 && \
6565
make gen-device-nrf && make gen-device-stm32
6666

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

7474
RUN cd /tinygo/ && \
7575
apt-get update && \
76-
apt-get install -y apt-utils make clang-9 binutils-avr gcc-avr avr-libc && \
76+
apt-get install -y apt-utils make clang-10 binutils-avr gcc-avr avr-libc && \
7777
make gen-device
7878

7979
CMD ["tinygo"]

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
1212
ifneq (, $(shell command -v llvm-build/bin/clang 2> /dev/null))
1313
CLANG ?= $(abspath llvm-build/bin/clang)
1414
else
15-
CLANG ?= clang-9
15+
CLANG ?= clang-10
1616
endif
1717
ifneq (, $(shell command -v llvm-build/bin/llvm-ar 2> /dev/null))
1818
LLVM_AR ?= $(abspath llvm-build/bin/llvm-ar)
19-
else ifneq (, $(shell command -v llvm-ar-9 2> /dev/null))
20-
LLVM_AR ?= llvm-ar-9
19+
else ifneq (, $(shell command -v llvm-ar-10 2> /dev/null))
20+
LLVM_AR ?= llvm-ar-10
2121
else
2222
LLVM_AR ?= llvm-ar
2323
endif
2424
ifneq (, $(shell command -v llvm-build/bin/llvm-nm 2> /dev/null))
2525
LLVM_NM ?= $(abspath llvm-build/bin/llvm-nm)
26-
else ifneq (, $(shell command -v llvm-nm-9 2> /dev/null))
27-
LLVM_NM ?= llvm-nm-9
26+
else ifneq (, $(shell command -v llvm-nm-10 2> /dev/null))
27+
LLVM_NM ?= llvm-nm-10
2828
else
2929
LLVM_NM ?= llvm-nm
3030
endif
@@ -53,7 +53,7 @@ endif
5353

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

56-
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
56+
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
5757

5858
ifeq ($(OS),Windows_NT)
5959
EXE = .exe
@@ -103,8 +103,8 @@ LLD_LIBS = $(START_GROUP) -llldCOFF -llldCommon -llldCore -llldDriver -llldELF -
103103
# For static linking.
104104
ifneq ("$(wildcard $(LLVM_BUILDDIR)/bin/llvm-config*)","")
105105
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
106-
CGO_CXXFLAGS=-std=c++11
107-
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)
106+
CGO_CXXFLAGS=-std=c++14
107+
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)
108108
endif
109109

110110

@@ -148,7 +148,7 @@ gen-device-stm32: build/gen-device-svd
148148

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

154154
# Configure LLVM.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ The original reasoning was: if [Python](https://micropython.org/) can run on mic
135135

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

138-
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.
138+
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.

azure-pipelines.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
steps:
1313
- task: GoTool@0
1414
inputs:
15-
version: '1.13.8'
15+
version: '1.13.8'
1616
- checkout: self
1717
- task: CacheBeta@0
1818
displayName: Cache LLVM source
1919
inputs:
20-
key: llvm-source-9-windows-v0
20+
key: llvm-source-10-windows-v0
2121
path: llvm-project
2222
- task: Bash@3
2323
displayName: Download LLVM source
@@ -27,7 +27,7 @@ jobs:
2727
- task: CacheBeta@0
2828
displayName: Cache LLVM build
2929
inputs:
30-
key: llvm-build-9-windows-v0
30+
key: llvm-build-10-windows-v0
3131
path: llvm-build
3232
- task: Bash@3
3333
displayName: Build LLVM
@@ -37,10 +37,6 @@ jobs:
3737
if [ ! -f llvm-build/lib/liblldELF.a ]
3838
then
3939
choco install ninja
40-
# LLVM 9 cannot be built with MinGW 8.
41-
# For details: https://reviews.llvm.org/D70266
42-
choco uninstall mingw
43-
choco install mingw --version=7.3.0
4440
make llvm-build
4541
fi
4642
- task: Bash@3
@@ -51,7 +47,7 @@ jobs:
5147
- task: CacheBeta@0
5248
displayName: Cache wasi-libc sysroot
5349
inputs:
54-
key: wasi-libc-sysroot-v1
50+
key: wasi-libc-sysroot-v2
5551
path: lib/wasi-libc/sysroot
5652
- task: Bash@3
5753
displayName: Build wasi-libc

0 commit comments

Comments
 (0)