Skip to content

Commit 118af9d

Browse files
committed
all: switch to LLVM 9
1 parent 172efc2 commit 118af9d

File tree

11 files changed

+57
-51
lines changed

11 files changed

+57
-51
lines changed

.circleci/config.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ commands:
4444
steps:
4545
- restore_cache:
4646
keys:
47-
- llvm-source-8-v5
47+
- llvm-source-9-v0
4848
- run:
4949
name: "Fetch LLVM source"
5050
command: make llvm-source
5151
- save_cache:
52-
key: llvm-source-8-v5
52+
key: llvm-source-9-v0
5353
paths:
5454
- llvm-project
5555
test-linux:
5656
steps:
5757
- checkout
5858
- submodules
5959
- apt-dependencies:
60-
llvm: "-8"
60+
llvm: "-9"
6161
- install-node
6262
- restore_cache:
6363
keys:
@@ -101,7 +101,7 @@ commands:
101101
- llvm-source-linux
102102
- restore_cache:
103103
keys:
104-
- llvm-build-8-linux-v7-assert
104+
- llvm-build-9-linux-v0-assert
105105
- run:
106106
name: "Build LLVM"
107107
command: |
@@ -119,15 +119,15 @@ commands:
119119
make ASSERT=1 llvm-build
120120
fi
121121
- save_cache:
122-
key: llvm-build-8-linux-v7-assert
122+
key: llvm-build-9-linux-v0-assert
123123
paths:
124124
llvm-build
125125
- run:
126126
name: "Create LLVM symlinks"
127127
command: |
128-
ln -s $PWD/llvm-build/bin/clang-8 /go/bin/clang-8
129-
ln -s $PWD/llvm-build/bin/ld.lld /go/bin/ld.lld-8
130-
ln -s $PWD/llvm-build/bin/wasm-ld /go/bin/wasm-ld-8
128+
ln -s $PWD/llvm-build/bin/clang-9 /go/bin/clang-9
129+
ln -s $PWD/llvm-build/bin/ld.lld /go/bin/ld.lld-9
130+
ln -s $PWD/llvm-build/bin/wasm-ld /go/bin/wasm-ld-9
131131
- run: make ASSERT=1
132132
- run:
133133
name: "Test TinyGo"
@@ -166,7 +166,7 @@ commands:
166166
- llvm-source-linux
167167
- restore_cache:
168168
keys:
169-
- llvm-build-8-linux-v7
169+
- llvm-build-9-linux-v0
170170
- run:
171171
name: "Build LLVM"
172172
command: |
@@ -184,15 +184,15 @@ commands:
184184
make llvm-build
185185
fi
186186
- save_cache:
187-
key: llvm-build-8-linux-v7
187+
key: llvm-build-9-linux-v0
188188
paths:
189189
llvm-build
190190
- run:
191191
name: "Create LLVM symlinks"
192192
command: |
193-
ln -s $PWD/llvm-build/bin/clang-8 /go/bin/clang-8
194-
ln -s $PWD/llvm-build/bin/ld.lld /go/bin/ld.lld-8
195-
ln -s $PWD/llvm-build/bin/wasm-ld /go/bin/wasm-ld-8
193+
ln -s $PWD/llvm-build/bin/clang-9 /go/bin/clang-9
194+
ln -s $PWD/llvm-build/bin/ld.lld /go/bin/ld.lld-9
195+
ln -s $PWD/llvm-build/bin/wasm-ld /go/bin/wasm-ld-9
196196
- run:
197197
name: "Test TinyGo"
198198
command: make test
@@ -239,17 +239,17 @@ commands:
239239
- go-cache-macos-v2-{{ checksum "go.mod" }}
240240
- restore_cache:
241241
keys:
242-
- llvm-source-8-macos-v5
242+
- llvm-source-9-macos-v0
243243
- run:
244244
name: "Fetch LLVM source"
245245
command: make llvm-source
246246
- save_cache:
247-
key: llvm-source-8-macos-v5
247+
key: llvm-source-9-macos-v0
248248
paths:
249249
- llvm-project
250250
- restore_cache:
251251
keys:
252-
- llvm-build-8-macos-v6
252+
- llvm-build-9-macos-v0
253253
- run:
254254
name: "Build LLVM"
255255
command: |
@@ -261,13 +261,13 @@ commands:
261261
make llvm-build
262262
fi
263263
- save_cache:
264-
key: llvm-build-8-macos-v6
264+
key: llvm-build-9-macos-v0
265265
paths:
266266
llvm-build
267267
- run:
268268
name: "Create LLVM symlinks"
269269
command: |
270-
ln -s $PWD/llvm-build/bin/clang-8 /usr/local/bin/clang-8
270+
ln -s $PWD/llvm-build/bin/clang-9 /usr/local/bin/clang-9
271271
- run:
272272
name: "Test TinyGo"
273273
command: make test
@@ -300,17 +300,17 @@ commands:
300300

301301

302302
jobs:
303-
test-llvm8-go111:
303+
test-llvm9-go111:
304304
docker:
305305
- image: circleci/golang:1.11-stretch
306306
steps:
307307
- test-linux
308-
test-llvm8-go112:
308+
test-llvm9-go112:
309309
docker:
310310
- image: circleci/golang:1.12-stretch
311311
steps:
312312
- test-linux
313-
test-llvm8-go113:
313+
test-llvm9-go113:
314314
docker:
315315
- image: circleci/golang:1.13-stretch
316316
steps:
@@ -337,9 +337,9 @@ jobs:
337337
workflows:
338338
test-all:
339339
jobs:
340-
- test-llvm8-go111
341-
- test-llvm8-go112
342-
- test-llvm8-go113
340+
- test-llvm9-go111
341+
- test-llvm9-go112
342+
- test-llvm9-go113
343343
- build-linux
344344
- build-macos
345345
- 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 8 and the TinyGo compiler itself.
1+
# TinyGo base stage installs Go 1.13, LLVM 9 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-8 main" >> /etc/apt/sources.list && \
5+
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >> /etc/apt/sources.list && \
66
apt-get update && \
7-
apt-get install -y llvm-8-dev libclang-8-dev git
7+
apt-get install -y llvm-9-dev libclang-9-dev git
88

99
COPY . /tinygo
1010

@@ -25,9 +25,9 @@ COPY --from=tinygo-base /tinygo/src /tinygo/src
2525
COPY --from=tinygo-base /tinygo/targets /tinygo/targets
2626

2727
RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
28-
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-8 main" >> /etc/apt/sources.list && \
28+
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >> /etc/apt/sources.list && \
2929
apt-get update && \
30-
apt-get install -y libllvm8 lld-8
30+
apt-get install -y libllvm9 lld-9
3131

3232
# tinygo-avr stage installs the needed dependencies to compile TinyGo programs for AVR microcontrollers.
3333
FROM tinygo-base AS tinygo-avr
@@ -59,7 +59,7 @@ COPY --from=tinygo-base /tinygo/lib /tinygo/lib
5959

6060
RUN cd /tinygo/ && \
6161
apt-get update && \
62-
apt-get install -y apt-utils python3 make clang-8 && \
62+
apt-get install -y apt-utils python3 make clang-9 && \
6363
make gen-device-nrf && make gen-device-stm32 && \
6464
apt-get remove -y python3 && \
6565
apt-get autoremove -y && \
@@ -74,7 +74,7 @@ COPY --from=tinygo-base /tinygo/lib /tinygo/lib
7474

7575
RUN cd /tinygo/ && \
7676
apt-get update && \
77-
apt-get install -y apt-utils python3 make clang-8 binutils-avr gcc-avr avr-libc && \
77+
apt-get install -y apt-utils python3 make clang-9 binutils-avr gcc-avr avr-libc && \
7878
make gen-device && \
7979
apt-get remove -y python3 && \
8080
apt-get autoremove -y && \

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ gen-device-stm32:
120120

121121
# Get LLVM sources.
122122
llvm-project/README.md:
123-
git clone -b release/8.x https://github.com/llvm/llvm-project
123+
git clone -b release/9.x https://github.com/llvm/llvm-project
124124
llvm-source: llvm-project/README.md
125125

126126
# Configure LLVM.
127127
TINYGO_SOURCE_DIR=$(shell pwd)
128128
$(LLVM_BUILDDIR)/build.ninja: llvm-source
129-
mkdir -p $(LLVM_BUILDDIR); cd $(LLVM_BUILDDIR); cmake -G Ninja $(TINYGO_SOURCE_DIR)/llvm-project/llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR;RISCV" -DCMAKE_BUILD_TYPE=Release -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF $(LLVM_OPTION)
129+
mkdir -p $(LLVM_BUILDDIR); cd $(LLVM_BUILDDIR); cmake -G Ninja $(TINYGO_SOURCE_DIR)/llvm-project/llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;RISCV;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR" -DCMAKE_BUILD_TYPE=Release -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF $(LLVM_OPTION)
130130

131131
# Build LLVM.
132132
$(LLVM_BUILDDIR): $(LLVM_BUILDDIR)/build.ninja

azure-pipelines.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- task: CacheBeta@0
1515
displayName: Cache LLVM source
1616
inputs:
17-
key: llvm-source-8-windows-v0
17+
key: llvm-source-9-windows-v0
1818
path: llvm-project
1919
- task: Bash@3
2020
displayName: Download LLVM source
@@ -24,7 +24,7 @@ jobs:
2424
- task: CacheBeta@0
2525
displayName: Cache LLVM build
2626
inputs:
27-
key: llvm-build-8-windows-v1
27+
key: llvm-build-9-windows-v0
2828
path: llvm-build
2929
- task: Bash@3
3030
displayName: Build LLVM
@@ -34,6 +34,10 @@ jobs:
3434
if [ ! -f llvm-build/lib/liblldELF.a ]
3535
then
3636
choco install ninja
37+
# LLVM 9 cannot be built with MinGW 8.
38+
# For details: https://reviews.llvm.org/D70266
39+
choco uninstall mingw
40+
choco install mingw --version=7.3.0
3741
make llvm-build
3842
fi
3943
- task: Bash@3

builder/commands.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ import (
1313
// distributions or may not even exist in $PATH, in which case absolute paths
1414
// may be used.
1515
var commands = map[string][]string{
16-
"clang": {"clang-8"},
17-
"ld.lld": {"ld.lld-8", "ld.lld"},
18-
"wasm-ld": {"wasm-ld-8", "wasm-ld"},
16+
"clang": {"clang-9"},
17+
"ld.lld": {"ld.lld-9", "ld.lld"},
18+
"wasm-ld": {"wasm-ld-9", "wasm-ld"},
1919
}
2020

2121
func init() {
22-
// Add the path to a Homebrew-installed LLVM 8 for ease of use (no need to
22+
// Add the path to a Homebrew-installed LLVM 9 for ease of use (no need to
2323
// manually set $PATH).
2424
if runtime.GOOS == "darwin" {
25-
commands["clang"] = append(commands["clang"], "/usr/local/opt/llvm@8/bin/clang-8")
26-
commands["ld.lld"] = append(commands["ld.lld"], "/usr/local/opt/llvm@8/bin/ld.lld")
27-
commands["wasm-ld"] = append(commands["wasm-ld"], "/usr/local/opt/llvm@8/bin/wasm-ld")
25+
commands["clang"] = append(commands["clang"], "/usr/local/opt/llvm@9/bin/clang-9")
26+
commands["ld.lld"] = append(commands["ld.lld"], "/usr/local/opt/llvm@9/bin/ld.lld")
27+
commands["wasm-ld"] = append(commands["wasm-ld"], "/usr/local/opt/llvm@9/bin/wasm-ld")
2828
}
2929
// Add the path for when LLVM was installed with the installer from
3030
// llvm.org, which by default doesn't add LLVM to the $PATH environment

builder/env.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ func getClangHeaderPath(TINYGOROOT string) string {
9696
return ""
9797
}
9898
// Example executable:
99-
// /usr/lib/llvm-8/bin/clang
99+
// /usr/lib/llvm-9/bin/clang
100100
// Example include path:
101-
// /usr/lib/llvm-8/lib/clang/8.0.1/include/
101+
// /usr/lib/llvm-9/lib/clang/9.0.1/include/
102102
llvmRoot := filepath.Dir(filepath.Dir(binpath))
103103
clangVersionRoot := filepath.Join(llvmRoot, "lib", "clang")
104104
dirs, err := ioutil.ReadDir(clangVersionRoot)

cgo/libclang.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
/*
18-
#include <clang-c/Index.h> // if this fails, install libclang-8-dev
18+
#include <clang-c/Index.h> // if this fails, install libclang-9-dev
1919
#include <stdlib.h>
2020
#include <stdint.h>
2121

cgo/libclang_config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
package cgo
44

55
/*
6-
#cgo linux CFLAGS: -I/usr/lib/llvm-8/include
7-
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@8/include
8-
#cgo linux LDFLAGS: -L/usr/lib/llvm-8/lib -lclang
9-
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@8/lib -lclang -lffi
6+
#cgo linux CFLAGS: -I/usr/lib/llvm-9/include
7+
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@9/include
8+
#cgo linux LDFLAGS: -L/usr/lib/llvm-9/lib -lclang
9+
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@9/lib -lclang -lffi
1010
*/
1111
import "C"

cgo/libclang_stubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// are slightly different from the ones defined in libclang.go, but they
44
// should be ABI compatible.
55

6-
#include <clang-c/Index.h> // if this fails, install libclang-8-dev
6+
#include <clang-c/Index.h> // if this fails, install libclang-9-dev
77

88
CXCursor tinygo_clang_getTranslationUnitCursor(CXTranslationUnit tu) {
99
return clang_getTranslationUnitCursor(tu);

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ require (
99
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45
1010
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
1111
golang.org/x/tools v0.0.0-20190227180812-8dcc6e70cdef
12-
tinygo.org/x/go-llvm v0.0.0-20191103200204-37e93e3f04e2
12+
tinygo.org/x/go-llvm v0.0.0-20191113125529-bad6d01809e8
1313
)

0 commit comments

Comments
 (0)