Skip to content

Commit fdfbfb0

Browse files
committed
all: add full LLVM 20 support
This switches the Espressif fork from LLVM 19 to LLVM 20, so we can use the improvements made between those LLVM versions. It also better aligns with the system-LLVM build method, which currently also defaults to LLVM 20.
1 parent 0964176 commit fdfbfb0

38 files changed

+190
-178
lines changed

.github/workflows/build-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: actions/cache/restore@v4
4646
id: cache-llvm-source
4747
with:
48-
key: llvm-source-19-${{ matrix.os }}-v1
48+
key: llvm-source-20-${{ matrix.os }}-v1
4949
path: |
5050
llvm-project/clang/lib/Headers
5151
llvm-project/clang/include
@@ -70,7 +70,7 @@ jobs:
7070
uses: actions/cache/restore@v4
7171
id: cache-llvm-build
7272
with:
73-
key: llvm-build-19-${{ matrix.os }}-v1
73+
key: llvm-build-20-${{ matrix.os }}-v1
7474
path: llvm-build
7575
- name: Build LLVM
7676
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

.github/workflows/linux.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/cache/restore@v4
4949
id: cache-llvm-source
5050
with:
51-
key: llvm-source-19-linux-alpine-v1
51+
key: llvm-source-20-linux-alpine-v1
5252
path: |
5353
llvm-project/clang/lib/Headers
5454
llvm-project/clang/include
@@ -73,7 +73,7 @@ jobs:
7373
uses: actions/cache/restore@v4
7474
id: cache-llvm-build
7575
with:
76-
key: llvm-build-19-linux-alpine-v1
76+
key: llvm-build-20-linux-alpine-v1
7777
path: llvm-build
7878
- name: Build LLVM
7979
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -197,7 +197,7 @@ jobs:
197197
uses: actions/cache/restore@v4
198198
id: cache-llvm-source
199199
with:
200-
key: llvm-source-19-linux-asserts-v1
200+
key: llvm-source-20-linux-asserts-v1
201201
path: |
202202
llvm-project/clang/lib/Headers
203203
llvm-project/clang/include
@@ -222,7 +222,7 @@ jobs:
222222
uses: actions/cache/restore@v4
223223
id: cache-llvm-build
224224
with:
225-
key: llvm-build-19-linux-asserts-v1
225+
key: llvm-build-20-linux-asserts-v1
226226
path: llvm-build
227227
- name: Build LLVM
228228
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -304,7 +304,7 @@ jobs:
304304
uses: actions/cache/restore@v4
305305
id: cache-llvm-source
306306
with:
307-
key: llvm-source-19-linux-v1
307+
key: llvm-source-20-linux-v1
308308
path: |
309309
llvm-project/clang/lib/Headers
310310
llvm-project/clang/include
@@ -329,7 +329,7 @@ jobs:
329329
uses: actions/cache/restore@v4
330330
id: cache-llvm-build
331331
with:
332-
key: llvm-build-19-linux-${{ matrix.goarch }}-v3
332+
key: llvm-build-20-linux-${{ matrix.goarch }}-v3
333333
path: llvm-build
334334
- name: Build LLVM
335335
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-19
39-
ghcr.io/${{ github.repository_owner }}/llvm-19
38+
tinygo/llvm-20
39+
ghcr.io/${{ github.repository_owner }}/llvm-20
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
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/cache/restore@v4
3030
id: cache-llvm-source
3131
with:
32-
key: llvm-source-19-linux-nix-v1
32+
key: llvm-source-20-linux-nix-v1
3333
path: |
3434
llvm-project/compiler-rt
3535
- name: Download LLVM source

.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-19-sizediff-v1
33+
key: llvm-source-20-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
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions/cache/restore@v4
4848
id: cache-llvm-source
4949
with:
50-
key: llvm-source-19-windows-v1
50+
key: llvm-source-20-windows-v1
5151
path: |
5252
llvm-project/clang/lib/Headers
5353
llvm-project/clang/include
@@ -72,7 +72,7 @@ jobs:
7272
uses: actions/cache/restore@v4
7373
id: cache-llvm-build
7474
with:
75-
key: llvm-build-19-windows-v1
75+
key: llvm-build-20-windows-v1
7676
path: llvm-build
7777
- name: Build LLVM
7878
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ gen-device-renesas: build/gen-device-svd
243243
GO111MODULE=off $(GO) fmt ./src/device/renesas
244244

245245
$(LLVM_PROJECTDIR)/llvm:
246-
git clone -b xtensa_release_19.1.2 --depth=1 https://github.com/espressif/llvm-project $(LLVM_PROJECTDIR)
246+
git clone -b release/esp_20.x --depth=1 https://github.com/espressif/llvm-project $(LLVM_PROJECTDIR)
247247
llvm-source: $(LLVM_PROJECTDIR)/llvm ## Get LLVM sources
248248

249249
# Configure LLVM.

builder/cc1as.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
144144
.Default(llvm::DebugCompressionType::None);
145145
}
146146

147-
Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
148-
Opts.SSE2AVX = Args.hasArg(OPT_msse2avx);
149147
if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
150148
Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
151149
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
@@ -236,6 +234,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
236234
Opts.EmitCompactUnwindNonCanonical =
237235
Args.hasArg(OPT_femit_compact_unwind_non_canonical);
238236
Opts.Crel = Args.hasArg(OPT_crel);
237+
Opts.ImplicitMapsyms = Args.hasArg(OPT_mmapsyms_implicit);
238+
Opts.X86RelaxRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
239+
Opts.X86Sse2Avx = Args.hasArg(OPT_msse2avx);
239240

240241
Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);
241242

@@ -294,8 +295,9 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
294295
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
295296
MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
296297
MCOptions.Crel = Opts.Crel;
297-
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
298-
MCOptions.X86Sse2Avx = Opts.SSE2AVX;
298+
MCOptions.ImplicitMapSyms = Opts.ImplicitMapsyms;
299+
MCOptions.X86RelaxRelocations = Opts.X86RelaxRelocations;
300+
MCOptions.X86Sse2Avx = Opts.X86Sse2Avx;
299301
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
300302
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
301303

@@ -343,10 +345,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
343345
// MCObjectFileInfo needs a MCContext reference in order to initialize itself.
344346
std::unique_ptr<MCObjectFileInfo> MOFI(
345347
TheTarget->createMCObjectFileInfo(Ctx, PIC));
346-
if (Opts.DarwinTargetVariantTriple)
347-
MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
348-
if (!Opts.DarwinTargetVariantSDKVersion.empty())
349-
MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
350348
Ctx.setObjectFileInfo(MOFI.get());
351349

352350
if (Opts.GenDwarfForAssembly)
@@ -428,6 +426,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
428426
Str.reset(TheTarget->createMCObjectStreamer(
429427
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
430428
Str.get()->initSections(Opts.NoExecStack, *STI);
429+
if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
430+
Triple *TVT = Opts.DarwinTargetVariantTriple
431+
? &*Opts.DarwinTargetVariantTriple
432+
: nullptr;
433+
Str->emitVersionForTarget(T, VersionTuple(), TVT,
434+
Opts.DarwinTargetVariantSDKVersion);
435+
}
431436
}
432437

433438
// When -fembed-bitcode is passed to clang_as, a 1-byte marker

builder/cc1as.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ struct AssemblerInvocation {
4545
LLVM_PREFERRED_TYPE(bool)
4646
unsigned GenDwarfForAssembly : 1;
4747
LLVM_PREFERRED_TYPE(bool)
48-
unsigned RelaxELFRelocations : 1;
49-
LLVM_PREFERRED_TYPE(bool)
50-
unsigned SSE2AVX : 1;
51-
LLVM_PREFERRED_TYPE(bool)
5248
unsigned Dwarf64 : 1;
5349
unsigned DwarfVersion;
5450
std::string DwarfDebugFlags;
@@ -117,6 +113,13 @@ struct AssemblerInvocation {
117113

118114
LLVM_PREFERRED_TYPE(bool)
119115
unsigned Crel : 1;
116+
LLVM_PREFERRED_TYPE(bool)
117+
unsigned ImplicitMapsyms : 1;
118+
119+
LLVM_PREFERRED_TYPE(bool)
120+
unsigned X86RelaxRelocations : 1;
121+
LLVM_PREFERRED_TYPE(bool)
122+
unsigned X86Sse2Avx : 1;
120123

121124
/// The name of the relocation model to use.
122125
std::string RelocationModel;
@@ -148,7 +151,6 @@ struct AssemblerInvocation {
148151
ShowInst = 0;
149152
ShowEncoding = 0;
150153
RelaxAll = 0;
151-
SSE2AVX = 0;
152154
NoExecStack = 0;
153155
FatalWarnings = 0;
154156
NoWarn = 0;
@@ -160,6 +162,9 @@ struct AssemblerInvocation {
160162
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
161163
EmitCompactUnwindNonCanonical = false;
162164
Crel = false;
165+
ImplicitMapsyms = 0;
166+
X86RelaxRelocations = 0;
167+
X86Sse2Avx = 0;
163168
}
164169

165170
static bool CreateFromArgs(AssemblerInvocation &Res,

builder/clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ bool tinygo_clang_driver(int argc, char **argv) {
6060
}
6161

6262
// Create the actual diagnostics engine.
63-
Clang->createDiagnostics();
63+
Clang->createDiagnostics(*llvm::vfs::getRealFileSystem());
6464
if (!Clang->hasDiagnostics()) {
6565
return false;
6666
}

0 commit comments

Comments
 (0)