Skip to content

Commit ca874ce

Browse files
committed
all: update to LLVM 14
Switch over to LLVM 14 for static builds. Keep using LLVM 13 for regular builds for now. This uses a branch of the upstream Espressif branch to fix an issue, see: espressif/llvm-project#59
1 parent 7ac52da commit ca874ce

Some content is hidden

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

43 files changed

+95
-64
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ commands:
2222
steps:
2323
- restore_cache:
2424
keys:
25-
- llvm-source-13-v3
25+
- llvm-source-14-v1
2626
- run:
2727
name: "Fetch LLVM source"
2828
command: make llvm-source
2929
- save_cache:
30-
key: llvm-source-13-v3
30+
key: llvm-source-14-v1
3131
paths:
3232
- llvm-project/clang/lib/Headers
3333
- llvm-project/clang/include

.github/workflows/build-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions/cache@v2
3636
id: cache-llvm-source
3737
with:
38-
key: llvm-source-13-macos-v2
38+
key: llvm-source-14-macos-v1
3939
path: |
4040
llvm-project/clang/lib/Headers
4141
llvm-project/clang/include
@@ -49,7 +49,7 @@ jobs:
4949
uses: actions/cache@v2
5050
id: cache-llvm-build
5151
with:
52-
key: llvm-build-13-macos-v3
52+
key: llvm-build-14-macos-v1
5353
path: llvm-build
5454
- name: Build LLVM
5555
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

.github/workflows/linux.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: actions/cache@v2
3939
id: cache-llvm-source
4040
with:
41-
key: llvm-source-13-linux-v2
41+
key: llvm-source-14-linux-v1
4242
path: |
4343
llvm-project/clang/lib/Headers
4444
llvm-project/clang/include
@@ -52,7 +52,7 @@ jobs:
5252
uses: actions/cache@v2
5353
id: cache-llvm-build
5454
with:
55-
key: llvm-build-13-linux-v2
55+
key: llvm-build-14-linux-v1
5656
path: llvm-build
5757
- name: Build LLVM
5858
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -180,7 +180,7 @@ jobs:
180180
uses: actions/cache@v2
181181
id: cache-llvm-source
182182
with:
183-
key: llvm-source-13-linux-asserts-v2
183+
key: llvm-source-14-linux-asserts-v1
184184
path: |
185185
llvm-project/clang/lib/Headers
186186
llvm-project/clang/include
@@ -194,7 +194,7 @@ jobs:
194194
uses: actions/cache@v2
195195
id: cache-llvm-build
196196
with:
197-
key: llvm-build-13-linux-asserts-v2
197+
key: llvm-build-14-linux-asserts-v1
198198
path: llvm-build
199199
- name: Build LLVM
200200
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions/cache@v2
3636
id: cache-llvm-source
3737
with:
38-
key: llvm-source-13-windows-v2
38+
key: llvm-source-14-windows-v1
3939
path: |
4040
llvm-project/clang/lib/Headers
4141
llvm-project/clang/include
@@ -49,7 +49,7 @@ jobs:
4949
uses: actions/cache@v2
5050
id: cache-llvm-build
5151
with:
52-
key: llvm-build-13-windows-v2
52+
key: llvm-build-14-windows-v1
5353
path: llvm-build
5454
- name: Build LLVM
5555
if: steps.cache-llvm-build.outputs.cache-hit != 'true'

Makefile

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 = 13 12 11
13+
LLVM_VERSIONS = 14 13 12 11
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)
@@ -91,11 +91,11 @@ CLANG_LIB_NAMES = clangAnalysis clangAST clangASTMatchers clangBasic clangCodeGe
9191
CLANG_LIBS = $(START_GROUP) $(addprefix -l,$(CLANG_LIB_NAMES)) $(END_GROUP) -lstdc++
9292

9393
# Libraries that should be linked in for the statically linked LLD.
94-
LLD_LIB_NAMES = lldCOFF lldCommon lldCore lldDriver lldELF lldMachO2 lldMinGW lldReaderWriter lldWasm lldYAML
94+
LLD_LIB_NAMES = lldCOFF lldCommon lldELF lldMachO lldMinGW lldWasm
9595
LLD_LIBS = $(START_GROUP) $(addprefix -l,$(LLD_LIB_NAMES)) $(END_GROUP)
9696

9797
# Other libraries that are needed to link TinyGo.
98-
EXTRA_LIB_NAMES = LLVMInterpreter
98+
EXTRA_LIB_NAMES = LLVMInterpreter LLVMMCA LLVMX86TargetMCA
9999

100100
# All libraries to be built and linked with the tinygo binary (lib/lib*.a).
101101
LIB_NAMES = clang $(CLANG_LIB_NAMES) $(LLD_LIB_NAMES) $(EXTRA_LIB_NAMES)
@@ -175,7 +175,7 @@ gen-device-rp: build/gen-device-svd
175175

176176
# Get LLVM sources.
177177
$(LLVM_PROJECTDIR)/llvm:
178-
git clone -b xtensa_release_13.0.0 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
178+
git clone -b xtensa_release_14.0.0-patched --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
179179
llvm-source: $(LLVM_PROJECTDIR)/llvm
180180

181181
# Configure LLVM.

builder/cc1as.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/MC/MCStreamer.h"
3939
#include "llvm/MC/MCSubtargetInfo.h"
4040
#include "llvm/MC/MCTargetOptions.h"
41+
#include "llvm/MC/TargetRegistry.h"
4142
#include "llvm/Option/Arg.h"
4243
#include "llvm/Option/ArgList.h"
4344
#include "llvm/Option/OptTable.h"
@@ -51,7 +52,6 @@
5152
#include "llvm/Support/Process.h"
5253
#include "llvm/Support/Signals.h"
5354
#include "llvm/Support/SourceMgr.h"
54-
#include "llvm/Support/TargetRegistry.h"
5555
#include "llvm/Support/TargetSelect.h"
5656
#include "llvm/Support/Timer.h"
5757
#include "llvm/Support/raw_ostream.h"
@@ -120,7 +120,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
120120
llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
121121
.Case("none", llvm::DebugCompressionType::None)
122122
.Case("zlib", llvm::DebugCompressionType::Z)
123-
.Case("zlib-gnu", llvm::DebugCompressionType::GNU)
124123
.Default(llvm::DebugCompressionType::None);
125124
}
126125

@@ -382,7 +381,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
382381
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
383382
Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
384383
/*DWARFMustBeAtTheEnd*/ true));
385-
Str.get()->InitSections(Opts.NoExecStack);
384+
Str.get()->initSections(Opts.NoExecStack, *STI);
386385
}
387386

388387
// When -fembed-bitcode is passed to clang_as, a 1-byte marker
@@ -442,7 +441,7 @@ bool ExecuteAssembler(AssemblerInvocation &Opts,
442441
return Failed;
443442
}
444443

445-
static void LLVMErrorHandler(void *UserData, const std::string &Message,
444+
static void LLVMErrorHandler(void *UserData, const char *Message,
446445
bool GenCrashDiag) {
447446
DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
448447

builder/darwin-libsystem.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/tinygo-org/tinygo/compileopts"
88
"github.com/tinygo-org/tinygo/goenv"
9+
"tinygo.org/x/go-llvm"
910
)
1011

1112
// Create a job that builds a Darwin libSystem.dylib stub library. This library
@@ -38,8 +39,12 @@ func makeDarwinLibSystemJob(config *compileopts.Config, tmpdir string) *compileJ
3839

3940
// Link object file to dynamic library.
4041
platformVersion := strings.TrimPrefix(strings.Split(config.Triple(), "-")[2], "macosx")
42+
flavor := "darwin"
43+
if strings.Split(llvm.Version, ".")[0] < "13" {
44+
flavor = "darwinnew" // needed on LLVM 12 and below
45+
}
4146
flags = []string{
42-
"-flavor", "darwinnew",
47+
"-flavor", flavor,
4348
"-demangle",
4449
"-dynamic",
4550
"-dylib",

builder/lld.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ extern "C" {
88

99
bool tinygo_link_elf(int argc, char **argv) {
1010
std::vector<const char*> args(argv, argv + argc);
11-
return lld::elf::link(args, false, llvm::outs(), llvm::errs());
11+
return lld::elf::link(args, llvm::outs(), llvm::errs(), false, false);
1212
}
1313

1414
bool tinygo_link_macho(int argc, char **argv) {
1515
std::vector<const char*> args(argv, argv + argc);
16-
return lld::macho::link(args, false, llvm::outs(), llvm::errs());
16+
return lld::macho::link(args, llvm::outs(), llvm::errs(), false, false);
1717
}
1818

1919
bool tinygo_link_mingw(int argc, char **argv) {
2020
std::vector<const char*> args(argv, argv + argc);
21-
return lld::mingw::link(args, false, llvm::outs(), llvm::errs());
21+
return lld::mingw::link(args, llvm::outs(), llvm::errs(), false, false);
2222
}
2323

2424
bool tinygo_link_wasm(int argc, char **argv) {
2525
std::vector<const char*> args(argv, argv + argc);
26-
return lld::wasm::link(args, false, llvm::outs(), llvm::errs());
26+
return lld::wasm::link(args, llvm::outs(), llvm::errs(), false, false);
2727
}
2828

2929
} // external "C"

builder/tools-builtin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func RunTool(tool string, args ...string) error {
5454
ok = C.tinygo_clang_driver(C.int(len(args)), (**C.char)(buf))
5555
case "ld.lld":
5656
switch linker {
57-
case "darwinnew":
57+
case "darwin", "darwinnew": // darwinnew is only needed for LLVM 12 and below
5858
ok = C.tinygo_link_macho(C.int(len(args)), (**C.char)(buf))
5959
case "elf":
6060
ok = C.tinygo_link_elf(C.int(len(args)), (**C.char)(buf))

cgo/libclang_config_llvm13.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !byollvm && !llvm11 && !llvm12
2-
// +build !byollvm,!llvm11,!llvm12
1+
//go:build !byollvm && !llvm11 && !llvm12 && !llvm14
2+
// +build !byollvm,!llvm11,!llvm12,!llvm14
33

44
package cgo
55

0 commit comments

Comments
 (0)