Skip to content

Commit 00d22d1

Browse files
committed
all: switch to LLVM 11 for static builds
This commit switches to LLVm 11 for builds with LLVM linked statically (e.g. `make`). It does not yet switch the default for builds dynamically linked to LLVM, that should be done in a later change. This commit also changes to use the default host toolchain (probably GCC) instead of Clang as the default compiler in CI. There were some issues with Clang 3.8 in CI and hopefully this will fix it.
1 parent 7abc671 commit 00d22d1

File tree

6 files changed

+43
-41
lines changed

6 files changed

+43
-41
lines changed

.circleci/config.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ commands:
6868
steps:
6969
- restore_cache:
7070
keys:
71-
- llvm-source-10-v1
71+
- llvm-source-11-v1
7272
- run:
7373
name: "Fetch LLVM source"
7474
command: make llvm-source
7575
- save_cache:
76-
key: llvm-source-10-v1
76+
key: llvm-source-11-v1
7777
paths:
7878
- llvm-project
7979
build-wasi-libc:
@@ -153,25 +153,22 @@ commands:
153153
- llvm-source-linux
154154
- restore_cache:
155155
keys:
156-
- llvm-build-10-linux-v1-assert
156+
- llvm-build-11-linux-v1-assert
157157
- run:
158158
name: "Build LLVM"
159159
command: |
160160
if [ ! -f llvm-build/lib/liblldELF.a ]
161161
then
162162
# install dependencies
163-
sudo apt-get install cmake clang ninja-build
164-
# make build faster
165-
export CC=clang
166-
export CXX=clang++
163+
sudo apt-get install cmake ninja-build
167164
# hack ninja to use less jobs
168165
echo -e '#!/bin/sh\n/usr/bin/ninja -j3 "$@"' > /go/bin/ninja
169166
chmod +x /go/bin/ninja
170167
# build!
171168
make ASSERT=1 llvm-build
172169
fi
173170
- save_cache:
174-
key: llvm-build-10-linux-v1-assert
171+
key: llvm-build-11-linux-v1-assert
175172
paths:
176173
llvm-build
177174
- run: make ASSERT=1
@@ -214,25 +211,22 @@ commands:
214211
- llvm-source-linux
215212
- restore_cache:
216213
keys:
217-
- llvm-build-10-linux-v1
214+
- llvm-build-11-linux-v1-noassert
218215
- run:
219216
name: "Build LLVM"
220217
command: |
221218
if [ ! -f llvm-build/lib/liblldELF.a ]
222219
then
223220
# install dependencies
224-
sudo apt-get install cmake clang ninja-build
225-
# make build faster
226-
export CC=clang
227-
export CXX=clang++
221+
sudo apt-get install cmake ninja-build
228222
# hack ninja to use less jobs
229223
echo -e '#!/bin/sh\n/usr/bin/ninja -j3 "$@"' > /go/bin/ninja
230224
chmod +x /go/bin/ninja
231225
# build!
232226
make llvm-build
233227
fi
234228
- save_cache:
235-
key: llvm-build-10-linux-v1
229+
key: llvm-build-11-linux-v1-noassert
236230
paths:
237231
llvm-build
238232
- build-wasi-libc
@@ -286,17 +280,17 @@ commands:
286280
- go-cache-macos-v2-{{ checksum "go.mod" }}
287281
- restore_cache:
288282
keys:
289-
- llvm-source-10-macos-v1
283+
- llvm-source-11-macos-v1
290284
- run:
291285
name: "Fetch LLVM source"
292286
command: make llvm-source
293287
- save_cache:
294-
key: llvm-source-10-macos-v1
288+
key: llvm-source-11-macos-v1
295289
paths:
296290
- llvm-project
297291
- restore_cache:
298292
keys:
299-
- llvm-build-10-macos-v1
293+
- llvm-build-11-macos-v1
300294
- run:
301295
name: "Build LLVM"
302296
command: |
@@ -308,7 +302,7 @@ commands:
308302
make llvm-build
309303
fi
310304
- save_cache:
311-
key: llvm-build-10-macos-v1
305+
key: llvm-build-11-macos-v1
312306
paths:
313307
llvm-build
314308
- restore_cache:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ gen-device-stm32: build/gen-device-svd
146146

147147
# Get LLVM sources.
148148
$(LLVM_PROJECTDIR)/README.md:
149-
git clone -b xtensa_release_10.0.1 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
149+
git clone -b xtensa_release_11.0.0 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
150150
llvm-source: $(LLVM_PROJECTDIR)/README.md
151151

152152
# Configure LLVM.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ The original reasoning was: if [Python](https://micropython.org/) can run on mic
148148

149149
This project is licensed under the BSD 3-clause license, just like the [Go project](https://golang.org/LICENSE) itself.
150150

151-
Some code has been copied from the LLVM project and is therefore licensed under [a variant of the Apache 2.0 license](http://releases.llvm.org/10.0.0/LICENSE.TXT). This has been clearly indicated in the header of these files.
151+
Some code has been copied from the LLVM project and is therefore licensed under [a variant of the Apache 2.0 license](http://releases.llvm.org/11.0.0/LICENSE.TXT). This has been clearly indicated in the header of these files.
152152

153153
Some code has been copied and/or ported from Paul Stoffregen's Teensy libraries and is therefore licensed under PJRC's license. This has been clearly indicated in the header of these files.

azure-pipelines.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- task: Cache@2
1919
displayName: Cache LLVM source
2020
inputs:
21-
key: llvm-source-10-windows-v1
21+
key: llvm-source-11-windows-v1
2222
path: llvm-project
2323
- task: Bash@3
2424
displayName: Download LLVM source
@@ -32,7 +32,7 @@ jobs:
3232
- task: CacheBeta@0
3333
displayName: Cache LLVM build
3434
inputs:
35-
key: llvm-build-10-windows-v1
35+
key: llvm-build-11-windows-v1
3636
path: llvm-build
3737
- task: Bash@3
3838
displayName: Build LLVM
@@ -41,7 +41,11 @@ jobs:
4141
script: |
4242
if [ ! -f llvm-build/lib/liblldELF.a ]
4343
then
44+
# install dependencies
4445
choco install ninja
46+
# hack ninja to use fewer jobs
47+
echo -e 'C:\\ProgramData\\Chocolatey\\bin\\ninja -j4 %*' > /usr/bin/ninja.bat
48+
# build!
4549
make llvm-build
4650
fi
4751
- task: Bash@3

builder/cc1as.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
101101

102102
// Target Options
103103
Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
104-
Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
104+
Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
105105
Opts.Features = Args.getAllArgValues(OPT_target_feature);
106106

107107
// Use the default target triple if unspecified.
@@ -132,13 +132,19 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
132132

133133
Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
134134
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
135-
Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
136-
Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
137-
Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
138-
Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
139-
140-
for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
141-
Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
135+
Opts.DwarfDebugFlags =
136+
std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
137+
Opts.DwarfDebugProducer =
138+
std::string(Args.getLastArgValue(OPT_dwarf_debug_producer));
139+
Opts.DebugCompilationDir =
140+
std::string(Args.getLastArgValue(OPT_fdebug_compilation_dir));
141+
Opts.MainFileName = std::string(Args.getLastArgValue(OPT_main_file_name));
142+
143+
for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
144+
auto Split = StringRef(Arg).split('=');
145+
Opts.DebugPrefixMap.insert(
146+
{std::string(Split.first), std::string(Split.second)});
147+
}
142148

143149
// Frontend Options
144150
if (Args.hasArg(OPT_INPUT)) {
@@ -154,8 +160,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
154160
}
155161
}
156162
Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
157-
Opts.OutputPath = Args.getLastArgValue(OPT_o);
158-
Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output);
163+
Opts.OutputPath = std::string(Args.getLastArgValue(OPT_o));
164+
Opts.SplitDwarfOutput =
165+
std::string(Args.getLastArgValue(OPT_split_dwarf_output));
159166
if (Arg *A = Args.getLastArg(OPT_filetype)) {
160167
StringRef Name = A->getValue();
161168
unsigned OutputType = StringSwitch<unsigned>(Name)
@@ -183,8 +190,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
183190
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
184191
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
185192
Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
186-
Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
187-
Opts.TargetABI = Args.getLastArgValue(OPT_target_abi);
193+
Opts.RelocationModel =
194+
std::string(Args.getLastArgValue(OPT_mrelocation_model, "pic"));
195+
Opts.TargetABI = std::string(Args.getLastArgValue(OPT_target_abi));
188196
Opts.IncrementalLinkerCompatible =
189197
Args.hasArg(OPT_mincremental_linker_compatible);
190198
Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
@@ -314,12 +322,7 @@ bool ExecuteAssembler(AssemblerInvocation &Opts, DiagnosticsEngine &Diags) {
314322
SrcMgr.getMemoryBuffer(BufferIndex)->getBuffer());
315323

316324
// Build up the feature string from the target feature list.
317-
std::string FS;
318-
if (!Opts.Features.empty()) {
319-
FS = Opts.Features[0];
320-
for (unsigned i = 1, e = Opts.Features.size(); i != e; ++i)
321-
FS += "," + Opts.Features[i];
322-
}
325+
std::string FS = llvm::join(Opts.Features, ",");
323326

324327
std::unique_ptr<MCStreamer> Str;
325328

@@ -383,7 +386,7 @@ bool ExecuteAssembler(AssemblerInvocation &Opts, DiagnosticsEngine &Diags) {
383386
MCSection *AsmLabel = Ctx.getMachOSection(
384387
"__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
385388
Str.get()->SwitchSection(AsmLabel);
386-
Str.get()->EmitZeros(1);
389+
Str.get()->emitZeros(1);
387390
}
388391

389392
// Assembly to object compilation should leverage assembly info.

builder/clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <clang/FrontendTool/Utils.h>
1212
#include <llvm/ADT/IntrusiveRefCntPtr.h>
1313
#include <llvm/Option/Option.h>
14+
#include <llvm/Support/Host.h>
1415

1516
using namespace llvm;
1617
using namespace clang;

0 commit comments

Comments
 (0)