Files
scriptc/packages/runtime-darwin-arm64/runtime-pack-matrix.mjs
T
Chris Tate 7329f07d36 Match V8's default locale and calendar in the ICU formatters, and build Intl programs without Zig from the runtime pack
- scr_intl.c resolves the default locale as V8 does: ICU's POSIX locale
  (LC_ALL=C, C.UTF-8, POSIX) becomes en-US, so numbers keep their grouping
  separators, and other defaults round-trip through their BCP 47 tag. The
  number formatter, the date pattern generator, the date formatter and the
  default word segmenter use that locale.
- The date formatter moves the Gregorian calendar's Julian cutover to the
  start of ECMAScript time, so dates before October 1582 print their
  proleptic Gregorian fields, as in Node.
- icu.numFormatDefault, icu.dateLocaleString and icu.dateLocaleTimeString
  are in the may-throw set: a missing ICU data file throws an Error into the
  surrounding catch.
- `x.toLocaleString(undefined)` reads the receiver before the argument runs.
- The linux-x64-gnu runtime pack ships the ICU headers scr_intl.c includes
  beside its ICU archive (manifest `headers`, verified like the other
  artifacts). The native compiler's sanitized build compiles scr_intl.c
  against them and refuses with SC3003 when they are missing or changed.
  The C-source path (sanitized builds) links the pack's ICU archive and
  uses those headers, instead of building ICU with Zig's C++ driver.
- The macOS pack omits scr_intl.c, scr_intl.h declares ScrDyn, and the
  library-mode teachings test uses a locale argument, which still refuses
  with SC2020.

Corpus programs pin the C and C.UTF-8 locales, pre-1582 dates and the
receiver order against Node. intl-missing-data.test.ts covers the throw.
sanitizer.test.ts covers the header lookup.
2026-10-29 02:42:35 -05:00

57 lines
2.3 KiB
JavaScript

import { withWorkerRuntimeVariants } from "../runtime-pack-common/worker-matrix.mjs";
import { withLibraryRuntimeFlavors } from "../runtime-pack-common/library-matrix.mjs";
import {
BASE_RUNTIME_SOURCES,
OPTIONAL_RUNTIME_SOURCES,
variantsFor,
} from "../runtime-pack-common/runtime-pack-matrix.mjs";
/**
* The executable runtime-pack matrix. This is the single source of truth for
* both release compilation and the generated feature predicates consumed by
* the compiler. A predicate is intentionally data, not JavaScript, so the
* installed compiler can validate and evaluate it deterministically.
*/
const any = (...features) => ({ any: features });
const all = (...features) => ({ all: features });
// ld64 dead-strips Mach-O symbol subsections without an ELF-style compile
// flag. Keep this checked-in metadata alongside the matrix so pack build and
// source/external linking share one documented executable recipe.
export const EXECUTABLE_SECTION_ELIMINATION = {
compile_flags: [],
link_flags: ["-Wl,-dead_strip"],
};
export const RUNTIME_PACK_MATRIX = withLibraryRuntimeFlavors(
withWorkerRuntimeVariants({
schema: "scriptc.runtime-pack-matrix.v1",
target: {
name: "macos-arm64",
llvm_triple: "arm64-apple-macosx14.0.0",
architecture: "arm64",
object_format: "macho",
minimum_os: "14.0",
},
flavors: { release: { optimization: "-O2" }, dev: { optimization: "-O0" } },
executable_section_elimination: EXECUTABLE_SECTION_ELIMINATION,
runtime_units: [
...BASE_RUNTIME_SOURCES.map((source) => ({ source, predicate: true })),
// The macOS pack ships no ICU, so it omits scr_intl.c, and the compiler
// refuses the ICU-answered Intl forms for this target.
...OPTIONAL_RUNTIME_SOURCES.filter(([source]) => source !== "scr_intl.c").map(
([source, predicate]) => ({ source, predicate }),
),
].map((unit) => ({ ...unit, variants: variantsFor(unit.source) })),
archives: [
{ id: "quickjs", predicate: false },
{ id: "libregexp", predicate: "regex" },
{ id: "zlib", predicate: "zlibEffective" },
{ id: "brotli", predicate: all("zlib", "brotli") },
{ id: "mbedtls", predicate: any("tlsEffective", "cipher", "ecdh", "dh", "pki") },
],
system_libraries: [{ name: "System", predicate: true }],
}),
);