Skip to content

Commit 852d47c

Browse files
committed
all: add support for LLVM 20
This adds support for the 'go install' case, where we link against the system LLVM (Homebrew, Linux distro version, etc). This does not have an effect on `make`, which still uses LLVM 19 for now. The main reason for doing this is because newer distros like Fedora 42 and Homebrew have switched to LLVM 20, so switching to this newer version helps those people. (I'm one of those people, I'm on Fedora 42). There are two small changes for WebAssembly included: * nontrapping-fptoint was enabled in the wasmbuiltin library used for wasm-unknown. This matches wasm-unknown which already had this enabled, so it doesn't add any new instructions. * bulk-memory was enabled in wasi-libc. This was previously enabled in all the other WebAssembly targets (wasm, wasip1, wasip2) so this does't add any new instructions. I think it was also enabled in the wasi-libc build before #4820 but I don't know for sure.
1 parent febb390 commit 852d47c

File tree

9 files changed

+35
-17
lines changed

9 files changed

+35
-17
lines changed

.circleci/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ jobs:
101101
# "make lint" fails before go 1.21 because internal/tools/go.mod specifies packages that require go 1.21
102102
fmt-check: false
103103
resource_class: large
104-
test-llvm19-go124:
104+
test-llvm20-go124:
105105
docker:
106106
- image: golang:1.24-bullseye
107107
steps:
108108
- test-linux:
109-
llvm: "19"
109+
llvm: "20"
110110
resource_class: large
111111

112112
workflows:
@@ -115,5 +115,5 @@ workflows:
115115
# This tests our lowest supported versions of Go and LLVM, to make sure at
116116
# least the smoke tests still pass.
117117
- test-llvm15-go119
118-
# This tests LLVM 19 support when linking against system libraries.
119-
- test-llvm19-go124
118+
# This tests LLVM 20 support when linking against system libraries.
119+
- test-llvm20-go124

.github/workflows/build-macos.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
runs-on: macos-latest
118118
strategy:
119119
matrix:
120-
version: [16, 17, 18, 19]
120+
version: [16, 17, 18, 19, 20]
121121
steps:
122122
- name: Set up Homebrew
123123
uses: Homebrew/actions/setup-homebrew@master
@@ -141,8 +141,8 @@ jobs:
141141
- name: Check binary
142142
run: tinygo version
143143
- name: Build TinyGo (default LLVM)
144-
if: matrix.version == 19
144+
if: matrix.version == 20
145145
run: go install
146146
- name: Check binary
147-
if: matrix.version == 19
147+
if: matrix.version == 20
148148
run: tinygo version

.github/workflows/sizediff-install-pkgs.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# still works after checking out the dev branch (that is, when going from LLVM
33
# 16 to LLVM 17 for example, both Clang 16 and Clang 17 are installed).
44

5-
echo 'deb https://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' | sudo tee /etc/apt/sources.list.d/llvm.list
5+
echo 'deb https://apt.llvm.org/noble/ llvm-toolchain-noble-20 main' | sudo tee /etc/apt/sources.list.d/llvm.list
66
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
77
sudo apt-get update
88
sudo apt-get install --no-install-recommends -y \
9-
llvm-19-dev \
10-
clang-19 \
11-
libclang-19-dev \
12-
lld-19
9+
llvm-20-dev \
10+
clang-20 \
11+
libclang-20-dev \
12+
lld-20

builder/wasilibc.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ var libWasiLibc = Library{
9393
"-Wall",
9494
"-std=gnu11",
9595
"-nostdlibinc",
96-
"-mnontrapping-fptoint", "-msign-ext",
96+
"-mnontrapping-fptoint", "-msign-ext", "-mbulk-memory",
9797
"-Wno-null-pointer-arithmetic", "-Wno-unused-parameter", "-Wno-sign-compare", "-Wno-unused-variable", "-Wno-unused-function", "-Wno-ignored-attributes", "-Wno-missing-braces", "-Wno-ignored-pragmas", "-Wno-unused-but-set-variable", "-Wno-unknown-warning-option",
9898
"-Wno-parentheses", "-Wno-shift-op-parentheses", "-Wno-bitwise-op-parentheses", "-Wno-logical-op-parentheses", "-Wno-string-plus-int", "-Wno-dangling-else", "-Wno-unknown-pragmas",
9999
"-DNDEBUG",
100100
"-D__wasilibc_printscan_no_long_double",
101101
"-D__wasilibc_printscan_full_support_option=\"long double support is disabled\"",
102+
"-DBULK_MEMORY_THRESHOLD=32", // default threshold in wasi-libc
102103
"-isystem", headerPath,
103104
"-I" + libcDir + "/libc-top-half/musl/src/include",
104105
"-I" + libcDir + "/libc-top-half/musl/src/internal",

builder/wasmbuiltins.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var libWasmBuiltins = Library{
2929
"-Wall",
3030
"-std=gnu11",
3131
"-nostdlibinc",
32+
"-mnontrapping-fptoint", // match wasm-unknown (default on in LLVM 20)
33+
"-mno-bulk-memory", // same here
3234
"-isystem", libcDir + "/libc-top-half/musl/arch/wasm32",
3335
"-isystem", libcDir + "/libc-top-half/musl/arch/generic",
3436
"-isystem", libcDir + "/libc-top-half/musl/src/internal",

cgo/libclang_config_llvm19.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !byollvm && !llvm15 && !llvm16 && !llvm17 && !llvm18
1+
//go:build !byollvm && llvm19
22

33
package cgo
44

cgo/libclang_config_llvm20.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build !byollvm && !llvm15 && !llvm16 && !llvm17 && !llvm18 && !llvm19
2+
3+
package cgo
4+
5+
/*
6+
#cgo linux CFLAGS: -I/usr/include/llvm-20 -I/usr/include/llvm-c-20 -I/usr/lib/llvm-20/include
7+
#cgo darwin,amd64 CFLAGS: -I/usr/local/opt/llvm@20/include
8+
#cgo darwin,arm64 CFLAGS: -I/opt/homebrew/opt/llvm@20/include
9+
#cgo freebsd CFLAGS: -I/usr/local/llvm20/include
10+
#cgo linux LDFLAGS: -L/usr/lib/llvm-20/lib -lclang
11+
#cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@20/lib -lclang
12+
#cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@20/lib -lclang
13+
#cgo freebsd LDFLAGS: -L/usr/local/llvm20/lib -lclang
14+
*/
15+
import "C"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
golang.org/x/sys v0.21.0
2121
golang.org/x/tools v0.22.1-0.20240621165957-db513b091504
2222
gopkg.in/yaml.v2 v2.4.0
23-
tinygo.org/x/go-llvm v0.0.0-20250119132755-9dca92dfb4f9
23+
tinygo.org/x/go-llvm v0.0.0-20250422114502-b8f170971e74
2424
)
2525

2626
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
7474
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
7575
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
7676
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
77-
tinygo.org/x/go-llvm v0.0.0-20250119132755-9dca92dfb4f9 h1:rMvEzuCYjyiR+pmdiCVWTQw3L6VqiSIXoL19I3lYufE=
78-
tinygo.org/x/go-llvm v0.0.0-20250119132755-9dca92dfb4f9/go.mod h1:GFbusT2VTA4I+l4j80b17KFK+6whv69Wtny5U+T8RR0=
77+
tinygo.org/x/go-llvm v0.0.0-20250422114502-b8f170971e74 h1:ovavgTdIBWCH8YWlcfq9gkpoyT1+IxMKSn+Df27QwE8=
78+
tinygo.org/x/go-llvm v0.0.0-20250422114502-b8f170971e74/go.mod h1:GFbusT2VTA4I+l4j80b17KFK+6whv69Wtny5U+T8RR0=

0 commit comments

Comments
 (0)