Skip to content

Commit a32c51a

Browse files
committed
WIP: add support for LLVM 19
This is incomplete. I've only made this so that we have a LLVM 19 branch ready to go once LLVM 19 is released (and the Xtensa fork has been rebased).
1 parent 1ef1aa7 commit a32c51a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+237
-193
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-18-v1
13+
- llvm-source-19-v1
1414
- run:
1515
name: "Fetch LLVM source"
1616
command: make llvm-source
1717
- save_cache:
18-
key: llvm-source-18-v1
18+
key: llvm-source-19-v1
1919
paths:
2020
- llvm-project/clang/lib/Headers
2121
- llvm-project/clang/include
@@ -107,12 +107,12 @@ jobs:
107107
# "make lint" fails before go 1.21 because internal/tools/go.mod specifies packages that require go 1.21
108108
fmt-check: false
109109
resource_class: large
110-
test-llvm18-go123:
110+
test-llvm19-go123:
111111
docker:
112112
- image: golang:1.23-bullseye
113113
steps:
114114
- test-linux:
115-
llvm: "18"
115+
llvm: "19"
116116
resource_class: large
117117

118118
workflows:
@@ -121,5 +121,5 @@ workflows:
121121
# This tests our lowest supported versions of Go and LLVM, to make sure at
122122
# least the smoke tests still pass.
123123
- test-llvm15-go119
124-
# This tests LLVM 18 support when linking against system libraries.
125-
- test-llvm18-go123
124+
# This tests LLVM 19 support when linking against system libraries.
125+
- test-llvm19-go123

.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-18-${{ matrix.os }}-v2
46+
key: llvm-source-19-${{ matrix.os }}-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-18-${{ matrix.os }}-v3
71+
key: llvm-build-19-${{ matrix.os }}-v1
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, 18]
131+
version: [16, 17, 18, 19]
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 == 18
155+
if: matrix.version == 19
156156
run: go install
157157
- name: Check binary
158-
if: matrix.version == 18
158+
if: matrix.version == 19
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-18-linux-alpine-v1
46+
key: llvm-source-19-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-18-linux-alpine-v2
71+
key: llvm-build-19-linux-alpine-v1
7272
path: llvm-build
7373
- name: Build LLVM
7474
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -200,7 +200,7 @@ jobs:
200200
uses: actions/cache/restore@v4
201201
id: cache-llvm-source
202202
with:
203-
key: llvm-source-18-linux-asserts-v1
203+
key: llvm-source-19-linux-asserts-v1
204204
path: |
205205
llvm-project/clang/lib/Headers
206206
llvm-project/clang/include
@@ -225,7 +225,7 @@ jobs:
225225
uses: actions/cache/restore@v4
226226
id: cache-llvm-build
227227
with:
228-
key: llvm-build-18-linux-asserts-v2
228+
key: llvm-build-19-linux-asserts-v1
229229
path: llvm-build
230230
- name: Build LLVM
231231
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -313,7 +313,7 @@ jobs:
313313
uses: actions/cache/restore@v4
314314
id: cache-llvm-source
315315
with:
316-
key: llvm-source-18-linux-v1
316+
key: llvm-source-19-linux-v1
317317
path: |
318318
llvm-project/clang/lib/Headers
319319
llvm-project/clang/include
@@ -338,7 +338,7 @@ jobs:
338338
uses: actions/cache/restore@v4
339339
id: cache-llvm-build
340340
with:
341-
key: llvm-build-18-linux-${{ matrix.goarch }}-v2
341+
key: llvm-build-19-linux-${{ matrix.goarch }}-v2
342342
path: llvm-build
343343
- name: Build LLVM
344344
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-18
39-
ghcr.io/${{ github.repository_owner }}/llvm-18
38+
tinygo/llvm-19
39+
ghcr.io/${{ github.repository_owner }}/llvm-19
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-18-linux-nix-v1
27+
key: llvm-source-19-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/noble/ llvm-toolchain-noble-18 main' | sudo tee /etc/apt/sources.list.d/llvm.list
5+
echo 'deb https://apt.llvm.org/noble/ llvm-toolchain-noble-19 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-18-dev \
10-
clang-18 \
11-
libclang-18-dev \
12-
lld-18
9+
llvm-19-dev \
10+
clang-19 \
11+
libclang-19-dev \
12+
lld-19

.github/workflows/sizediff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/cache@v4
3131
id: cache-llvm-source
3232
with:
33-
key: llvm-source-18-sizediff-v1
33+
key: llvm-source-19-sizediff-v1
3434
path: |
3535
llvm-project/compiler-rt
3636
- 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-18-windows-v1
44+
key: llvm-source-19-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-18-windows-v2
69+
key: llvm-build-19-windows-v1
7070
path: llvm-build
7171
- name: Build LLVM
7272
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

GNUmakefile

Lines changed: 3 additions & 3 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 = 18 17 16 15
13+
LLVM_VERSIONS = 19 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)
@@ -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 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
150+
CLANG_LIB_NAMES = clangAnalysis clangAPINotes clangAST clangASTMatchers clangBasic clangCodeGen clangCrossTU clangDriver clangDynamicASTMatchers clangEdit clangExtractAPI clangFormat clangFrontend clangFrontendTool clangHandleCXX clangHandleLLVM clangIndex clangInstallAPI 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.
@@ -238,7 +238,7 @@ gen-device-renesas: build/gen-device-svd
238238
GO111MODULE=off $(GO) fmt ./src/device/renesas
239239

240240
$(LLVM_PROJECTDIR)/llvm:
241-
git clone -b tinygo_xtensa_release_18.1.2 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
241+
git clone -b llvmorg-19.1.0-rc3 --depth=1 https://github.com/llvm/llvm-project $(LLVM_PROJECTDIR)
242242
llvm-source: $(LLVM_PROJECTDIR)/llvm ## Get LLVM sources
243243

244244
# Configure LLVM.

builder/cc1as.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
145145
}
146146

147147
Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
148+
Opts.SSE2AVX = Args.hasArg(OPT_msse2avx);
148149
if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
149150
Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
150151
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
@@ -234,6 +235,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
234235

235236
Opts.EmitCompactUnwindNonCanonical =
236237
Args.hasArg(OPT_femit_compact_unwind_non_canonical);
238+
Opts.Crel = Args.hasArg(OPT_crel);
237239

238240
Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);
239241

@@ -287,8 +289,14 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
287289
assert(MRI && "Unable to create target register info!");
288290

289291
MCTargetOptions MCOptions;
292+
MCOptions.MCRelaxAll = Opts.RelaxAll;
290293
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
291294
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
295+
MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
296+
MCOptions.Crel = Opts.Crel;
297+
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
298+
MCOptions.X86Sse2Avx = Opts.SSE2AVX;
299+
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
292300
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
293301

294302
std::unique_ptr<MCAsmInfo> MAI(
@@ -297,9 +305,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
297305

298306
// Ensure MCAsmInfo initialization occurs before any use, otherwise sections
299307
// may be created with a combination of default and explicit settings.
300-
MAI->setCompressDebugSections(Opts.CompressDebugSections);
301308

302-
MAI->setRelaxELFRelocations(Opts.RelaxELFRelocations);
303309

304310
bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;
305311
if (Opts.OutputPath.empty())
@@ -343,8 +349,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
343349
MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
344350
Ctx.setObjectFileInfo(MOFI.get());
345351

346-
if (Opts.SaveTemporaryLabels)
347-
Ctx.setAllowTemporaryLabels(false);
348352
if (Opts.GenDwarfForAssembly)
349353
Ctx.setGenDwarfForAssembly(true);
350354
if (!Opts.DwarfDebugFlags.empty())
@@ -381,6 +385,9 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
381385
MCOptions.MCNoWarn = Opts.NoWarn;
382386
MCOptions.MCFatalWarnings = Opts.FatalWarnings;
383387
MCOptions.MCNoTypeCheck = Opts.NoTypeCheck;
388+
MCOptions.ShowMCInst = Opts.ShowInst;
389+
MCOptions.AsmVerbose = true;
390+
MCOptions.MCUseDwarfDirectory = MCTargetOptions::EnableDwarfDirectory;
384391
MCOptions.ABIName = Opts.TargetABI;
385392

386393
// FIXME: There is a bit of code duplication with addPassesToEmitFile.
@@ -395,10 +402,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
395402
TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
396403

397404
auto FOut = std::make_unique<formatted_raw_ostream>(*Out);
398-
Str.reset(TheTarget->createAsmStreamer(
399-
Ctx, std::move(FOut), /*asmverbose*/ true,
400-
/*useDwarfDirectory*/ true, IP, std::move(CE), std::move(MAB),
401-
Opts.ShowInst));
405+
Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), IP,
406+
std::move(CE), std::move(MAB)));
402407
} else if (Opts.OutputType == AssemblerInvocation::FT_Null) {
403408
Str.reset(createNullStreamer(Ctx));
404409
} else {
@@ -421,9 +426,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
421426

422427
Triple T(Opts.Triple);
423428
Str.reset(TheTarget->createMCObjectStreamer(
424-
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
425-
Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
426-
/*DWARFMustBeAtTheEnd*/ true));
429+
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
427430
Str.get()->initSections(Opts.NoExecStack, *STI);
428431
}
429432

@@ -436,9 +439,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
436439
Str.get()->emitZeros(1);
437440
}
438441

439-
// Assembly to object compilation should leverage assembly info.
440-
Str->setUseAssemblerInfoForParsing(true);
441-
442442
bool Failed = false;
443443

444444
std::unique_ptr<MCAsmParser> Parser(

0 commit comments

Comments
 (0)