Skip to content

Commit 808cc56

Browse files
committed
LLVM 18 support
1 parent 1d9f26c commit 808cc56

35 files changed

+139
-94
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ commands:
1010
steps:
1111
- restore_cache:
1212
keys:
13-
- llvm-source-17-v1
13+
- llvm-source-18-v1
1414
- run:
1515
name: "Fetch LLVM source"
1616
command: make llvm-source
1717
- save_cache:
18-
key: llvm-source-17-v1
18+
key: llvm-source-18-v1
1919
paths:
2020
- llvm-project/clang/lib/Headers
2121
- llvm-project/clang/include
@@ -105,12 +105,12 @@ jobs:
105105
- test-linux:
106106
llvm: "15"
107107
resource_class: large
108-
test-llvm17-go122:
108+
test-llvm18-go122:
109109
docker:
110110
- image: golang:1.22-bullseye
111111
steps:
112112
- test-linux:
113-
llvm: "17"
113+
llvm: "18"
114114
resource_class: large
115115

116116
workflows:
@@ -119,5 +119,5 @@ workflows:
119119
# This tests our lowest supported versions of Go and LLVM, to make sure at
120120
# least the smoke tests still pass.
121121
- test-llvm15-go118
122-
# This tests LLVM 17 support when linking against system libraries.
123-
- test-llvm17-go122
122+
# This tests LLVM 18 support when linking against system libraries.
123+
- test-llvm18-go122

.github/workflows/build-macos.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
uses: actions/cache/restore@v4
4444
id: cache-llvm-source
4545
with:
46-
key: llvm-source-17-${{ matrix.os }}-v2
46+
key: llvm-source-18-${{ matrix.os }}-v2
4747
path: |
4848
llvm-project/clang/lib/Headers
4949
llvm-project/clang/include
@@ -68,7 +68,7 @@ jobs:
6868
uses: actions/cache/restore@v4
6969
id: cache-llvm-build
7070
with:
71-
key: llvm-build-17-${{ matrix.os }}-v2
71+
key: llvm-build-18-${{ matrix.os }}-v2
7272
path: llvm-build
7373
- name: Build LLVM
7474
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -128,7 +128,7 @@ jobs:
128128
runs-on: macos-latest
129129
strategy:
130130
matrix:
131-
version: [16, 17]
131+
version: [16, 17, 18]
132132
steps:
133133
- name: Set up Homebrew
134134
uses: Homebrew/actions/setup-homebrew@master
@@ -152,8 +152,8 @@ jobs:
152152
- name: Check binary
153153
run: tinygo version
154154
- name: Build TinyGo (default LLVM)
155-
if: matrix.version == 17
155+
if: matrix.version == 18
156156
run: go install
157157
- name: Check binary
158-
if: matrix.version == 17
158+
if: matrix.version == 18
159159
run: tinygo version

.github/workflows/linux.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
uses: actions/cache/restore@v4
4444
id: cache-llvm-source
4545
with:
46-
key: llvm-source-17-linux-alpine-v2
46+
key: llvm-source-18-linux-alpine-v1
4747
path: |
4848
llvm-project/clang/lib/Headers
4949
llvm-project/clang/include
@@ -68,7 +68,7 @@ jobs:
6868
uses: actions/cache/restore@v4
6969
id: cache-llvm-build
7070
with:
71-
key: llvm-build-17-linux-alpine-v2
71+
key: llvm-build-18-linux-alpine-v1
7272
path: llvm-build
7373
- name: Build LLVM
7474
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -196,7 +196,7 @@ jobs:
196196
uses: actions/cache/restore@v4
197197
id: cache-llvm-source
198198
with:
199-
key: llvm-source-17-linux-asserts-v2
199+
key: llvm-source-18-linux-asserts-v1
200200
path: |
201201
llvm-project/clang/lib/Headers
202202
llvm-project/clang/include
@@ -221,7 +221,7 @@ jobs:
221221
uses: actions/cache/restore@v4
222222
id: cache-llvm-build
223223
with:
224-
key: llvm-build-17-linux-asserts-v2
224+
key: llvm-build-18-linux-asserts-v1
225225
path: llvm-build
226226
- name: Build LLVM
227227
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -309,7 +309,7 @@ jobs:
309309
uses: actions/cache/restore@v4
310310
id: cache-llvm-source
311311
with:
312-
key: llvm-source-17-linux-v2
312+
key: llvm-source-18-linux-v1
313313
path: |
314314
llvm-project/clang/lib/Headers
315315
llvm-project/clang/include
@@ -334,7 +334,7 @@ jobs:
334334
uses: actions/cache/restore@v4
335335
id: cache-llvm-build
336336
with:
337-
key: llvm-build-17-linux-${{ matrix.goarch }}-v2
337+
key: llvm-build-18-linux-${{ matrix.goarch }}-v1
338338
path: llvm-build
339339
- name: Build LLVM
340340
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

.github/workflows/llvm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
uses: docker/metadata-action@v5
3636
with:
3737
images: |
38-
tinygo/llvm-17
39-
ghcr.io/${{ github.repository_owner }}/llvm-17
38+
tinygo/llvm-18
39+
ghcr.io/${{ github.repository_owner }}/llvm-18
4040
tags: |
4141
type=sha,format=long
4242
type=raw,value=latest

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/cache/restore@v4
2525
id: cache-llvm-source
2626
with:
27-
key: llvm-source-17-linux-nix-v2
27+
key: llvm-source-18-linux-nix-v1
2828
path: |
2929
llvm-project/compiler-rt
3030
- name: Download LLVM source

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

Lines changed: 5 additions & 5 deletions
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/jammy/ llvm-toolchain-jammy-17 main' | sudo tee /etc/apt/sources.list.d/llvm.list
5+
echo 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 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-17-dev \
10-
clang-17 \
11-
libclang-17-dev \
12-
lld-17
9+
llvm-18-dev \
10+
clang-18 \
11+
libclang-18-dev \
12+
lld-18

.github/workflows/sizediff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: actions/cache@v4
2929
id: cache-llvm-source
3030
with:
31-
key: llvm-source-17-sizediff-v2
31+
key: llvm-source-18-sizediff-v1
3232
path: |
3333
llvm-project/compiler-rt
3434
- name: Download LLVM source

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/cache/restore@v4
4242
id: cache-llvm-source
4343
with:
44-
key: llvm-source-17-windows-v2
44+
key: llvm-source-18-windows-v1
4545
path: |
4646
llvm-project/clang/lib/Headers
4747
llvm-project/clang/include
@@ -66,7 +66,7 @@ jobs:
6666
uses: actions/cache/restore@v4
6767
id: cache-llvm-build
6868
with:
69-
key: llvm-build-17-windows-v2
69+
key: llvm-build-18-windows-v1
7070
path: llvm-build
7171
- name: Build LLVM
7272
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

GNUmakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
1010

1111
# Try to autodetect LLVM build tools.
1212
# Versions are listed here in descending priority order.
13-
LLVM_VERSIONS = 17 16 15
13+
LLVM_VERSIONS = 18 17 16 15
1414
errifempty = $(if $(1),$(1),$(error $(2)))
1515
detect = $(shell which $(call errifempty,$(firstword $(foreach p,$(2),$(shell command -v $(p) 2> /dev/null && echo $(p)))),failed to locate $(1) at any of: $(2)))
1616
toolSearchPathsVersion = $(1)-$(2)
@@ -111,7 +111,7 @@ endif
111111

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

114-
LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfodwarf debuginfopdb executionengine frontendhlsl frontendopenmp instrumentation interpreter ipo irreader libdriver linker lto mc mcjit objcarcopts option profiledata scalaropts support target windowsdriver windowsmanifest
114+
LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfodwarf debuginfopdb executionengine frontenddriver frontendhlsl frontendopenmp instrumentation interpreter ipo irreader libdriver linker lto mc mcjit objcarcopts option profiledata scalaropts support target windowsdriver windowsmanifest
115115

116116
ifeq ($(OS),Windows_NT)
117117
EXE = .exe
@@ -147,7 +147,7 @@ endif
147147
MD5SUM ?= md5sum
148148

149149
# Libraries that should be linked in for the statically linked Clang.
150-
CLANG_LIB_NAMES = clangAnalysis clangAST clangASTMatchers clangBasic clangCodeGen clangCrossTU clangDriver clangDynamicASTMatchers clangEdit clangExtractAPI clangFormat clangFrontend clangFrontendTool clangHandleCXX clangHandleLLVM clangIndex clangLex clangParse clangRewrite clangRewriteFrontend clangSema clangSerialization clangSupport clangTooling clangToolingASTDiff clangToolingCore clangToolingInclusions
150+
CLANG_LIB_NAMES = clangAnalysis clangAPINotes clangAST clangASTMatchers clangBasic clangCodeGen clangCrossTU clangDriver clangDynamicASTMatchers clangEdit clangExtractAPI clangFormat clangFrontend clangFrontendTool clangHandleCXX clangHandleLLVM clangIndex clangLex clangParse clangRewrite clangRewriteFrontend clangSema clangSerialization clangSupport clangTooling clangToolingASTDiff clangToolingCore clangToolingInclusions
151151
CLANG_LIBS = $(START_GROUP) $(addprefix -l,$(CLANG_LIB_NAMES)) $(END_GROUP) -lstdc++
152152

153153
# Libraries that should be linked in for the statically linked LLD.
@@ -239,7 +239,7 @@ gen-device-renesas: build/gen-device-svd
239239

240240
# Get LLVM sources.
241241
$(LLVM_PROJECTDIR)/llvm:
242-
git clone -b esp-17.0.1_20240419 --depth=1 https://github.com/espressif/llvm-project $(LLVM_PROJECTDIR)
242+
git clone -b tinygo_xtensa_release_18.1.2 --depth=1 https://github.com/tinygo/llvm-project $(LLVM_PROJECTDIR)
243243
llvm-source: $(LLVM_PROJECTDIR)/llvm
244244

245245
# Configure LLVM.

builder/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
773773
if sizeLevel >= 2 {
774774
// Workaround with roughly the same effect as
775775
// https://reviews.llvm.org/D119342.
776-
// Can hopefully be removed in LLVM 18.
776+
// Can hopefully be removed in LLVM 19.
777777
ldflags = append(ldflags,
778778
"-mllvm", "--rotation-max-header-size=0")
779779
}

builder/builtins.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
"github.com/tinygo-org/tinygo/goenv"
99
)
1010

11-
// These are the GENERIC_SOURCES according to CMakeList.txt.
11+
// These are the GENERIC_SOURCES according to CMakeList.txt except for
12+
// divmodsi4.c and udivmodsi4.c.
1213
var genericBuiltins = []string{
1314
"absvdi2.c",
1415
"absvsi2.c",
1516
"absvti2.c",
1617
"adddf3.c",
1718
"addsf3.c",
18-
"addtf3.c",
1919
"addvdi3.c",
2020
"addvsi3.c",
2121
"addvti3.c",
@@ -40,12 +40,12 @@ var genericBuiltins = []string{
4040
"divdf3.c",
4141
"divdi3.c",
4242
"divmoddi4.c",
43+
//"divmodsi4.c",
44+
"divmodti4.c",
4345
"divsc3.c",
4446
"divsf3.c",
4547
"divsi3.c",
46-
"divtc3.c",
4748
"divti3.c",
48-
"divtf3.c",
4949
"extendsfdf2.c",
5050
"extendhfsf2.c",
5151
"ffsdi2.c",
@@ -91,7 +91,6 @@ var genericBuiltins = []string{
9191
"mulsc3.c",
9292
"mulsf3.c",
9393
"multi3.c",
94-
"multf3.c",
9594
"mulvdi3.c",
9695
"mulvsi3.c",
9796
"mulvti3.c",
@@ -111,13 +110,11 @@ var genericBuiltins = []string{
111110
"popcountti2.c",
112111
"powidf2.c",
113112
"powisf2.c",
114-
"powitf2.c",
115113
"subdf3.c",
116114
"subsf3.c",
117115
"subvdi3.c",
118116
"subvsi3.c",
119117
"subvti3.c",
120-
"subtf3.c",
121118
"trampoline_setup.c",
122119
"truncdfhf2.c",
123120
"truncdfsf2.c",
@@ -126,6 +123,7 @@ var genericBuiltins = []string{
126123
"ucmpti2.c",
127124
"udivdi3.c",
128125
"udivmoddi4.c",
126+
//"udivmodsi4.c",
129127
"udivmodti4.c",
130128
"udivsi3.c",
131129
"udivti3.c",

builder/cc1as.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
8282
// Parse the arguments.
8383
const OptTable &OptTbl = getDriverOptTable();
8484

85-
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
85+
llvm::opt::Visibility VisibilityMask(options::CC1AsOption);
8686
unsigned MissingArgIndex, MissingArgCount;
87-
InputArgList Args = OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount,
88-
IncludedFlagsBitmask);
87+
InputArgList Args =
88+
OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount, VisibilityMask);
8989

9090
// Check for missing argument error.
9191
if (MissingArgCount) {
@@ -98,7 +98,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
9898
for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
9999
auto ArgString = A->getAsString(Args);
100100
std::string Nearest;
101-
if (OptTbl.findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
101+
if (OptTbl.findNearest(ArgString, Nearest, VisibilityMask) > 1)
102102
Diags.Report(diag::err_drv_unknown_argument) << ArgString;
103103
else
104104
Diags.Report(diag::err_drv_unknown_argument_with_suggestion)
@@ -521,9 +521,10 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
521521
if (Asm.ShowHelp) {
522522
getDriverOptTable().printHelp(
523523
llvm::outs(), "clang -cc1as [options] file...",
524-
"Clang Integrated Assembler",
525-
/*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
526-
/*ShowAllAliases=*/false);
524+
"Clang Integrated Assembler", /*ShowHidden=*/false,
525+
/*ShowAllAliases=*/false,
526+
llvm::opt::Visibility(driver::options::CC1AsOption));
527+
527528
return 0;
528529
}
529530

builder/cc1as.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct AssemblerInvocation {
9393
EmitDwarfUnwindType EmitDwarfUnwind;
9494

9595
// Whether to emit compact-unwind for non-canonical entries.
96-
// Note: may be overridden by other constraints.
96+
// Note: maybe overriden by other constraints.
9797
unsigned EmitCompactUnwindNonCanonical : 1;
9898

9999
/// The name of the relocation model to use.

builder/sizes_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func TestBinarySize(t *testing.T) {
4141
// This is a small number of very diverse targets that we want to test.
4242
tests := []sizeTest{
4343
// microcontrollers
44-
{"hifive1b", "examples/echo", 4476, 280, 0, 2252},
45-
{"microbit", "examples/serial", 2724, 388, 8, 2256},
46-
{"wioterminal", "examples/pininterrupt", 5996, 1484, 116, 6816},
44+
{"hifive1b", "examples/echo", 4484, 280, 0, 2252},
45+
{"microbit", "examples/serial", 2732, 388, 8, 2256},
46+
{"wioterminal", "examples/pininterrupt", 6016, 1484, 116, 6816},
4747

4848
// TODO: also check wasm. Right now this is difficult, because
4949
// wasm binaries are run through wasm-opt and therefore the

cgo/libclang_config_llvm17.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !byollvm && !llvm15 && !llvm16
1+
//go:build !byollvm && llvm17
22

33
package cgo
44

cgo/libclang_config_llvm18.go

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

compileopts/target.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
319319
case "arm64":
320320
spec.CPU = "generic"
321321
if goos == "darwin" {
322-
spec.Features = "+neon"
322+
spec.Features = "+fp-armv8,+neon"
323323
} else if goos == "windows" {
324-
spec.Features = "+neon,-fmv"
324+
spec.Features = "+fp-armv8,+neon,-fmv"
325325
} else { // linux
326-
spec.Features = "+neon,-fmv,-outline-atomics"
326+
spec.Features = "+fp-armv8,+neon,-fmv,-outline-atomics"
327327
}
328328
case "wasm":
329329
spec.CPU = "generic"

0 commit comments

Comments
 (0)