aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/llvm.go
blob: 6a9532d7a0fce97f30ff83d74498d3465f8b408b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
package rosa

import (
	"runtime"
	"slices"
	"strconv"
	"strings"
	"sync"

	"hakurei.app/internal/pkg"
)

// llvmAttr holds the attributes that will be applied to a new [pkg.Artifact]
// containing a LLVM variant.
type llvmAttr struct {
	// Passed through to PackageAttr.Flag.
	flags int

	// Concatenated with default environment for PackageAttr.Env.
	env []string
	// Concatenated with generated entries for CMakeHelper.Cache.
	cmake [][2]string
	// Override CMakeHelper.Append.
	append []string
	// Passed through to PackageAttr.NonStage0.
	nonStage0 []pkg.Artifact
	// Passed through to PackageAttr.Paths.
	paths []pkg.ExecPath
	// Concatenated with default fixup for CMakeHelper.Script.
	script string

	// Patch name and body pairs.
	patches [][2]string
}

const (
	llvmProjectClang = 1 << iota
	llvmProjectLld

	llvmProjectAll = 1<<iota - 1

	llvmRuntimeCompilerRT = 1 << iota
	llvmRuntimeLibunwind
	llvmRuntimeLibc
	llvmRuntimeLibcxx
	llvmRuntimeLibcxxABI

	llvmAll        = 1<<iota - 1
	llvmRuntimeAll = llvmAll - (2 * llvmProjectAll) - 1
)

// llvmFlagName resolves a llvmAttr.flags project or runtime flag to its name.
func llvmFlagName(flag int) string {
	switch flag {
	case llvmProjectClang:
		return "clang"
	case llvmProjectLld:
		return "lld"

	case llvmRuntimeCompilerRT:
		return "compiler-rt"
	case llvmRuntimeLibunwind:
		return "libunwind"
	case llvmRuntimeLibc:
		return "libc"
	case llvmRuntimeLibcxx:
		return "libcxx"
	case llvmRuntimeLibcxxABI:
		return "libcxxabi"

	default:
		panic("invalid flag " + strconv.Itoa(flag))
	}
}

const (
	llvmVersionMajor = "22"
	llvmVersion      = llvmVersionMajor + ".1.0"
)

// newLLVMVariant returns a [pkg.Artifact] containing a LLVM variant.
func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
	const checksum = "-_Tu5Lt8xkWoxm2VDVV7crh0WqZQbbblN3fYamMdPTDSy_54FAkD2ii7afSymPVV"

	if attr == nil {
		panic("LLVM attr must be non-nil")
	}

	var projects, runtimes []string
	for i := 1; i < llvmProjectAll; i <<= 1 {
		if attr.flags&i != 0 {
			projects = append(projects, llvmFlagName(i))
		}
	}
	for i := (llvmProjectAll + 1) << 1; i < llvmRuntimeAll; i <<= 1 {
		if attr.flags&i != 0 {
			runtimes = append(runtimes, llvmFlagName(i))
		}
	}

	var script string

	cache := [][2]string{
		{"CMAKE_BUILD_TYPE", "Release"},

		{"LLVM_HOST_TRIPLE", `"${ROSA_TRIPLE}"`},
		{"LLVM_DEFAULT_TARGET_TRIPLE", `"${ROSA_TRIPLE}"`},
	}
	if len(projects) > 0 {
		cache = append(cache,
			[2]string{"LLVM_ENABLE_PROJECTS", `"${ROSA_LLVM_PROJECTS}"`})
	}
	if len(runtimes) > 0 {
		cache = append(cache,
			[2]string{"LLVM_ENABLE_RUNTIMES", `"${ROSA_LLVM_RUNTIMES}"`})
	}

	cmakeAppend := []string{"llvm"}
	if attr.append != nil {
		cmakeAppend = attr.append
	} else {
		cache = append(cache,
			[2]string{"LLVM_ENABLE_LIBCXX", "ON"},
			[2]string{"LLVM_USE_LINKER", "lld"},

			[2]string{"LLVM_INSTALL_BINUTILS_SYMLINKS", "ON"},
			[2]string{"LLVM_INSTALL_CCTOOLS_SYMLINKS", "ON"},
		)
	}

	if attr.flags&llvmProjectClang != 0 {
		cache = append(cache,
			[2]string{"CLANG_DEFAULT_LINKER", "lld"},
			[2]string{"CLANG_DEFAULT_CXX_STDLIB", "libc++"},
			[2]string{"CLANG_DEFAULT_RTLIB", "compiler-rt"},
			[2]string{"CLANG_DEFAULT_UNWINDLIB", "libunwind"},
		)
	}
	if attr.flags&llvmProjectLld != 0 {
		script += `
ln -s ld.lld /work/system/bin/ld
`
	}
	if attr.flags&llvmRuntimeCompilerRT != 0 {
		if attr.append == nil {
			cache = append(cache,
				[2]string{"COMPILER_RT_USE_LLVM_UNWINDER", "ON"})
		}
	}
	if attr.flags&llvmRuntimeLibunwind != 0 {
		cache = append(cache,
			[2]string{"LIBUNWIND_USE_COMPILER_RT", "ON"})
	}
	if attr.flags&llvmRuntimeLibcxx != 0 {
		cache = append(cache,
			[2]string{"LIBCXX_HAS_MUSL_LIBC", "ON"},
			[2]string{"LIBCXX_USE_COMPILER_RT", "ON"},
		)
	}
	if attr.flags&llvmRuntimeLibcxxABI != 0 {
		cache = append(cache,
			[2]string{"LIBCXXABI_USE_COMPILER_RT", "ON"},
			[2]string{"LIBCXXABI_USE_LLVM_UNWINDER", "ON"},
		)
	}

	return t.NewPackage("llvm", llvmVersion, pkg.NewHTTPGetTar(
		nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+
			"llvmorg-"+llvmVersion+".tar.gz",
		mustDecode(checksum),
		pkg.TarGzip,
	), &PackageAttr{
		Patches:   attr.patches,
		NonStage0: attr.nonStage0,

		Env: slices.Concat([]string{
			"ROSA_LLVM_PROJECTS=" + strings.Join(projects, ";"),
			"ROSA_LLVM_RUNTIMES=" + strings.Join(runtimes, ";"),
		}, attr.env),

		Paths: attr.paths,
		Flag:  TExclusive,
	}, &CMakeHelper{
		Variant: variant,

		Cache:  slices.Concat(cache, attr.cmake),
		Append: cmakeAppend,
		Script: script + attr.script,
	},
		Libffi,
		Python,
		Perl,
		Diffutils,
		Bash,
		Gawk,
		Coreutils,
		Findutils,

		KernelHeaders,
	)
}

// newLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
	var target string
	switch runtime.GOARCH {
	case "386", "amd64":
		target = "X86"
	case "arm64":
		target = "AArch64"

	default:
		panic("unsupported target " + runtime.GOARCH)
	}

	minimalDeps := [][2]string{
		{"LLVM_ENABLE_ZLIB", "OFF"},
		{"LLVM_ENABLE_ZSTD", "OFF"},
		{"LLVM_ENABLE_LIBXML2", "OFF"},
	}

	muslHeaders, _ := t.newMusl(true, []string{
		"CC=clang",
	})

	compilerRT = t.newLLVMVariant("compiler-rt", &llvmAttr{
		env: stage0ExclConcat(t, []string{},
			"LDFLAGS="+earlyLDFLAGS(false),
		),
		cmake: [][2]string{
			// libc++ not yet available
			{"CMAKE_CXX_COMPILER_TARGET", ""},

			{"COMPILER_RT_BUILD_BUILTINS", "ON"},
			{"COMPILER_RT_DEFAULT_TARGET_ONLY", "ON"},
			{"COMPILER_RT_SANITIZERS_TO_BUILD", "asan"},
			{"LLVM_ENABLE_PER_TARGET_RUNTIME_DIR", "ON"},

			// does not work without libunwind
			{"COMPILER_RT_BUILD_CTX_PROFILE", "OFF"},
			{"COMPILER_RT_BUILD_LIBFUZZER", "OFF"},
			{"COMPILER_RT_BUILD_MEMPROF", "OFF"},
			{"COMPILER_RT_BUILD_PROFILE", "OFF"},
			{"COMPILER_RT_BUILD_XRAY", "OFF"},
		},
		append: []string{"compiler-rt"},
		nonStage0: []pkg.Artifact{
			muslHeaders,
		},
		script: `
mkdir -p "/work/system/lib/clang/` + llvmVersionMajor + `/lib/"
ln -s \
	"../../../${ROSA_TRIPLE}" \
	"/work/system/lib/clang/` + llvmVersionMajor + `/lib/"

ln -s \
	"clang_rt.crtbegin-` + linuxArch() + `.o" \
	"/work/system/lib/${ROSA_TRIPLE}/crtbeginS.o"
ln -s \
	"clang_rt.crtend-` + linuxArch() + `.o" \
	"/work/system/lib/${ROSA_TRIPLE}/crtendS.o"
`,
	})

	musl, _ = t.newMusl(false, stage0ExclConcat(t, []string{
		"CC=clang",
		"LIBCC=/system/lib/clang/" + llvmVersionMajor + "/lib/" +
			triplet() + "/libclang_rt.builtins.a",
		"AR=ar",
		"RANLIB=ranlib",
	},
		"LDFLAGS="+earlyLDFLAGS(false),
	), compilerRT)

	runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
		env: stage0ExclConcat(t, []string{},
			"LDFLAGS="+earlyLDFLAGS(false),
		),
		flags: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI,
		cmake: slices.Concat([][2]string{
			// libc++ not yet available
			{"CMAKE_CXX_COMPILER_WORKS", "ON"},

			{"LIBCXX_HAS_ATOMIC_LIB", "OFF"},
			{"LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL", "OFF"},
		}, minimalDeps),
		append: []string{"runtimes"},
		nonStage0: []pkg.Artifact{
			compilerRT,
			musl,
		},
	})

	clang = t.newLLVMVariant("clang", &llvmAttr{
		flags: llvmProjectClang | llvmProjectLld,
		env: stage0ExclConcat(t, []string{},
			"CFLAGS="+earlyCFLAGS,
			"CXXFLAGS="+earlyCXXFLAGS(),
			"LDFLAGS="+earlyLDFLAGS(false),
		),
		cmake: slices.Concat([][2]string{
			{"LLVM_TARGETS_TO_BUILD", target},
			{"CMAKE_CROSSCOMPILING", "OFF"},
			{"CXX_SUPPORTS_CUSTOM_LINKER", "ON"},
		}, minimalDeps),
		nonStage0: []pkg.Artifact{
			musl,
			compilerRT,
			runtimes,
		},
		script: `
ln -s clang /work/system/bin/cc
ln -s clang++ /work/system/bin/c++

ninja check-all
`,

		patches: [][2]string{
			{"add-rosa-vendor", `diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 9c83abeeb3b1..5acfe5836a23 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -190,6 +190,7 @@ public:
 
     Apple,
     PC,
+    Rosa,
     SCEI,
     Freescale,
     IBM,
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index a4f9dd42c0fe..cb5a12387034 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -279,6 +279,7 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
   case NVIDIA: return "nvidia";
   case OpenEmbedded: return "oe";
   case PC: return "pc";
+  case Rosa: return "rosa";
   case SCEI: return "scei";
   case SUSE: return "suse";
   case Meta:
@@ -689,6 +690,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
   return StringSwitch<Triple::VendorType>(VendorName)
       .Case("apple", Triple::Apple)
       .Case("pc", Triple::PC)
+      .Case("rosa", Triple::Rosa)
       .Case("scei", Triple::SCEI)
       .Case("sie", Triple::SCEI)
       .Case("fsl", Triple::Freescale)
`},

			{"xfail-broken-tests", `diff --git a/clang/test/Modules/timestamps.c b/clang/test/Modules/timestamps.c
index 50fdce630255..4b4465a75617 100644
--- a/clang/test/Modules/timestamps.c
+++ b/clang/test/Modules/timestamps.c
@@ -1,3 +1,5 @@
+// XFAIL: target={{.*-rosa-linux-musl}}
+
 /// Verify timestamps that gets embedded in the module
 #include <c-header.h>
 
`},

			{"path-system-include", `diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 8ac8d4eb9181..e46b04a898ca 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -671,6 +671,12 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
     addExternCSystemInclude(
         DriverArgs, CC1Args,
         concat(SysRoot, "/usr/include", MultiarchIncludeDir));
+  if (!MultiarchIncludeDir.empty() &&
+      D.getVFS().exists(concat(SysRoot, "/system/include", MultiarchIncludeDir)))
+    addExternCSystemInclude(
+        DriverArgs, CC1Args,
+        concat(SysRoot, "/system/include", MultiarchIncludeDir));
+
 
   if (getTriple().getOS() == llvm::Triple::RTEMS)
     return;
@@ -681,6 +687,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include"));
 
   addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include"));
+  addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/system/include"));
 
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
     addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
`},

			{"path-system-libraries", `diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 8ac8d4eb9181..f4d1347ab64d 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -282,6 +282,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
   const bool IsHexagon = Arch == llvm::Triple::hexagon;
   const bool IsRISCV = Triple.isRISCV();
   const bool IsCSKY = Triple.isCSKY();
+  const bool IsRosa = Triple.getVendor() == llvm::Triple::Rosa;
 
   if (IsCSKY && !SelectedMultilibs.empty())
     SysRoot = SysRoot + SelectedMultilibs.back().osSuffix();
@@ -318,12 +319,23 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  if (IsRosa) {
+    ExtraOpts.push_back("-rpath");
+    ExtraOpts.push_back("/system/lib");
+    ExtraOpts.push_back("-rpath");
+    ExtraOpts.push_back(concat("/system/lib", MultiarchTriple));
+  }
+
   // mips32: Debian multilib, we use /libo32, while in other case, /lib is
   // used. We need add both libo32 and /lib.
   if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
     Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths);
-    addPathIfExists(D, concat(SysRoot, "/libo32"), Paths);
-    addPathIfExists(D, concat(SysRoot, "/usr/libo32"), Paths);
+    if (!IsRosa) {
+      addPathIfExists(D, concat(SysRoot, "/libo32"), Paths);
+      addPathIfExists(D, concat(SysRoot, "/usr/libo32"), Paths);
+    } else {
+      addPathIfExists(D, concat(SysRoot, "/system/libo32"), Paths);
+    }
   }
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
@@ -341,18 +353,30 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
         Paths);
   }
 
-  addPathIfExists(D, concat(SysRoot, "/usr/lib", MultiarchTriple), Paths);
-  addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
+  if (!IsRosa) {
+    addPathIfExists(D, concat(SysRoot, "/usr/lib", MultiarchTriple), Paths);
+    addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
+  } else {
+    addPathIfExists(D, concat(SysRoot, "/system/lib", MultiarchTriple), Paths);
+    addPathIfExists(D, concat(SysRoot, "/system", OSLibDir), Paths);
+  }
   if (IsRISCV) {
     StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
     addPathIfExists(D, concat(SysRoot, "/", OSLibDir, ABIName), Paths);
-    addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir, ABIName), Paths);
+    if (!IsRosa)
+      addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir, ABIName), Paths);
+    else
+      addPathIfExists(D, concat(SysRoot, "/system", OSLibDir, ABIName), Paths);
   }
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
-  addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
+  if (!IsRosa) {
+    addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
+    addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
+  } else {
+    addPathIfExists(D, concat(SysRoot, "/system/lib"), Paths);
+  }
 }
 
 ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
@@ -457,6 +481,9 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
     return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
   }
   if (Triple.isMusl()) {
+    if (Triple.getVendor() == llvm::Triple::Rosa)
+      return "/system/bin/linker";
+
     std::string ArchName;
     bool IsArm = false;
 
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
index 64324a3f8b01..15ce70b68217 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -515,7 +515,7 @@ bool Options::processFrontendOptions(InputArgList &Args) {
     FEOpts.FwkPaths = std::move(FrameworkPaths);
 
   // Add default framework/library paths.
-  PathSeq DefaultLibraryPaths = {"/usr/lib", "/usr/local/lib"};
+  PathSeq DefaultLibraryPaths = {"/usr/lib", "/system/lib", "/usr/local/lib"};
   PathSeq DefaultFrameworkPaths = {"/Library/Frameworks",
                                    "/System/Library/Frameworks"};
 
`},
		},
	})

	return
}
func init() {
	artifactsM[LLVMCompilerRT] = Metadata{
		f: func(t Toolchain) (pkg.Artifact, string) {
			_, compilerRT, _, _ := t.newLLVM()
			return compilerRT, llvmVersion
		},

		Name:        "llvm-compiler-rt",
		Description: "LLVM runtime: compiler-rt",
		Website:     "https://llvm.org/",
	}

	artifactsM[LLVMRuntimes] = Metadata{
		f: func(t Toolchain) (pkg.Artifact, string) {
			_, _, runtimes, _ := t.newLLVM()
			return runtimes, llvmVersion
		},

		Name:        "llvm-runtimes",
		Description: "LLVM runtimes: libunwind, libcxx, libcxxabi",
		Website:     "https://llvm.org/",
	}

	artifactsM[LLVMClang] = Metadata{
		f: func(t Toolchain) (pkg.Artifact, string) {
			_, _, _, clang := t.newLLVM()
			return clang, llvmVersion
		},

		Name:        "clang",
		Description: `an "LLVM native" C/C++/Objective-C compiler`,
		Website:     "https://llvm.org/",

		ID: 1830,
	}
}

var (
	// llvm stores the result of Toolchain.newLLVM.
	llvm [_toolchainEnd][4]pkg.Artifact
	// llvmOnce is for lazy initialisation of llvm.
	llvmOnce [_toolchainEnd]sync.Once
)

// NewLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) NewLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
	llvmOnce[t].Do(func() {
		llvm[t][0], llvm[t][1], llvm[t][2], llvm[t][3] = t.newLLVM()
	})
	return llvm[t][0], llvm[t][1], llvm[t][2], llvm[t][3]
}