xbintsc 0.3.14 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +22 -22
  2. package/README.zh-CN.md +20 -19
  3. package/bin/xbintsc.js +1 -2
  4. package/dist/src/cli/main.js +4 -1
  5. package/dist/src/cli/main.js.map +1 -1
  6. package/dist/src/codegen/generator/tables.d.ts +5 -6
  7. package/dist/src/codegen/generator/tables.js +5 -6
  8. package/dist/src/codegen/generator/tables.js.map +1 -1
  9. package/dist/src/driver/index.d.ts +1 -2
  10. package/dist/src/driver/index.js +1 -2
  11. package/dist/src/driver/index.js.map +1 -1
  12. package/dist/src/driver/paths.d.ts +0 -9
  13. package/dist/src/driver/paths.js +0 -31
  14. package/dist/src/driver/paths.js.map +1 -1
  15. package/dist/src/driver/toolchain-provider.d.ts +10 -10
  16. package/dist/src/driver/toolchain-provider.js +9 -38
  17. package/dist/src/driver/toolchain-provider.js.map +1 -1
  18. package/dist/src/driver/toolchain.js +8 -2
  19. package/dist/src/driver/toolchain.js.map +1 -1
  20. package/dist/src/extensions/native.d.ts +2 -3
  21. package/dist/src/extensions/native.js +2 -3
  22. package/dist/src/extensions/native.js.map +1 -1
  23. package/dist/tests/driver/paths.test.js +1 -9
  24. package/dist/tests/driver/paths.test.js.map +1 -1
  25. package/dist/tests/driver/toolchain-provider.test.js +12 -79
  26. package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
  27. package/dist/tests/e2e/native-extensions.test.d.ts +4 -5
  28. package/dist/tests/e2e/native-extensions.test.js +6 -7
  29. package/dist/tests/e2e/native-extensions.test.js.map +1 -1
  30. package/package.json +1 -2
  31. package/runtime/ext_node/fs/meta_ops.c +3 -3
  32. package/runtime/rt.h +3 -4
  33. package/runtime/rt_internal.h +10 -23
  34. package/runtime/xt_ext.h +0 -1
  35. package/runtime/xt_io.c +3 -3
  36. package/runtime/xt_stdlib2/helpers.inc +2 -4
  37. package/scripts/build-runtime.ts +7 -8
  38. package/scripts/coverage-runtime.ts +4 -4
  39. package/scripts/package-release.ts +12 -84
  40. package/src/cli/main.ts +4 -1
  41. package/src/codegen/generator/tables.ts +5 -6
  42. package/src/driver/index.ts +1 -9
  43. package/src/driver/paths.ts +0 -31
  44. package/src/driver/toolchain-provider.ts +12 -45
  45. package/src/driver/toolchain.ts +7 -2
  46. package/src/extensions/native.ts +2 -3
  47. package/dist/src/driver/toolchain-download.d.ts +0 -50
  48. package/dist/src/driver/toolchain-download.js +0 -102
  49. package/dist/src/driver/toolchain-download.js.map +0 -1
  50. package/dist/tests/driver/toolchain-download.test.d.ts +0 -1
  51. package/dist/tests/driver/toolchain-download.test.js +0 -53
  52. package/dist/tests/driver/toolchain-download.test.js.map +0 -1
  53. package/scripts/fetch-toolchain.ts +0 -101
  54. package/src/driver/toolchain-download.ts +0 -135
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Assemble a self-contained release archive for the current platform:
3
+ * Assemble a release archive for the current platform:
4
4
  *
5
5
  * dist/release/xbintsc-<version>-<os>-<arch>.tar.gz (or .tar.zst)
6
6
  * dist/release/xbintsc-<version>-<os>-<arch>.tar.gz.sha256
@@ -10,23 +10,24 @@
10
10
  *
11
11
  * The unpacked staging tree is built under `build/release-stage/`, never under
12
12
  * `dist/release/`, so an upload glob over `dist/release/*` cannot accidentally
13
- * ship the (multi-GB) tree alongside the archive.
13
+ * ship the (large) tree alongside the archive.
14
+ *
15
+ * xbintsc does not bundle a compiler: the archive holds only the self-hosted
16
+ * binary and the C runtime sources plus prebuilt archives. Users provide the
17
+ * toolchain themselves (see `doc/requirements.md`).
14
18
  *
15
19
  * Layout inside the archive:
16
20
  *
17
21
  * xbintsc-<os>-<arch>/
18
22
  * bin/xbintsc[.exe] the self-hosted compiler
19
23
  * runtime/ C runtime sources + prebuilt runtime/lib/<slug>
20
- * vendor/<slug>/ the bundled clang+lld toolchain (Linux/Windows)
21
24
  * README.md
22
25
  *
23
- * The compiler locates `runtime/` and `vendor/` relative to its own executable
24
- * (see `findRuntimeDir`/`findVendorDir`), so this tree runs with no system
25
- * toolchain installed.
26
+ * The compiler locates `runtime/` relative to its own executable (see
27
+ * `findRuntimeDir`), so this tree runs without any bundled toolchain.
26
28
  *
27
29
  * Inputs:
28
30
  * - the self-hosted binary staged at `dist/xbintsc[.exe]` (CI copies it there)
29
- * - `vendor/<slug>/`, fetched by `scripts/fetch-toolchain.ts`
30
31
  * - `runtime/lib/<slug>/`, built by `scripts/build-runtime.ts`
31
32
  */
32
33
 
@@ -37,9 +38,7 @@ import {
37
38
  chmodSync,
38
39
  existsSync,
39
40
  mkdirSync,
40
- readdirSync,
41
41
  readFileSync,
42
- realpathSync,
43
42
  rmSync,
44
43
  statSync,
45
44
  writeFileSync,
@@ -49,14 +48,12 @@ import { basename, dirname, join, resolve } from "node:path";
49
48
  import { fileURLToPath } from "node:url";
50
49
  import {
51
50
  findRuntimeDir,
52
- platformSlug,
53
51
  releaseArchiveBase,
54
52
  releaseArchiveExtension,
55
53
  releaseArchiveFileName,
56
54
  } from "../src/driver/paths.js";
57
55
 
58
56
  const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
59
- const slug = platformSlug();
60
57
  const base = releaseArchiveBase();
61
58
  const version = (
62
59
  JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as { version: string }
@@ -77,55 +74,6 @@ function firstExisting(candidates: readonly string[]): string | undefined {
77
74
  return undefined;
78
75
  }
79
76
 
80
- /**
81
- * Copy only the parts of the fetched toolchain that xbintsc actually runs.
82
- *
83
- * The official LLVM release unpacks to ~7 GB: every MLIR/Flang/lldb tool, the
84
- * static archives and the full C++ headers. The compiler only shells out to the
85
- * clang driver, the lld linker and llvm-ar, and clang additionally needs its own
86
- * resource directory (`lib/clang/<version>`, the builtin headers and
87
- * compiler-rt). Copying just those keeps the archive ~100x smaller.
88
- */
89
- function stageToolchain(vendor: string, dest: string): void {
90
- const exe = process.platform === "win32" ? ".exe" : "";
91
- mkdirSync(join(dest, "bin"), { recursive: true });
92
-
93
- const real = (...candidates: readonly string[]): string | undefined => {
94
- const found = firstExisting(candidates.map((candidate) => join(vendor, candidate)));
95
- return found ? realpathSync(found) : undefined;
96
- };
97
- const copyAs = (source: string | undefined, name: string): void => {
98
- if (!source) return;
99
- const target = join(dest, "bin", name);
100
- copyFileSync(source, target);
101
- if (process.platform !== "win32") chmodSync(target, 0o755);
102
- };
103
-
104
- // In the official release `clang`/`ld.lld` are symlinks into the bin/ dir;
105
- // copy the resolved targets under the names the toolchain provider (and
106
- // clang's `-fuse-ld=lld`) expect next to `bin/clang`.
107
- copyAs(real(`bin/clang${exe}`, `bin/clang-18${exe}`), `clang${exe}`);
108
- copyAs(real(`bin/ld.lld${exe}`, `bin/lld${exe}`), `ld.lld${exe}`);
109
- copyAs(real(`bin/llvm-ar${exe}`, "bin/llvm-ar"), `llvm-ar${exe}`);
110
-
111
- // clang's resource directory: builtin headers + compiler-rt archives.
112
- const resourceDir = join(vendor, "lib", "clang");
113
- if (existsSync(resourceDir)) {
114
- cpSync(resourceDir, join(dest, "lib", "clang"), { recursive: true });
115
- }
116
-
117
- // Shared libraries the fetch placed next to the toolchain (on Linux that is
118
- // the legacy `libtinfo.so.5` the official build still links).
119
- const libDir = join(vendor, "lib");
120
- if (existsSync(libDir)) {
121
- for (const entry of readdirSync(libDir, { withFileTypes: true })) {
122
- if (/^(.*\.so(\.\d+)*|.*\.dylib|.*\.dll)$/.test(entry.name)) {
123
- cpSync(join(libDir, entry.name), join(dest, "lib", entry.name), { recursive: true });
124
- }
125
- }
126
- }
127
- }
128
-
129
77
  const distDir = join(root, "dist");
130
78
  const binary = firstExisting([
131
79
  join(distDir, `xbintsc${exeSuffix}`),
@@ -138,7 +86,7 @@ if (!binary) {
138
86
 
139
87
  // Archives go to `dist/release/`; the unpacked staging tree goes to
140
88
  // `build/release-stage/` so the upload glob over `dist/release/*` cannot pick up
141
- // the raw tree (which would ship the toolchain twice, and uncompressed).
89
+ // the raw tree.
142
90
  const releaseRoot = join(distDir, "release");
143
91
  const stageRoot = join(root, "build", "release-stage");
144
92
  const stage = join(stageRoot, base);
@@ -156,33 +104,13 @@ console.log(`xbintsc: packaged binary ${basename(binary)} (${statSync(binary).si
156
104
  cpSync(findRuntimeDir(), join(stage, "runtime"), { recursive: true });
157
105
  console.log("xbintsc: packaged runtime/");
158
106
 
159
- // 3. The bundled toolchain, when one was fetched for this platform.
160
- const vendor = join(root, "vendor", slug);
161
- if (existsSync(join(vendor, "bin"))) {
162
- if (process.platform === "win32") {
163
- // llvm-mingw spreads its MinGW-w64 CRT/import libraries across the tree, so
164
- // bundling it whole is the safe default there for now.
165
- cpSync(vendor, join(stage, "vendor", slug), { recursive: true });
166
- } else {
167
- stageToolchain(vendor, join(stage, "vendor", slug));
168
- }
169
- console.log(`xbintsc: packaged vendor/${slug}/`);
170
- } else if (process.platform === "linux" || process.platform === "win32") {
171
- console.warn(
172
- `xbintsc: warning: no vendor/${slug}/ found; the release will rely on a system toolchain. ` +
173
- "Run `npm run fetch-toolchain` first for a self-contained archive.",
174
- );
175
- } else {
176
- console.log(`xbintsc: no bundled toolchain for ${slug}; relying on the system SDK (macOS)`);
177
- }
178
-
179
- // 4. Human-facing notes.
107
+ // 3. Human-facing notes.
180
108
  for (const name of ["README.md", "LICENSE"]) {
181
109
  const source = join(root, name);
182
110
  if (existsSync(source)) copyFileSync(source, join(stage, name));
183
111
  }
184
112
 
185
- // 5. Archive it. Prefer zstd when available, otherwise gzip.
113
+ // 4. Archive it. Prefer zstd when available, otherwise gzip.
186
114
  const hasZstd = !spawnSync("zstd", ["--version"], { stdio: "ignore" }).error;
187
115
  const extension = releaseArchiveExtension(hasZstd);
188
116
  const archive = join(releaseRoot, `${archiveBase}${extension}`);
@@ -192,7 +120,7 @@ const tar = spawnSync("tar", tarArgs, { stdio: "inherit" });
192
120
  if (tar.error) fail(`failed to run tar: ${tar.error.message}`);
193
121
  if (tar.status !== 0) fail(`tar exited with ${tar.status}`);
194
122
 
195
- // 6. Checksum, so users can verify the download.
123
+ // 5. Checksum, so users can verify the download.
196
124
  const digest = createHash("sha256").update(readFileSync(archive)).digest("hex");
197
125
  writeFileSync(`${archive}.sha256`, `${digest} ${basename(archive)}\n`);
198
126
 
package/src/cli/main.ts CHANGED
@@ -172,7 +172,10 @@ function doctor(io: CliIo): number {
172
172
  io.stdout(`toolchain : ${toolchain.clang} (${toolchain.source})\n`);
173
173
  io.stdout(`compiler : ${firstLine(version) || "unknown"}\n`);
174
174
  } catch {
175
- io.stdout("toolchain : not found (install the Xcode Command Line Tools or set xbintsc_CLANG)\n");
175
+ io.stdout("toolchain : not found\n");
176
+ io.stdout(" install one of: Xcode Command Line Tools (`xcode-select --install`) on macOS,\n");
177
+ io.stdout(" clang+lld (apt/dnf/pacman) on Linux, or LLVM + Visual Studio C++ build tools on Windows,\n");
178
+ io.stdout(" then re-run; or set xbintsc_CLANG to a clang binary. See doc/requirements.md.\n");
176
179
  }
177
180
 
178
181
  try {
@@ -12,12 +12,11 @@ import {
12
12
  /**
13
13
  * True when a `try` frame must be saved with `_setjmpex` rather than `_setjmp`.
14
14
  *
15
- * 64-bit Windows on ARM has no `_setjmp`: both the UCRT and MinGW-w64 declare
16
- * `setjmp` as `_setjmpex(buf, sponentry)` there, so the linker expects
17
- * `_setjmpex` (with the caller's stack pointer at entry, `llvm.sponentry`,
18
- * instead of its frame pointer). clang lowers a C `setjmp` on this target to
19
- * exactly that pair. Checked at code-generation time because xbintsc builds for
20
- * its own host.
15
+ * 64-bit Windows on ARM has no `_setjmp`: the UCRT declares `setjmp` as
16
+ * `_setjmpex(buf, sponentry)` there, so the linker expects `_setjmpex` (with the
17
+ * caller's stack pointer at entry, `llvm.sponentry`, instead of its frame
18
+ * pointer). clang lowers a C `setjmp` on this target to exactly that pair.
19
+ * Checked at code-generation time because xbintsc builds for its own host.
21
20
  */
22
21
  export function requiresSetjmpex(platform: string, arch: string): boolean {
23
22
  return platform === "win32" && arch === "arm64";
@@ -1,14 +1,6 @@
1
1
  export { build, compileString, COMPILER_VERSION, type BuildOptions, type BuildResult, type EmitKind } from "./compiler.js";
2
2
  export { BuildCache, hashParts, hashString } from "./cache.js";
3
- export { findRuntimeDir, findPackageRoot, findVendorDir, vendorRootDir, platformSlug, releaseArchiveBase, releaseArchiveFileName, releaseArchiveExtension } from "./paths.js";
4
- export {
5
- toolchainDownload,
6
- toolchainSupportLibraries,
7
- LLVM_VERSION,
8
- LLVM_MINGW_VERSION,
9
- type ToolchainDownload,
10
- type SupportLibrary,
11
- } from "./toolchain-download.js";
3
+ export { findRuntimeDir, platformSlug, releaseArchiveBase, releaseArchiveFileName, releaseArchiveExtension } from "./paths.js";
12
4
  export { findRuntimeLibrary, runtimeLibDir } from "./runtime-lib.js";
13
5
  export {
14
6
  findClang,
@@ -22,15 +22,6 @@ export function findRuntimeDir(): string {
22
22
  throw new Error("Unable to locate the xbintsc runtime directory (missing runtime/rt.h)");
23
23
  }
24
24
 
25
- export function findPackageRoot(): string {
26
- return resolve(findRuntimeDir(), "..");
27
- }
28
-
29
- /** `<package>/vendor` — where a bundled toolchain is assembled (may not exist). */
30
- export function vendorRootDir(): string {
31
- return resolve(findPackageRoot(), "vendor");
32
- }
33
-
34
25
  /** Platform-architecture slug, e.g. `darwin-arm64`, `linux-x64`, `win32-x64`. */
35
26
  export function platformSlug(): string {
36
27
  return `${process.platform}-${process.arch}`;
@@ -68,25 +59,3 @@ export function releaseArchiveFileName(
68
59
  export function releaseArchiveExtension(useZstd: boolean): string {
69
60
  return useZstd ? ".tar.zst" : ".tar.gz";
70
61
  }
71
-
72
- /**
73
- * Directory that may hold a toolchain shipped next to the package:
74
- * `<package>/vendor/<os>-<arch>` (or a generic `vendor/`). Undefined when none
75
- * is present, in which case the driver falls back to the system PATH.
76
- */
77
- export function findVendorDir(): string | undefined {
78
- const roots: string[] = [];
79
- try {
80
- roots.push(findPackageRoot());
81
- } catch {
82
- // `runtime/` may be absent (e.g. a bare `emit` install); vendor is optional.
83
- }
84
- roots.push(resolve(here, "../../.."), resolve(here, "../.."), process.cwd());
85
- for (const root of roots) {
86
- const specific = join(root, "vendor", platformSlug());
87
- if (existsSync(specific)) return specific;
88
- const generic = join(root, "vendor");
89
- if (existsSync(generic)) return generic;
90
- }
91
- return undefined;
92
- }
@@ -3,23 +3,23 @@
3
3
  *
4
4
  * xbintsc shells out to a clang-compatible driver for three jobs: lowering LLVM
5
5
  * IR to an object, compiling the C runtime, and linking. This module decides
6
- * *which* driver to use, in a fixed priority order, so a bundled toolchain can
7
- * shadow the system one without touching the driver code:
6
+ * *which* driver to use, in a fixed priority order:
8
7
  *
9
8
  * 1. an explicit `xbintsc_CLANG` / `xbintsc_TOOLCHAIN`
10
- * 2. a toolchain shipped next to the package (`vendor/<os>-<arch>/bin`)
11
- * 3. the system `PATH` (`findClang`)
9
+ * 2. the system `PATH` (`findClang`)
10
+ *
11
+ * xbintsc does not ship a compiler. Every host must provide a clang-compatible
12
+ * toolchain (see `doc/requirements.md`): the Xcode Command Line Tools on macOS,
13
+ * the distribution's clang/lld on Linux, and LLVM plus the Visual Studio C++
14
+ * build tools (the MSVC ABI) on Windows.
12
15
  *
13
16
  * Extra linker arguments (for example `-fuse-ld=lld`) can be supplied through
14
17
  * `xbintsc_LINKER_ARGS`.
15
18
  */
16
19
 
17
- import { existsSync } from "node:fs";
18
- import { join } from "node:path";
19
- import { findVendorDir } from "./paths.js";
20
20
  import { findClang, realRunner, type Runner } from "./toolchain.js";
21
21
 
22
- export type ToolchainSource = "env" | "vendor" | "system";
22
+ export type ToolchainSource = "env" | "system";
23
23
 
24
24
  export interface ResolvedToolchain {
25
25
  /** Path or name of the clang-compatible driver to invoke. */
@@ -28,17 +28,14 @@ export interface ResolvedToolchain {
28
28
  readonly source: ToolchainSource;
29
29
  /** Extra arguments to pass to the link step. */
30
30
  readonly linkerArgs: readonly string[];
31
- /**
32
- * Extra environment for the toolchain subprocesses, merged over the current
33
- * environment. Used to point `LD_LIBRARY_PATH` at bundled shared libraries
34
- * (for example the legacy `libtinfo.so.5` the official Linux build needs).
35
- */
31
+ /** Extra environment for the toolchain subprocesses, merged over the current
32
+ * environment. */
36
33
  readonly env: Record<string, string>;
37
34
  }
38
35
 
39
- function works(runner: Runner, command: string, env?: Record<string, string>): boolean {
36
+ function works(runner: Runner, command: string): boolean {
40
37
  try {
41
- return runner.run(command, ["--version"], env ? { env } : undefined).status === 0;
38
+ return runner.run(command, ["--version"]).status === 0;
42
39
  } catch {
43
40
  return false;
44
41
  }
@@ -50,18 +47,6 @@ function linkerArgs(fallback: readonly string[]): string[] {
50
47
  return [...fallback];
51
48
  }
52
49
 
53
- /**
54
- * Environment overrides for a bundled toolchain. The official Linux build links
55
- * the removed `libtinfo.so.5` soname, so when we ship it under `vendor/lib/` we
56
- * prepend that directory to the dynamic linker search path.
57
- */
58
- function vendorEnv(vendor: string): Record<string, string> {
59
- const libDir = join(vendor, "lib");
60
- if (process.platform !== "linux" || !existsSync(libDir)) return {};
61
- const existing = process.env.LD_LIBRARY_PATH;
62
- return { LD_LIBRARY_PATH: existing ? libDir + ":" + existing : libDir };
63
- }
64
-
65
50
  /** Resolve the toolchain that `build` should use. See the module docblock. */
66
51
  export function resolveToolchain(runner: Runner = realRunner): ResolvedToolchain {
67
52
  const explicit = process.env.xbintsc_CLANG ?? process.env.xbintsc_TOOLCHAIN;
@@ -69,23 +54,5 @@ export function resolveToolchain(runner: Runner = realRunner): ResolvedToolchain
69
54
  return { clang: explicit, source: "env", linkerArgs: linkerArgs([]), env: {} };
70
55
  }
71
56
 
72
- const vendor = findVendorDir();
73
- if (vendor) {
74
- const env = vendorEnv(vendor);
75
- const names = process.platform === "win32" ? ["clang.exe", "clang"] : ["clang"];
76
- for (const name of names) {
77
- const candidate = join(vendor, "bin", name);
78
- if (existsSync(candidate) && works(runner, candidate, env)) {
79
- // A bundled toolchain ships `ld.lld`, so prefer lld over any system linker.
80
- return {
81
- clang: candidate,
82
- source: "vendor",
83
- linkerArgs: linkerArgs(["-fuse-ld=lld"]),
84
- env,
85
- };
86
- }
87
- }
88
- }
89
-
90
57
  return { clang: findClang(runner), source: "system", linkerArgs: linkerArgs([]), env: {} };
91
58
  }
@@ -64,8 +64,13 @@ export function findClang(runner: Runner = realRunner): string {
64
64
  "cc",
65
65
  ].filter((candidate): candidate is string => Boolean(candidate));
66
66
  for (const candidate of candidates) {
67
- const result = runner.run(candidate, ["--version"]);
68
- if (result.status === 0) return candidate;
67
+ let status: number;
68
+ try {
69
+ status = runner.run(candidate, ["--version"]).status;
70
+ } catch {
71
+ continue;
72
+ }
73
+ if (status === 0) return candidate;
69
74
  }
70
75
  throw new ToolchainError("clang --version", 1, "No C compiler found. Set xbintsc_CLANG to a clang binary.");
71
76
  }
@@ -18,9 +18,8 @@
18
18
  * {
19
19
  * "name": "mathx",
20
20
  * "description": "C++ math helpers",
21
- * "objects": ["build/libmathx.a"],
22
- * "linkerFlags": ["-lm"],
23
- * "linkerFlagsByPlatform": { "linux": ["-lstdc++"], "darwin": ["-lc++"] },
21
+ * "objects": ["build/mathx.o"],
22
+ * "linkerFlagsByPlatform": { "linux": ["-lstdc++", "-lm"], "darwin": ["-lc++"], "win32": ["-lmsvcprt"] },
24
23
  * "builtins": { "fastAdd": { "symbol": "mathx_add" } },
25
24
  * "modules": {
26
25
  * "mathx": {
@@ -1,50 +0,0 @@
1
- /**
2
- * Which toolchain xbintsc bundles for each host.
3
- *
4
- * The end goal is that `build` needs no user-installed compiler. Per the
5
- * recorded decisions (see `doc/requirements.md`):
6
- *
7
- * Linux -> the official LLVM release (clang + lld + llvm-ar)
8
- * Windows -> llvm-mingw (clang + lld + the MinGW-w64 sysroot/CRT/import libs)
9
- * macOS -> nothing; the Xcode Command Line Tools are the prerequisite
10
- *
11
- * This module only maps a host to a pinned download; the actual fetch lives in
12
- * `scripts/fetch-toolchain.ts`.
13
- */
14
- /** Pinned LLVM release used for the Linux bundle. */
15
- export declare const LLVM_VERSION = "18.1.8";
16
- /** Pinned llvm-mingw release used for the Windows bundle. */
17
- export declare const LLVM_MINGW_VERSION = "20260908";
18
- export interface ToolchainDownload {
19
- /** Download URL. */
20
- readonly url: string;
21
- /** Suggested local file name for the archive. */
22
- readonly archive: string;
23
- /** Archive type. Both are unpacked with `tar` (bsdtar reads zip). */
24
- readonly kind: "tar.xz" | "zip";
25
- /** Leading path segments to strip while extracting. */
26
- readonly stripComponents: number;
27
- }
28
- /**
29
- * The toolchain to bundle for a host, or undefined when the host's own SDK is
30
- * used instead (macOS: the Xcode Command Line Tools).
31
- */
32
- export declare function toolchainDownload(platform?: string, arch?: string): ToolchainDownload | undefined;
33
- export interface SupportLibrary {
34
- /** Candidate download URLs, tried in order. */
35
- readonly urls: readonly string[];
36
- /** Local file name for the downloaded `.deb`. */
37
- readonly archive: string;
38
- /** Path inside the extracted `.deb` data tree. */
39
- readonly member: string;
40
- /** File name placed in `vendor/<os>-<arch>/lib/`. */
41
- readonly dest: string;
42
- }
43
- /**
44
- * Extra shared libraries the bundled toolchain needs but that are not part of
45
- * the OS C library. The official Linux LLVM build links the legacy
46
- * `libtinfo.so.5` soname, which current distributions no longer ship, so we
47
- * bundle it (from the Ubuntu `libtinfo5` package) into `vendor/<os>-<arch>/lib`
48
- * and point `LD_LIBRARY_PATH` at that directory.
49
- */
50
- export declare function toolchainSupportLibraries(platform?: string, arch?: string): readonly SupportLibrary[];
@@ -1,102 +0,0 @@
1
- /**
2
- * Which toolchain xbintsc bundles for each host.
3
- *
4
- * The end goal is that `build` needs no user-installed compiler. Per the
5
- * recorded decisions (see `doc/requirements.md`):
6
- *
7
- * Linux -> the official LLVM release (clang + lld + llvm-ar)
8
- * Windows -> llvm-mingw (clang + lld + the MinGW-w64 sysroot/CRT/import libs)
9
- * macOS -> nothing; the Xcode Command Line Tools are the prerequisite
10
- *
11
- * This module only maps a host to a pinned download; the actual fetch lives in
12
- * `scripts/fetch-toolchain.ts`.
13
- */
14
- /** Pinned LLVM release used for the Linux bundle. */
15
- export const LLVM_VERSION = "18.1.8";
16
- /** Pinned llvm-mingw release used for the Windows bundle. */
17
- export const LLVM_MINGW_VERSION = "20260908";
18
- /**
19
- * The toolchain to bundle for a host, or undefined when the host's own SDK is
20
- * used instead (macOS: the Xcode Command Line Tools).
21
- */
22
- export function toolchainDownload(platform = process.platform, arch = process.arch) {
23
- if (platform === "linux") {
24
- if (arch === "x64") {
25
- return {
26
- url: `https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-18.04.tar.xz`,
27
- archive: `clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu.tar.xz`,
28
- kind: "tar.xz",
29
- stripComponents: 1,
30
- };
31
- }
32
- if (arch === "arm64") {
33
- return {
34
- url: `https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz`,
35
- archive: `clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz`,
36
- kind: "tar.xz",
37
- stripComponents: 1,
38
- };
39
- }
40
- return undefined;
41
- }
42
- if (platform === "win32" && arch === "x64") {
43
- return {
44
- url: `https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-x86_64.zip`,
45
- archive: `llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-x86_64.zip`,
46
- kind: "zip",
47
- stripComponents: 1,
48
- };
49
- }
50
- if (platform === "win32" && arch === "arm64") {
51
- // The llvm-mingw `aarch64` package is the Windows-on-ARM host build; its
52
- // clang targets aarch64 by default, so a native Windows ARM64 runner gets
53
- // native MinGW-w64 binaries with no MSVC dependency.
54
- return {
55
- url: `https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-aarch64.zip`,
56
- archive: `llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-aarch64.zip`,
57
- kind: "zip",
58
- stripComponents: 1,
59
- };
60
- }
61
- // macOS (and any other host) uses the system SDK; nothing to bundle.
62
- return undefined;
63
- }
64
- /**
65
- * Extra shared libraries the bundled toolchain needs but that are not part of
66
- * the OS C library. The official Linux LLVM build links the legacy
67
- * `libtinfo.so.5` soname, which current distributions no longer ship, so we
68
- * bundle it (from the Ubuntu `libtinfo5` package) into `vendor/<os>-<arch>/lib`
69
- * and point `LD_LIBRARY_PATH` at that directory.
70
- */
71
- export function toolchainSupportLibraries(platform = process.platform, arch = process.arch) {
72
- if (platform === "linux" && arch === "x64") {
73
- return [
74
- {
75
- urls: [
76
- "https://security.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_amd64.deb",
77
- "https://archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_amd64.deb",
78
- ],
79
- archive: "libtinfo5.deb",
80
- member: "lib/x86_64-linux-gnu/libtinfo.so.5.9",
81
- dest: "libtinfo.so.5",
82
- },
83
- ];
84
- }
85
- if (platform === "linux" && arch === "arm64") {
86
- // The aarch64 release build links the same removed `libtinfo.so.5` soname as
87
- // the x86_64 one; arm64 packages live in the Ubuntu ports archive.
88
- return [
89
- {
90
- urls: [
91
- "https://ports.ubuntu.com/ubuntu-ports/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_arm64.deb",
92
- "http://ports.ubuntu.com/ubuntu-ports/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_arm64.deb",
93
- ],
94
- archive: "libtinfo5.deb",
95
- member: "lib/aarch64-linux-gnu/libtinfo.so.5.9",
96
- dest: "libtinfo.so.5",
97
- },
98
- ];
99
- }
100
- return [];
101
- }
102
- //# sourceMappingURL=toolchain-download.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolchain-download.js","sourceRoot":"","sources":["../../../src/driver/toolchain-download.ts"],"names":[],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,EAAE,cAAc,kBAAkB,mBAAmB;YAC5D,IAAI,EAAE,KAAK;YACX,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;IAED,qEAAqE;IACrE,OAAO,SAAS,CAAC;AACnB,CAAC;AAaD;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAmB,OAAO,CAAC,QAAQ,EACnC,OAAe,OAAO,CAAC,IAAI;IAE3B,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO;YACL;gBACE,IAAI,EAAE;oBACJ,iGAAiG;oBACjG,gGAAgG;iBACjG;gBACD,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,sCAAsC;gBAC9C,IAAI,EAAE,eAAe;aACtB;SACF,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7C,6EAA6E;QAC7E,mEAAmE;QACnE,OAAO;YACL;gBACE,IAAI,EAAE;oBACJ,oGAAoG;oBACpG,mGAAmG;iBACpG;gBACD,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,uCAAuC;gBAC/C,IAAI,EAAE,eAAe;aACtB;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { LLVM_MINGW_VERSION, LLVM_VERSION, toolchainDownload, toolchainSupportLibraries, } from "../../src/driver/toolchain-download.js";
3
- describe("toolchainDownload", () => {
4
- it("maps Linux x64 to the pinned LLVM release", () => {
5
- const target = toolchainDownload("linux", "x64");
6
- expect(target?.url).toContain(`llvmorg-${LLVM_VERSION}`);
7
- expect(target?.url).toContain("x86_64-linux-gnu");
8
- expect(target?.kind).toBe("tar.xz");
9
- expect(target?.stripComponents).toBe(1);
10
- });
11
- it("maps Linux arm64 to the pinned LLVM release", () => {
12
- const target = toolchainDownload("linux", "arm64");
13
- expect(target?.url).toContain("aarch64-linux-gnu");
14
- expect(target?.kind).toBe("tar.xz");
15
- });
16
- it("maps Windows x64 to the pinned llvm-mingw release", () => {
17
- const target = toolchainDownload("win32", "x64");
18
- expect(target?.url).toContain(`llvm-mingw-${LLVM_MINGW_VERSION}`);
19
- expect(target?.url).toContain("ucrt-x86_64");
20
- expect(target?.kind).toBe("zip");
21
- expect(target?.stripComponents).toBe(1);
22
- });
23
- it("maps Windows arm64 to the pinned llvm-mingw release", () => {
24
- const target = toolchainDownload("win32", "arm64");
25
- expect(target?.url).toContain(`llvm-mingw-${LLVM_MINGW_VERSION}`);
26
- expect(target?.url).toContain("ucrt-aarch64");
27
- expect(target?.kind).toBe("zip");
28
- expect(target?.stripComponents).toBe(1);
29
- });
30
- it("does not bundle a toolchain on macOS", () => {
31
- expect(toolchainDownload("darwin", "arm64")).toBeUndefined();
32
- expect(toolchainDownload("darwin", "x64")).toBeUndefined();
33
- });
34
- it("bundles libtinfo.so.5 for Linux x64", () => {
35
- const libraries = toolchainSupportLibraries("linux", "x64");
36
- expect(libraries).toHaveLength(1);
37
- expect(libraries[0]?.dest).toBe("libtinfo.so.5");
38
- expect(libraries[0]?.urls.length).toBeGreaterThan(0);
39
- });
40
- it("bundles libtinfo.so.5 for Linux arm64", () => {
41
- const libraries = toolchainSupportLibraries("linux", "arm64");
42
- expect(libraries).toHaveLength(1);
43
- expect(libraries[0]?.dest).toBe("libtinfo.so.5");
44
- expect(libraries[0]?.member).toContain("aarch64-linux-gnu");
45
- expect(libraries[0]?.urls.length).toBeGreaterThan(0);
46
- });
47
- it("requests no support libraries on other hosts", () => {
48
- expect(toolchainSupportLibraries("darwin", "arm64")).toEqual([]);
49
- expect(toolchainSupportLibraries("win32", "x64")).toEqual([]);
50
- expect(toolchainSupportLibraries("win32", "arm64")).toEqual([]);
51
- });
52
- });
53
- //# sourceMappingURL=toolchain-download.test.js.map
@@ -1 +0,0 @@
1
- {"version":3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