From 83818a530219ac3a6cda6d5e6c3f86b92fe5b0fc Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Wed, 4 Jun 2025 20:44:19 -0700 Subject: [PATCH 01/24] Use runtime op if available to set platform for `std.process` --- packages/std/core/recipes/process.bri | 2 +- packages/std/core/runtime.bri | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/std/core/recipes/process.bri b/packages/std/core/recipes/process.bri index e2437cee..eaf61dd8 100644 --- a/packages/std/core/recipes/process.bri +++ b/packages/std/core/recipes/process.bri @@ -183,7 +183,7 @@ export function process(options: ProcessOptions): Process { env: Object.fromEntries(envPairsSerialized), currentDir: currentDirSerialized ?? undefined, dependencies: dependenciesSerialized, - platform: "x86_64-linux", + platform: runtime.CURRENT_PLATFORM, workDir: workDirSerialized ?? { type: "create_directory", entries: {}, diff --git a/packages/std/core/runtime.bri b/packages/std/core/runtime.bri index 36f87bd5..624075f6 100644 --- a/packages/std/core/runtime.bri +++ b/packages/std/core/runtime.bri @@ -11,6 +11,18 @@ function getBriocheVersion(): string { export const BRIOCHE_VERSION = getBriocheVersion(); +function getCurrentPlatform(): Platform { + const { op_brioche_current_platform } = (globalThis as any).Deno.core.ops; + + if (op_brioche_current_platform === undefined) { + return "x86_64-linux"; + } + + return op_brioche_current_platform(); +} + +export const CURRENT_PLATFORM = getCurrentPlatform(); + export async function bakeAll(recipes: []): Promise<[]>; export async function bakeAll(recipes: [Recipe]): Promise<[Artifact]>; export async function bakeAll( From d519702d9aba6ff22e399365679aa3bcb1917a25 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 14 Jun 2025 23:36:46 -0700 Subject: [PATCH 02/24] Update `std.toolchain()` to support native compilation on aarch64 --- packages/std/brioche.lock | 20 +++ packages/std/core/index.bri | 2 + packages/std/runtime_utils.bri | 22 ++- packages/std/toolchain/native/binutils.bri | 6 +- packages/std/toolchain/native/gcc.bri | 27 +++- packages/std/toolchain/native/glibc.bri | 18 ++- packages/std/toolchain/stage0/index.bri | 140 ++++++++++++++---- .../std/toolchain/stage1/1_01_binutils.bri | 4 +- packages/std/toolchain/stage1/1_02_gcc.bri | 4 +- .../toolchain/stage1/1_03_linux_headers.bri | 4 +- packages/std/toolchain/stage1/1_04_glibc.bri | 7 +- .../std/toolchain/stage1/1_05_libstdcpp.bri | 17 ++- packages/std/toolchain/stage1/index.bri | 18 ++- packages/std/toolchain/stage2/2_01_m4.bri | 4 +- .../std/toolchain/stage2/2_02_ncurses.bri | 4 +- packages/std/toolchain/stage2/2_03_bash.bri | 4 +- .../std/toolchain/stage2/2_04_coreutils.bri | 4 +- .../std/toolchain/stage2/2_05_diffutils.bri | 4 +- packages/std/toolchain/stage2/2_06_file.bri | 4 +- .../std/toolchain/stage2/2_07_findutils.bri | 4 +- packages/std/toolchain/stage2/2_08_gawk.bri | 4 +- packages/std/toolchain/stage2/2_09_grep.bri | 4 +- packages/std/toolchain/stage2/2_10_gzip.bri | 4 +- packages/std/toolchain/stage2/2_11_make.bri | 4 +- packages/std/toolchain/stage2/2_12_patch.bri | 4 +- packages/std/toolchain/stage2/2_13_sed.bri | 4 +- packages/std/toolchain/stage2/2_14_tar.bri | 4 +- packages/std/toolchain/stage2/2_15_xz.bri | 4 +- .../std/toolchain/stage2/2_16_binutils.bri | 4 +- packages/std/toolchain/stage2/2_17_gcc.bri | 13 +- .../std/toolchain/stage2/2_18_toolchain.bri | 22 +-- packages/std/toolchain/utils.bri | 22 ++- 32 files changed, 287 insertions(+), 123 deletions(-) diff --git a/packages/std/brioche.lock b/packages/std/brioche.lock index a303b182..58b440ba 100644 --- a/packages/std/brioche.lock +++ b/packages/std/brioche.lock @@ -5,10 +5,18 @@ "type": "sha256", "value": "f4a245b94124b377d8b49646bf421f9155d36aa7614b6ebf83705d3ffc76eaad" }, + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-bootstrap/99ab9787d5ee27eb613227131e23d2c651de318a/aarch64-linux/brioche-bootstrap.tar.zstd": { + "type": "sha256", + "value": "dde2f006b119a8154dc6c22a63f064e67fd880bb42d74f64730be7325fde4fbb" + }, "https://development-content.brioche.dev/github.com/brioche-dev/brioche-bootstrap/99ab9787d5ee27eb613227131e23d2c651de318a/x86_64-linux/brioche-bootstrap.tar.zstd": { "type": "sha256", "value": "0cabcd0a074e08ac132281f711f884777b47def17fbeff2a82ba011836b83d11" }, + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd": { + "type": "sha256", + "value": "9fd2d3fd6c114dd4c79cf794ca91a91da7a8be946b756346710a9b279cc7e3fa" + }, "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd": { "type": "sha256", "value": "ca2bdc7d2bb6184036e5a3b247935a25979d7ec5381dd5b94058a0a50cc6b870" @@ -17,14 +25,26 @@ "type": "sha256", "value": "e2e9ae181e115e155158cb9031687d943b0847d8058a4c28454194d835478be6" }, + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_arm64_linux.tar.xz": { + "type": "sha256", + "value": "02308fd5aaea492d730f390b8122a0d518a13df7fbbeb46568497cc6ef93bc81" + }, "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/toolchain_amd64_linux.tar.zstd": { "type": "sha256", "value": "27416708f7ee8cd0c5d408010192705b40c914647fd0d80f00c2194795828cd6" }, + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/toolchain_arm64_linux.tar.zstd": { + "type": "sha256", + "value": "823c4f9687aaee22f4115845063c84c62fccb75c081c2e50c0b78d459857b4fd" + }, "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/utils_amd64_linux.tar.zstd": { "type": "sha256", "value": "eb29ea059fcd9ca457841f5c79151721a74761a31610d694bce61a62f4de6d33" }, + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/utils_arm64_linux.tar.zstd": { + "type": "sha256", + "value": "36c0dcfb02e61a07f4654e1ca6047cdefb17ce1f2e37fcb2ba5dc20695b3e273" + }, "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/Python-3.11.4.tar.xz": { "type": "sha256", "value": "2f0e409df2ab57aa9fc4cbddfb976af44e4e55bf6f619eee6bc5c2297264a7f6" diff --git a/packages/std/core/index.bri b/packages/std/core/index.bri index cbe43e06..486ea7ac 100644 --- a/packages/std/core/index.bri +++ b/packages/std/core/index.bri @@ -11,6 +11,7 @@ export { } from "./utils.bri"; export { BRIOCHE_VERSION, + CURRENT_PLATFORM, utf8Encode, utf8Decode, tickEncode, @@ -19,6 +20,7 @@ export { bstringToBytes, bstringToString, type BString, + type Platform, } from "./runtime.bri"; import "./console.bri"; diff --git a/packages/std/runtime_utils.bri b/packages/std/runtime_utils.bri index 729de89f..e6df1449 100644 --- a/packages/std/runtime_utils.bri +++ b/packages/std/runtime_utils.bri @@ -1,9 +1,25 @@ import * as std from "/core"; -export function runtimeUtils(): std.Recipe { - return Brioche.download( +const PLATFORM_RUNTIME_UTILS: Record< + std.Platform, + std.Recipe | undefined +> = { + "x86_64-linux": Brioche.download( "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd", - ).unarchive("tar", "zstd"); + ).unarchive("tar", "zstd"), + "aarch64-linux": Brioche.download( + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd", + ).unarchive("tar", "zstd"), +}; + +export function runtimeUtils(): std.Recipe { + const platformRuntimeUtils = PLATFORM_RUNTIME_UTILS[std.CURRENT_PLATFORM]; + std.assert( + platformRuntimeUtils != null, + `The platform '${std.CURRENT_PLATFORM}' is not handled by this version of std`, + ); + + return platformRuntimeUtils; } interface RunnableData { diff --git a/packages/std/toolchain/native/binutils.bri b/packages/std/toolchain/native/binutils.bri index 5a068763..a38205e2 100644 --- a/packages/std/toolchain/native/binutils.bri +++ b/packages/std/toolchain/native/binutils.bri @@ -1,10 +1,12 @@ import * as std from "/core"; -import stage2 from "/toolchain/stage2"; import { useBriocheLd } from "/toolchain/utils.bri"; +import { currentPlatformInfo } from "/toolchain/stage0"; +import stage2 from "/toolchain/stage2"; import flex from "./flex.bri"; import zlib from "./zlib.bri"; export default std.memo((): std.Recipe => { + const platformInfo = currentPlatformInfo(); const source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/binutils-2.41.tar.xz", ) @@ -50,7 +52,7 @@ export default std.memo((): std.Recipe => { binutils = useBriocheLd(binutils, { ldPaths: ["bin/ld.bfd", "bin/ld.gold"], interpreterPaths: { - "lib64/ld-linux-x86-64.so.2": "lib64/ld-linux-x86-64.so.2", + [platformInfo.dynamicLinkerPath]: platformInfo.dynamicLinkerPath, }, }); diff --git a/packages/std/toolchain/native/gcc.bri b/packages/std/toolchain/native/gcc.bri index 6e4ff6c5..f595821f 100644 --- a/packages/std/toolchain/native/gcc.bri +++ b/packages/std/toolchain/native/gcc.bri @@ -1,5 +1,6 @@ import * as std from "/core"; import { useBriocheCc } from "../utils.bri"; +import { currentPlatformInfo } from "../stage0"; import linuxHeaders from "./linux_headers.bri"; import stage2 from "/toolchain/stage2"; import glibc from "./glibc.bri"; @@ -11,6 +12,7 @@ import mpc from "./mpc.bri"; import libxcrypt from "./libxcrypt.bri"; export default std.memo((): std.Recipe => { + const platformInfo = currentPlatformInfo(); let source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/gcc-13.2.0.tar.xz", ) @@ -92,7 +94,9 @@ export default std.memo((): std.Recipe => { ], env: { PATH: std.tpl`${buildSysroot}/bin:${stage2()}/bin`, - CPPFLAGS: std.tpl`-I${zlib()}/include -I${gmp()}/include -I${mpfr()}/include -I${mpc()}/include -isystem ${stage2()}/usr/lib/gcc/x86_64-lfs-linux-gnu/13.2.0/include -isystem ${buildSysroot}/include -isystem ${buildSysroot}/usr/include`, + CPPFLAGS: std.tpl`-I${zlib()}/include -I${gmp()}/include -I${mpfr()}/include -I${mpc()}/include -isystem ${stage2()}/usr/lib/gcc/${ + platformInfo.arch + }-lfs-linux-gnu/13.2.0/include -isystem ${buildSysroot}/include -isystem ${buildSysroot}/usr/include`, LDFLAGS: std.tpl`-L${zlib()}/lib -L${gmp()}/lib -L${mpfr()}/lib -L${mpc()}/lib -L${buildSysroot}/lib -L${buildSysroot}/lib64 -lm --sysroot=${buildSysroot}`, buildSysroot, gmp: gmp(), @@ -105,10 +109,10 @@ export default std.memo((): std.Recipe => { gcc = useBriocheCc(gcc, { ccPaths: [ - "bin/x86_64-pc-linux-gnu-c++", - "bin/x86_64-pc-linux-gnu-g++", - "bin/x86_64-pc-linux-gnu-gcc", - "bin/x86_64-pc-linux-gnu-gcc-13.2.0", + `bin/${toolchainTriple()}-c++`, + `bin/${toolchainTriple()}-g++`, + `bin/${toolchainTriple()}-gcc`, + `bin/${toolchainTriple()}-gcc-13.2.0`, "bin/c++", "bin/g++", "bin/gcc", @@ -118,3 +122,16 @@ export default std.memo((): std.Recipe => { return gcc; }); + +function toolchainTriple(): string { + switch (std.CURRENT_PLATFORM) { + case "x86_64-linux": + return "x86_64-pc-linux-gnu"; + case "aarch64-linux": + return "aarch64-unknown-linux-gnu"; + default: + throw new Error( + `The platform '${std.CURRENT_PLATFORM}' is not handled by this version of std`, + ); + } +} diff --git a/packages/std/toolchain/native/glibc.bri b/packages/std/toolchain/native/glibc.bri index 9fed540c..68cbf9b5 100644 --- a/packages/std/toolchain/native/glibc.bri +++ b/packages/std/toolchain/native/glibc.bri @@ -1,7 +1,9 @@ import * as std from "/core"; +import { currentPlatformInfo } from "/toolchain/stage0"; import stage2 from "/toolchain/stage2"; export default std.memo((): std.Recipe => { + const platformInfo = currentPlatformInfo(); let source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/glibc-2.38.tar.xz", ) @@ -74,14 +76,16 @@ export default std.memo((): std.Recipe => { }) .toDirectory(); - glibc = glibc.insert( - "lib64", - std.directory({ - "ld-linux-x86-64.so.2": std.symlink({ - target: "../lib/ld-linux-x86-64.so.2", + if (platformInfo.arch === "x86_64") { + glibc = glibc.insert( + "lib64", + std.directory({ + "ld-linux-x86-64.so.2": std.symlink({ + target: "../lib/ld-linux-x86-64.so.2", + }), }), - }), - ); + ); + } return glibc; }); diff --git a/packages/std/toolchain/stage0/index.bri b/packages/std/toolchain/stage0/index.bri index cf7fd67e..770913cd 100644 --- a/packages/std/toolchain/stage0/index.bri +++ b/packages/std/toolchain/stage0/index.bri @@ -1,6 +1,77 @@ import * as std from "/core"; import { runtimeUtils } from "../utils.bri"; +interface PlatformInfo { + bootstrapToolchain: std.Recipe; + bootstrapToolchainTargetTriple: string; + bootstrapToolchainDynamicLinkerName: string; + bootstrapUtils: std.Recipe; + bootstrapRootfs: std.Recipe; + bootstrapRootfsSystemToolchainPath: string; + busybox: std.Recipe; + libDir: string; + dynamicLinkerPath: string; + arch: string; + os: string; +} + +export const PLATFORM_INFO: Record = { + "x86_64-linux": { + bootstrapToolchain: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/toolchain_amd64_linux.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapToolchainTargetTriple: "x86_64-linux-musl", + bootstrapToolchainDynamicLinkerName: "ld-musl-x86_64.so.1", + bootstrapUtils: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/utils_amd64_linux.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapRootfs: Brioche.download( + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-bootstrap/99ab9787d5ee27eb613227131e23d2c651de318a/x86_64-linux/brioche-bootstrap.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapRootfsSystemToolchainPath: "/usr/lib/gcc/x86_64-linux-gnu/12", + busybox: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_amd64_linux.tar.xz", + ).unarchive("tar", "xz"), + libDir: "lib64", + dynamicLinkerPath: "lib64/ld-linux-x86-64.so.2", + arch: "x86_64", + os: "linux", + }, + "aarch64-linux": { + bootstrapToolchain: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/toolchain_arm64_linux.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapToolchainTargetTriple: "aarch64-linux-musl", + bootstrapToolchainDynamicLinkerName: "ld-musl-aarch64.so.1", + bootstrapUtils: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/utils_arm64_linux.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapRootfs: Brioche.download( + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-bootstrap/99ab9787d5ee27eb613227131e23d2c651de318a/aarch64-linux/brioche-bootstrap.tar.zstd", + ).unarchive("tar", "zstd"), + bootstrapRootfsSystemToolchainPath: "/usr/lib/gcc/aarch64-linux-gnu/12", + busybox: Brioche.download( + "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_arm64_linux.tar.xz", + ) + .unarchive("tar", "xz") + .peel(1), + libDir: "lib", + dynamicLinkerPath: "lib/ld-linux-aarch64.so.1", + arch: "aarch64", + os: "linux", + }, +}; + +export function currentPlatformInfo(): PlatformInfo { + const platformInfo = PLATFORM_INFO[std.CURRENT_PLATFORM]; + std.assert( + platformInfo != null, + `The platform '${std.CURRENT_PLATFORM}' is not handled by this version of std`, + ); + + return platformInfo; +} + interface BootstrapRunOptions { script: string; env?: Record; @@ -11,14 +82,7 @@ interface BootstrapRunOptions { export function bootstrapRun( options: BootstrapRunOptions, ): std.Recipe { - const bootstrapRootfs = Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-bootstrap/99ab9787d5ee27eb613227131e23d2c651de318a/x86_64-linux/brioche-bootstrap.tar.zstd", - ).unarchive("tar", "zstd"); - - const busybox = Brioche.download( - "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_amd64_linux.tar.xz", - ).unarchive("tar", "xz"); - + const platformInfo = currentPlatformInfo(); const briocheLd = runtimeUtils().get("bin/brioche-ld"); const briochePacked = runtimeUtils().get("bin/brioche-packed-exec"); @@ -50,13 +114,13 @@ export function bootstrapRun( "$BUSYBOX/bin/busybox" mount --rbind "$BRIOCHE_OUTPUT" "$(pwd)/rootfs/$BRIOCHE_OUTPUT" "$BUSYBOX/bin/busybox" mount --rbind "$BRIOCHE_RESOURCE_DIR" "$(pwd)/rootfs/$BRIOCHE_RESOURCE_DIR" - "$BUSYBOX/bin/busybox" mkdir -p "$HOME/.local/libexec/brioche-toolchain/bin" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/lib64" + "$BUSYBOX/bin/busybox" mkdir -p "$HOME/.local/libexec/brioche-toolchain/bin" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/$lib_dir" "$BUSYBOX/bin/busybox" cp "$BRIOCHE_LD" "$HOME/.local/libexec/brioche-toolchain/bin/ld" "$BUSYBOX/bin/busybox" cp "$BRIOCHE_PACKED" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/brioche-packed" "$BUSYBOX/bin/busybox" chmod +x "$HOME/.local/libexec/brioche-toolchain/bin/ld" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/brioche-packed" "$BUSYBOX/bin/busybox" ln -s "/usr/bin/ld" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/ld" - "$BUSYBOX/bin/busybox" ln -s "/lib64/ld-linux-x86-64.so.2" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/lib64/" - "$BUSYBOX/bin/busybox" ln -s "ld" "$HOME/.local/libexec/brioche-toolchain/bin/x86_64-linux-gnu-ld" + "$BUSYBOX/bin/busybox" ln -s "/$dynamic_linker_path" "$HOME/.local/libexec/brioche-toolchain/libexec/brioche-ld/$lib_dir/" + "$BUSYBOX/bin/busybox" ln -s "ld" "$HOME/.local/libexec/brioche-toolchain/bin/$ld_name" export PATH="$HOME/.local/libexec/brioche-toolchain/bin\${PATH:+:$PATH}" @@ -67,19 +131,26 @@ export function bootstrapRun( `) .withPermissions({ executable: true }); + const ldName = `${platformInfo.arch}-${platformInfo.os}-gnu-ld`; return std .process({ - command: std.tpl`${busybox}/bin/busybox`, + command: std.tpl`${platformInfo.busybox}/bin/busybox`, args: ["unshare", "-Umfr", enterBootstrapChrootScript], env: { - BUSYBOX: busybox, + BUSYBOX: platformInfo.busybox, BRIOCHE_LD: briocheLd, BRIOCHE_PACKED: briochePacked, - SYSTEM_TOOLCHAIN_PATH: "/usr/lib/gcc/x86_64-linux-gnu/12", + SYSTEM_TOOLCHAIN_PATH: platformInfo.bootstrapRootfsSystemToolchainPath, + dynamic_linker_path: platformInfo.dynamicLinkerPath, + lib_dir: platformInfo.libDir, + ld_name: ldName, ...options.env, }, workDir: std.directory({ - rootfs: bootstrapRootfs.insert("bootstrap.sh", bootstrapScript), + rootfs: platformInfo.bootstrapRootfs.insert( + "bootstrap.sh", + bootstrapScript, + ), work: options.workDir ?? std.directory(), }), outputScaffold: options.outputScaffold, @@ -88,19 +159,17 @@ export function bootstrapRun( } export default async (): Promise => { - const utils = Brioche.download( - "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/utils_amd64_linux.tar.zstd", - ).unarchive("tar", "zstd"); - - const toolchain = Brioche.download( - "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2023-07-06/toolchain_amd64_linux.tar.zstd", - ).unarchive("tar", "zstd"); + const platformInfo = PLATFORM_INFO[std.CURRENT_PLATFORM]; + std.assert( + platformInfo != null, + `The platform '${std.CURRENT_PLATFORM}' is not handled by this version of std`, + ); const briocheLd = runtimeUtils().get("bin/brioche-ld"); const briochePacked = runtimeUtils().get("bin/brioche-packed-exec"); const briochePack = std.directory({ - "x86_64-linux-musl": std.directory({ + [platformInfo.bootstrapToolchainTargetTriple]: std.directory({ bin: std.directory({ "brioche-ld": briocheLd, }), @@ -109,8 +178,8 @@ export default async (): Promise => { ld: std.symlink({ target: "../../bin/system-ld" }), "brioche-packed": briochePacked, lib: std.directory({ - "ld-musl-x86_64.so.1": std.symlink({ - target: "../../../../lib/ld-musl-x86_64.so.1", + [platformInfo.bootstrapToolchainDynamicLinkerName]: std.symlink({ + target: `../../../../lib/${platformInfo.bootstrapToolchainDynamicLinkerName}`, }), }), }), @@ -118,17 +187,28 @@ export default async (): Promise => { }), }); - let stage0 = std.merge(utils, toolchain, briochePack); + let stage0 = std.merge( + platformInfo.bootstrapUtils, + platformInfo.bootstrapToolchain, + briochePack, + ); - const systemLd = stage0.get("x86_64-linux-musl/bin/ld"); - stage0 = stage0.insert("x86_64-linux-musl/bin/system-ld", systemLd); + const systemLd = stage0.get( + `${platformInfo.bootstrapToolchainTargetTriple}/bin/ld`, + ); + stage0 = stage0.insert( + `${platformInfo.bootstrapToolchainTargetTriple}/bin/system-ld`, + systemLd, + ); stage0 = stage0.insert( - "x86_64-linux-musl/bin/ld", + `${platformInfo.bootstrapToolchainTargetTriple}/bin/ld`, std.symlink({ target: "brioche-ld" }), ); stage0 = stage0.insert( "bin/ld", - std.symlink({ target: "../x86_64-linux-musl/bin/ld" }), + std.symlink({ + target: `../${platformInfo.bootstrapToolchainTargetTriple}/bin/ld`, + }), ); return stage0; diff --git a/packages/std/toolchain/stage1/1_01_binutils.bri b/packages/std/toolchain/stage1/1_01_binutils.bri index 041b3664..2130057b 100644 --- a/packages/std/toolchain/stage1/1_01_binutils.bri +++ b/packages/std/toolchain/stage1/1_01_binutils.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "/toolchain/stage0"; +import { bootstrapRun, currentPlatformInfo } from "/toolchain/stage0"; const source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/binutils-2.41.tar.xz", @@ -26,7 +26,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, }, workDir: source, }); diff --git a/packages/std/toolchain/stage1/1_02_gcc.bri b/packages/std/toolchain/stage1/1_02_gcc.bri index d04cb9e0..988d0629 100644 --- a/packages/std/toolchain/stage1/1_02_gcc.bri +++ b/packages/std/toolchain/stage1/1_02_gcc.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "/toolchain/stage0"; +import { bootstrapRun, currentPlatformInfo } from "/toolchain/stage0"; import binutils from "./1_01_binutils.bri"; export default std.memo(async (): Promise> => { @@ -75,7 +75,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1, }, workDir: source, diff --git a/packages/std/toolchain/stage1/1_03_linux_headers.bri b/packages/std/toolchain/stage1/1_03_linux_headers.bri index ded0dfbf..21551352 100644 --- a/packages/std/toolchain/stage1/1_03_linux_headers.bri +++ b/packages/std/toolchain/stage1/1_03_linux_headers.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "/toolchain/stage0"; +import { bootstrapRun, currentPlatformInfo } from "/toolchain/stage0"; export default std.memo(async (): Promise> => { const source = Brioche.download( @@ -22,7 +22,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, }, workDir: source, }); diff --git a/packages/std/toolchain/stage1/1_04_glibc.bri b/packages/std/toolchain/stage1/1_04_glibc.bri index 472d9639..77775053 100644 --- a/packages/std/toolchain/stage1/1_04_glibc.bri +++ b/packages/std/toolchain/stage1/1_04_glibc.bri @@ -1,11 +1,12 @@ import * as std from "/core"; import { runtimeUtils } from "../utils.bri"; -import { bootstrapRun } from "/toolchain/stage0"; +import { bootstrapRun, currentPlatformInfo } from "/toolchain/stage0"; import binutils from "./1_01_binutils.bri"; import gcc from "./1_02_gcc.bri"; import linuxHeaders from "./1_03_linux_headers.bri"; export default std.memo((): std.Recipe => { + const platformInfo = currentPlatformInfo(); let source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/glibc-2.38.tar.xz", ) @@ -68,8 +69,8 @@ export default std.memo((): std.Recipe => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", - LD_LINUX: "/lib64/ld-linux-x86-64.so.2", + TARGET: `${platformInfo.arch}-lfs-linux-gnu`, + LD_LINUX: `/${platformInfo.dynamicLinkerPath}`, stage1, }, workDir: source, diff --git a/packages/std/toolchain/stage1/1_05_libstdcpp.bri b/packages/std/toolchain/stage1/1_05_libstdcpp.bri index 6fd6de4c..323024f1 100644 --- a/packages/std/toolchain/stage1/1_05_libstdcpp.bri +++ b/packages/std/toolchain/stage1/1_05_libstdcpp.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "/toolchain/stage0"; +import { bootstrapRun, currentPlatformInfo } from "/toolchain/stage0"; import binutils from "./1_01_binutils.bri"; import gcc from "./1_02_gcc.bri"; import linuxHeaders from "./1_03_linux_headers.bri"; @@ -7,6 +7,7 @@ import glibc from "./1_04_glibc.bri"; import { wrapWithScript, useBriocheLd } from "../utils.bri"; export default std.memo(async (): Promise> => { + const platformInfo = currentPlatformInfo(); const source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/gcc-13.2.0.tar.xz", ) @@ -16,7 +17,7 @@ export default std.memo(async (): Promise> => { let stage1 = std.merge(binutils(), gcc(), linuxHeaders(), glibc()); stage1 = wrapWithScript(stage1, { - paths: ["usr/bin/x86_64-lfs-linux-gnu-gcc"], + paths: [`usr/bin/${platformInfo.arch}-lfs-linux-gnu-gcc`], renameSuffix: "-orig", script: std .file(std.indoc` @@ -29,13 +30,13 @@ export default std.memo(async (): Promise> => { stage1 = useBriocheLd(stage1, { ldPaths: [ - "usr/bin/x86_64-lfs-linux-gnu-ld", - "usr/bin/x86_64-lfs-linux-gnu-ld.bfd", - "usr/x86_64-lfs-linux-gnu/bin/ld", - "usr/x86_64-lfs-linux-gnu/bin/ld.bfd", + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-ld`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-ld.bfd`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld.bfd`, ], interpreterPaths: { - "lib64/ld-linux-x86-64.so.2": "lib64/ld-linux-x86-64.so.2", + [platformInfo.dynamicLinkerPath]: platformInfo.dynamicLinkerPath, }, }); @@ -66,7 +67,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${platformInfo.arch}-lfs-linux-gnu`, stage1, }, workDir: source, diff --git a/packages/std/toolchain/stage1/index.bri b/packages/std/toolchain/stage1/index.bri index f2886912..962229c5 100644 --- a/packages/std/toolchain/stage1/index.bri +++ b/packages/std/toolchain/stage1/index.bri @@ -4,6 +4,7 @@ import gcc from "./1_02_gcc.bri"; import linuxHeaders from "./1_03_linux_headers.bri"; import glibc from "./1_04_glibc.bri"; import libstdcpp from "./1_05_libstdcpp.bri"; +import { currentPlatformInfo } from "../stage0"; import { useBriocheLd, wrapWithScript } from "../utils.bri"; export { default as linuxHeaders } from "./1_03_linux_headers.bri"; @@ -11,6 +12,7 @@ export { default as glibc } from "./1_04_glibc.bri"; export { default as libstdcpp } from "./1_05_libstdcpp.bri"; export default std.memo(() => { + const platformInfo = currentPlatformInfo(); let stage1 = std.merge( binutils(), gcc(), @@ -23,20 +25,20 @@ export default std.memo(() => { stage1 = useBriocheLd(stage1, { ldPaths: [ - "usr/bin/x86_64-lfs-linux-gnu-ld", - "usr/bin/x86_64-lfs-linux-gnu-ld.bfd", - "usr/x86_64-lfs-linux-gnu/bin/ld", - "usr/x86_64-lfs-linux-gnu/bin/ld.bfd", + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-ld`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-ld.bfd`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld.bfd`, ], interpreterPaths: { - "lib64/ld-linux-x86-64.so.2": "lib/ld-linux-x86-64.so.2", + [platformInfo.dynamicLinkerPath]: platformInfo.dynamicLinkerPath, }, }); stage1 = wrapWithScript(stage1, { paths: [ - "usr/bin/x86_64-lfs-linux-gnu-g++", - "usr/bin/x86_64-lfs-linux-gnu-gcc", + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-g++`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-gcc`, ], renameSuffix: "-orig", script: std @@ -44,7 +46,7 @@ export default std.memo(() => { #!/usr/bin/env sh script_dir=$(cd "$(dirname -- "$0")" && pwd -P) sysroot=$(cd "$script_dir/../.." && pwd -P) - "$0-orig" --sysroot="$sysroot" -isystem "$sysroot/x86_64-lfs-linux-gnu/include/c++/13.2.0/x86_64-lfs-linux-gnu" -isystem "$sysroot/x86_64-lfs-linux-gnu/include/c++/13.2.0" -isystem "$sysroot/usr/include" "$@" + "$0-orig" --sysroot="$sysroot" -isystem "$sysroot/${platformInfo.arch}-lfs-linux-gnu/include/c++/13.2.0/${platformInfo.arch}-lfs-linux-gnu" -isystem "$sysroot/${platformInfo.arch}-lfs-linux-gnu/include/c++/13.2.0" -isystem "$sysroot/usr/include" "$@" `) .withPermissions({ executable: true }), }); diff --git a/packages/std/toolchain/stage2/2_01_m4.bri b/packages/std/toolchain/stage2/2_01_m4.bri index 11afc1d5..b883bb8e 100644 --- a/packages/std/toolchain/stage2/2_01_m4.bri +++ b/packages/std/toolchain/stage2/2_01_m4.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -22,7 +22,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_02_ncurses.bri b/packages/std/toolchain/stage2/2_02_ncurses.bri index e83d73fc..c8658439 100644 --- a/packages/std/toolchain/stage2/2_02_ncurses.bri +++ b/packages/std/toolchain/stage2/2_02_ncurses.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -48,7 +48,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_03_bash.bri b/packages/std/toolchain/stage2/2_03_bash.bri index 97999c8e..1306904b 100644 --- a/packages/std/toolchain/stage2/2_03_bash.bri +++ b/packages/std/toolchain/stage2/2_03_bash.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -25,7 +25,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_04_coreutils.bri b/packages/std/toolchain/stage2/2_04_coreutils.bri index 58865ad3..8edf55f1 100644 --- a/packages/std/toolchain/stage2/2_04_coreutils.bri +++ b/packages/std/toolchain/stage2/2_04_coreutils.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -31,7 +31,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_05_diffutils.bri b/packages/std/toolchain/stage2/2_05_diffutils.bri index 30591ba4..16610ea3 100644 --- a/packages/std/toolchain/stage2/2_05_diffutils.bri +++ b/packages/std/toolchain/stage2/2_05_diffutils.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -23,7 +23,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_06_file.bri b/packages/std/toolchain/stage2/2_06_file.bri index 388555a2..b63a968b 100644 --- a/packages/std/toolchain/stage2/2_06_file.bri +++ b/packages/std/toolchain/stage2/2_06_file.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -35,7 +35,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_07_findutils.bri b/packages/std/toolchain/stage2/2_07_findutils.bri index 8f1c20bb..39e1f25c 100644 --- a/packages/std/toolchain/stage2/2_07_findutils.bri +++ b/packages/std/toolchain/stage2/2_07_findutils.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -24,7 +24,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_08_gawk.bri b/packages/std/toolchain/stage2/2_08_gawk.bri index b9e1ff27..d064f11a 100644 --- a/packages/std/toolchain/stage2/2_08_gawk.bri +++ b/packages/std/toolchain/stage2/2_08_gawk.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -25,7 +25,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_09_grep.bri b/packages/std/toolchain/stage2/2_09_grep.bri index 209f727c..060b87d7 100644 --- a/packages/std/toolchain/stage2/2_09_grep.bri +++ b/packages/std/toolchain/stage2/2_09_grep.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -23,7 +23,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_10_gzip.bri b/packages/std/toolchain/stage2/2_10_gzip.bri index 440126e7..c09eba4f 100644 --- a/packages/std/toolchain/stage2/2_10_gzip.bri +++ b/packages/std/toolchain/stage2/2_10_gzip.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -22,7 +22,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_11_make.bri b/packages/std/toolchain/stage2/2_11_make.bri index b0fc938e..d8278636 100644 --- a/packages/std/toolchain/stage2/2_11_make.bri +++ b/packages/std/toolchain/stage2/2_11_make.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -24,7 +24,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_12_patch.bri b/packages/std/toolchain/stage2/2_12_patch.bri index 18203750..5faaa89b 100644 --- a/packages/std/toolchain/stage2/2_12_patch.bri +++ b/packages/std/toolchain/stage2/2_12_patch.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -23,7 +23,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_13_sed.bri b/packages/std/toolchain/stage2/2_13_sed.bri index c84c9a73..0d71f513 100644 --- a/packages/std/toolchain/stage2/2_13_sed.bri +++ b/packages/std/toolchain/stage2/2_13_sed.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -23,7 +23,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_14_tar.bri b/packages/std/toolchain/stage2/2_14_tar.bri index 656eb0d4..33cf9f84 100644 --- a/packages/std/toolchain/stage2/2_14_tar.bri +++ b/packages/std/toolchain/stage2/2_14_tar.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -23,7 +23,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_15_xz.bri b/packages/std/toolchain/stage2/2_15_xz.bri index c7251f48..792e580b 100644 --- a/packages/std/toolchain/stage2/2_15_xz.bri +++ b/packages/std/toolchain/stage2/2_15_xz.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -27,7 +27,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_16_binutils.bri b/packages/std/toolchain/stage2/2_16_binutils.bri index 1de7cc70..d78161cb 100644 --- a/packages/std/toolchain/stage2/2_16_binutils.bri +++ b/packages/std/toolchain/stage2/2_16_binutils.bri @@ -1,5 +1,5 @@ import * as std from "/core"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; export default std.memo(async (): Promise> => { @@ -41,7 +41,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${currentPlatformInfo().arch}-lfs-linux-gnu`, stage1: stage1(), }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_17_gcc.bri b/packages/std/toolchain/stage2/2_17_gcc.bri index 13aa2239..90c9259b 100644 --- a/packages/std/toolchain/stage2/2_17_gcc.bri +++ b/packages/std/toolchain/stage2/2_17_gcc.bri @@ -1,6 +1,6 @@ import * as std from "/core"; import { useBriocheLd } from "../utils.bri"; -import { bootstrapRun } from "../stage0"; +import { bootstrapRun, currentPlatformInfo } from "../stage0"; import stage1 from "../stage1"; import m4 from "./2_01_m4.bri"; import ncurses from "./2_02_ncurses.bri"; @@ -20,6 +20,7 @@ import xz from "./2_15_xz.bri"; import binutils from "./2_16_binutils.bri"; export default std.memo(async (): Promise> => { + const platformInfo = currentPlatformInfo(); let source = Brioche.download( "https://development-content.brioche.dev/linuxfromscratch.org/v12.0/packages/gcc-13.2.0.tar.xz", ) @@ -82,11 +83,11 @@ export default std.memo(async (): Promise> => { ldPaths: [ "usr/bin/ld", "usr/bin/ld.bfd", - "usr/x86_64-lfs-linux-gnu/bin/ld", - "usr/x86_64-lfs-linux-gnu/bin/ld.bfd", + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld.bfd`, ], interpreterPaths: { - "lib64/ld-linux-x86-64.so.2": "lib/ld-linux-x86-64.so.2", + [platformInfo.dynamicLinkerPath]: platformInfo.dynamicLinkerPath, }, }); @@ -94,7 +95,7 @@ export default std.memo(async (): Promise> => { for (const tool of prefixedTools) { stage2 = stage2.insert( `usr/bin/${tool}`, - std.symlink({ target: `x86_64-lfs-linux-gnu-${tool}` }), + std.symlink({ target: `${platformInfo.arch}-lfs-linux-gnu-${tool}` }), ); } @@ -138,7 +139,7 @@ export default std.memo(async (): Promise> => { `, env: { BRIOCHE_OUTPUT: std.outputPath, - TARGET: "x86_64-lfs-linux-gnu", + TARGET: `${platformInfo.arch}-lfs-linux-gnu`, stage2, }, workDir: source, diff --git a/packages/std/toolchain/stage2/2_18_toolchain.bri b/packages/std/toolchain/stage2/2_18_toolchain.bri index 38a20dac..1aa2af70 100644 --- a/packages/std/toolchain/stage2/2_18_toolchain.bri +++ b/packages/std/toolchain/stage2/2_18_toolchain.bri @@ -1,5 +1,6 @@ import * as std from "/core"; import { wrapWithScript, useBriocheLd } from "../utils.bri"; +import { currentPlatformInfo } from "../stage0"; import { linuxHeaders, glibc, libstdcpp } from "../stage1"; import m4 from "./2_01_m4.bri"; import ncurses from "./2_02_ncurses.bri"; @@ -20,6 +21,7 @@ import binutils from "./2_16_binutils.bri"; import gcc from "./2_17_gcc.bri"; export default std.memo(async (): Promise> => { + const platformInfo = currentPlatformInfo(); let toolchain = std.merge( linuxHeaders(), glibc(), @@ -49,20 +51,20 @@ export default std.memo(async (): Promise> => { ldPaths: [ "usr/bin/ld", "usr/bin/ld.bfd", - "usr/x86_64-lfs-linux-gnu/bin/ld", - "usr/x86_64-lfs-linux-gnu/bin/ld.bfd", + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld`, + `usr/${platformInfo.arch}-lfs-linux-gnu/bin/ld.bfd`, ], interpreterPaths: { - "lib64/ld-linux-x86-64.so.2": "lib/ld-linux-x86-64.so.2", + [platformInfo.dynamicLinkerPath]: platformInfo.dynamicLinkerPath, }, }); toolchain = wrapWithScript(toolchain, { paths: [ - "usr/bin/x86_64-lfs-linux-gnu-c++", - "usr/bin/x86_64-lfs-linux-gnu-g++", - "usr/bin/x86_64-lfs-linux-gnu-gcc", - "usr/bin/x86_64-lfs-linux-gnu-gcc-13.2.0", + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-c++`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-g++`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-gcc`, + `usr/bin/${platformInfo.arch}-lfs-linux-gnu-gcc-13.2.0`, "usr/bin/c++", "usr/bin/g++", "usr/bin/gcc", @@ -131,8 +133,8 @@ export default std.memo(async (): Promise> => { if [ "$include_system_headers" -eq 1 ]; then set -- \ - -isystem "$sysroot/x86_64-lfs-linux-gnu/include/c++/13.2.0/x86_64-lfs-linux-gnu" \ - -isystem "$sysroot/x86_64-lfs-linux-gnu/include/c++/13.2.0" \ + -isystem "$sysroot/${platformInfo.arch}-lfs-linux-gnu/include/c++/13.2.0/${platformInfo.arch}-lfs-linux-gnu" \ + -isystem "$sysroot/${platformInfo.arch}-lfs-linux-gnu/include/c++/13.2.0" \ -isystem "$sysroot/usr/include" \ "$@" fi @@ -147,7 +149,7 @@ export default std.memo(async (): Promise> => { for (const tool of prefixedTools) { toolchain = toolchain.insert( `usr/bin/${tool}`, - std.symlink({ target: `x86_64-lfs-linux-gnu-${tool}` }), + std.symlink({ target: `${platformInfo.arch}-lfs-linux-gnu-${tool}` }), ); } diff --git a/packages/std/toolchain/utils.bri b/packages/std/toolchain/utils.bri index b94e744d..06918743 100644 --- a/packages/std/toolchain/utils.bri +++ b/packages/std/toolchain/utils.bri @@ -1,12 +1,28 @@ import * as std from "/core"; +const PLATFORM_RUNTIME_UTILS: Record< + std.Platform, + std.Recipe | undefined +> = { + "x86_64-linux": Brioche.download( + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd", + ).unarchive("tar", "zstd"), + "aarch64-linux": Brioche.download( + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd", + ).unarchive("tar", "zstd"), +}; + // NOTE: This download is just like the `runtimeUtils()` export, except // it's pinned to a specific version. It should only be updated if the // tools used for building the toolchain should be upgraded export function runtimeUtils(): std.Recipe { - return Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd", - ).unarchive("tar", "zstd"); + const platformRuntimeUtils = PLATFORM_RUNTIME_UTILS[std.CURRENT_PLATFORM]; + std.assert( + platformRuntimeUtils != null, + `The platform '${std.CURRENT_PLATFORM}' is not handled by this version of std`, + ); + + return platformRuntimeUtils; } interface UseBriocheLdOptions { From f747fa67c5b7cf583b4eac2e601d4bd360339e79 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 18:59:12 -0700 Subject: [PATCH 03/24] Add `cargo_chef` package --- packages/cargo_chef/brioche.lock | 8 ++++++ packages/cargo_chef/project.bri | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 packages/cargo_chef/brioche.lock create mode 100644 packages/cargo_chef/project.bri diff --git a/packages/cargo_chef/brioche.lock b/packages/cargo_chef/brioche.lock new file mode 100644 index 00000000..4f551df4 --- /dev/null +++ b/packages/cargo_chef/brioche.lock @@ -0,0 +1,8 @@ +{ + "dependencies": {}, + "git_refs": { + "https://github.com/LukeMathWalker/cargo-chef.git": { + "v0.1.71": "f3b371eb2bafbe7fe47e678f9ea26b8c08b53bbe" + } + } +} diff --git a/packages/cargo_chef/project.bri b/packages/cargo_chef/project.bri new file mode 100644 index 00000000..b6bed33c --- /dev/null +++ b/packages/cargo_chef/project.bri @@ -0,0 +1,44 @@ +import * as std from "std"; +import rust, { cargoBuild } from "rust"; + +export const project = { + name: "cargo_chef", + version: "0.1.71", + repository: "https://github.com/LukeMathWalker/cargo-chef.git", +}; + +const source = Brioche.gitCheckout({ + repository: project.repository, + ref: `v${project.version}`, +}); + +export default function cargoChef(): std.Recipe { + return cargoBuild({ + source, + // Disable using cargo-chef while building cargo-chef to avoid + // infinite recursion + cargoChefPrepare: false, + }); +} + +export async function test(): Promise> { + const script = std.runBash` + cargo chef --version | tee "$BRIOCHE_OUTPUT" + ` + .dependencies(rust, cargoChef) + .toFile(); + + const result = (await script.read()).trim(); + + const version = result.split("\n").at(0); + + // Check that the result contains the expected version + const expected = `cargo-chef-chef ${project.version}`; + std.assert(version === expected, `expected '${expected}', got '${version}'`); + + return script; +} + +export async function liveUpdate() { + return std.liveUpdateFromGithubReleases({ project }); +} From bf18960a9bf7be5fa9a8dd3aed64cbf58fb970f5 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 18:59:12 -0700 Subject: [PATCH 04/24] Update `rust` package to use `cargo_chef` package instead of bespoke download --- packages/rust/brioche.lock | 4 ---- packages/rust/project.bri | 11 +---------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/rust/brioche.lock b/packages/rust/brioche.lock index c5f0ce00..5357cfe9 100644 --- a/packages/rust/brioche.lock +++ b/packages/rust/brioche.lock @@ -1,10 +1,6 @@ { "dependencies": {}, "downloads": { - "https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.71/cargo-chef-x86_64-unknown-linux-musl.tar.gz": { - "type": "sha256", - "value": "bc601a12f1e086a995690e9eed86353b23d9e0429509bfaae1db2e39b41cde52" - }, "https://static.rust-lang.org/dist/channel-rust-1.87.0.toml": { "type": "sha256", "value": "2949b5ea91e3f9c45e75ff2fc6cfc7776616c693ab599ed43abc2120b7522415" diff --git a/packages/rust/project.bri b/packages/rust/project.bri index ffb5ef30..cf8ad1b6 100644 --- a/packages/rust/project.bri +++ b/packages/rust/project.bri @@ -1,4 +1,5 @@ import * as std from "std"; +import cargoChef from "cargo_chef"; import * as TOML from "smol_toml"; import * as t from "typer"; import nushell from "nushell"; @@ -436,13 +437,3 @@ export function vendorCrate( return crate; } - -function cargoChef(): std.Recipe { - const pkg = Brioche.download( - "https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.71/cargo-chef-x86_64-unknown-linux-musl.tar.gz", - ); - - return std.directory({ - bin: pkg.unarchive("tar", "gzip"), - }); -} From d5aae8b3b336adfa3a9a9438c7dd2190e700308a Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 18:59:12 -0700 Subject: [PATCH 05/24] Update `rust` package to support aarch64-linux --- packages/rust/project.bri | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/rust/project.bri b/packages/rust/project.bri index cf8ad1b6..3e5aef19 100644 --- a/packages/rust/project.bri +++ b/packages/rust/project.bri @@ -57,7 +57,7 @@ export default async function rust(): Promise> { throw new Error(`Rustup package ${pkgName} not found`); } - const pkgTarget = pkg.target["x86_64-unknown-linux-gnu"]; + const pkgTarget = pkg.target[targetTriple()]; if (pkgTarget?.available !== true) { continue; } @@ -437,3 +437,16 @@ export function vendorCrate( return crate; } + +function targetTriple(): string { + switch (std.CURRENT_PLATFORM) { + case "x86_64-linux": + return "x86_64-unknown-linux-gnu"; + case "aarch64-linux": + return "aarch64-unknown-linux-gnu"; + default: + throw new Error( + `The platform '${std.CURRENT_PLATFORM}' is currently not supported by this version of the rust package`, + ); + } +} From 12c2290690f5dc98ab536a77fb4d615b47a20b0d Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 23:57:18 -0700 Subject: [PATCH 06/24] Update `go` package to support aarch64-linux --- packages/go/brioche.lock | 4 ++++ packages/go/project.bri | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/go/brioche.lock b/packages/go/brioche.lock index 0d7ee53e..090c4f08 100644 --- a/packages/go/brioche.lock +++ b/packages/go/brioche.lock @@ -4,6 +4,10 @@ "https://go.dev/dl/go1.24.3.linux-amd64.tar.gz": { "type": "sha256", "value": "3333f6ea53afa971e9078895eaa4ac7204a8c6b5c68c10e6bc9a33e8e391bdd8" + }, + "https://go.dev/dl/go1.24.3.linux-arm64.tar.gz": { + "type": "sha256", + "value": "a463cb59382bd7ae7d8f4c68846e73c4d589f223c589ac76871b66811ded7836" } } } diff --git a/packages/go/project.bri b/packages/go/project.bri index f86ffb6b..c4e42ca2 100644 --- a/packages/go/project.bri +++ b/packages/go/project.bri @@ -6,11 +6,26 @@ export const project = { version: "1.24.3", }; -const source = Brioche.download( - `https://go.dev/dl/go${project.version}.linux-amd64.tar.gz`, -) - .unarchive("tar", "gzip") - .peel(); +function goPrebuilt(): std.Recipe { + switch (std.CURRENT_PLATFORM) { + case "x86_64-linux": + return Brioche.download( + `https://go.dev/dl/go${project.version}.linux-amd64.tar.gz`, + ) + .unarchive("tar", "gzip") + .peel(); + case "aarch64-linux": + return Brioche.download( + `https://go.dev/dl/go${project.version}.linux-arm64.tar.gz`, + ) + .unarchive("tar", "gzip") + .peel(); + default: + throw new Error( + `The platform '${std.CURRENT_PLATFORM}' is currently not supported by this version of the go package`, + ); + } +} /** * The Go programming language. @@ -27,7 +42,7 @@ const source = Brioche.download( export default function go(): std.Recipe { return std .directory({ - go: source, + go: goPrebuilt(), bin: std.directory({ go: std.symlink({ target: "../go/bin/go" }), gofmt: std.symlink({ target: "../go/bin/gofmt" }), From 43fbf44e4a893646d6c09744c5d4442c9debd4a4 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 23:59:03 -0700 Subject: [PATCH 07/24] Update `nodejs` package to support aarch64-linux --- packages/nodejs/brioche.lock | 4 ++++ packages/nodejs/project.bri | 39 ++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/nodejs/brioche.lock b/packages/nodejs/brioche.lock index 56524887..5979fdaf 100644 --- a/packages/nodejs/brioche.lock +++ b/packages/nodejs/brioche.lock @@ -1,6 +1,10 @@ { "dependencies": {}, "downloads": { + "https://nodejs.org/dist/v24.1.0/node-v24.1.0-linux-arm64.tar.xz": { + "type": "sha256", + "value": "ff5a3a68781794a473f59a727f35314723785eff6f48aaf983361fadf0eadf36" + }, "https://nodejs.org/dist/v24.1.0/node-v24.1.0-linux-x64.tar.xz": { "type": "sha256", "value": "76b77c43f97a7c4cf60917e24c5e212faaf8ca664e433759ef98d12f268b6b49" diff --git a/packages/nodejs/project.bri b/packages/nodejs/project.bri index f47d3950..8d5ebf66 100644 --- a/packages/nodejs/project.bri +++ b/packages/nodejs/project.bri @@ -8,6 +8,27 @@ export const project = { version: "24.1.0", }; +function nodejsPrebuilt(): std.Recipe { + switch (std.CURRENT_PLATFORM) { + case "x86_64-linux": + return Brioche.download( + `https://nodejs.org/dist/v${project.version}/node-v${project.version}-linux-x64.tar.xz`, + ) + .unarchive("tar", "xz") + .peel(); + case "aarch64-linux": + return Brioche.download( + `https://nodejs.org/dist/v${project.version}/node-v${project.version}-linux-arm64.tar.xz`, + ) + .unarchive("tar", "xz") + .peel(); + default: + throw new Error( + `The platform '${std.CURRENT_PLATFORM}' is currently not supported by this version of the nodejs package`, + ); + } +} + /** * The main Node.js recipe. Returns a recipe containing the following: * @@ -15,17 +36,13 @@ export const project = { * - `bin/npm` */ export default function nodejs(): std.Recipe { - let node = Brioche.download( - `https://nodejs.org/dist/v${project.version}/node-v${project.version}-linux-x64.tar.xz`, - ) - .unarchive("tar", "xz") - .peel(); - - node = std.autopack(node, { - globs: ["bin/**"], - }); - - return std.withRunnableLink(node, "bin/node"); + return nodejsPrebuilt() + .pipe((node) => + std.autopack(node, { + globs: ["bin/**"], + }), + ) + .pipe((node) => std.withRunnableLink(node, "bin/node")); } export async function test(): Promise> { From 55c972d7d459ca813f06189f204d124669e47487 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 15 Jun 2025 18:59:12 -0700 Subject: [PATCH 08/24] Update GitHub Actions workflow to build for x86_64 and aarch64 --- .github/workflows/_build.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index f1851b33..f3da16ae 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -9,9 +9,17 @@ on: jobs: build: - name: Build packages + name: Build packages [${{ matrix.host.platform }}] if: inputs.enabled - runs-on: brioche-dev-builder-runner + strategy: + matrix: + host: + - platform: x86_64-linux + runs-on: brioche-dev-builder-runner + - platform: aarch64-linux + runs-on: brioche-dev-builder-runner-aarch64 + + runs-on: ${{ matrix.host.runs-on }} timeout-minutes: 720 steps: - name: Install system packages @@ -24,9 +32,11 @@ jobs: - name: Install Brioche run: | mkdir -p ~/.local/bin - curl -L https://development-content.brioche.dev/github.com/brioche-dev/brioche/branches/main/x86_64-linux/brioche -o ~/.local/bin/brioche + curl -L https://development-content.brioche.dev/github.com/brioche-dev/brioche/branches/main/$PLATFORM/brioche -o ~/.local/bin/brioche chmod +x ~/.local/bin/brioche echo "$HOME/.local/bin" >> $GITHUB_PATH + env: + PLATFORM: ${{ matrix.host.platform }} - name: Build packages run: | From 6327bb696f3816d7a9bd367615ca9444404d2caa Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Thu, 19 Jun 2025 17:02:34 -0700 Subject: [PATCH 09/24] Update runtime utils --- packages/std/brioche.lock | 8 ++++---- packages/std/runtime_utils.bri | 4 ++-- packages/std/toolchain/utils.bri | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/std/brioche.lock b/packages/std/brioche.lock index 58b440ba..8b1e9633 100644 --- a/packages/std/brioche.lock +++ b/packages/std/brioche.lock @@ -13,13 +13,13 @@ "type": "sha256", "value": "0cabcd0a074e08ac132281f711f884777b47def17fbeff2a82ba011836b83d11" }, - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd": { + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd": { "type": "sha256", - "value": "9fd2d3fd6c114dd4c79cf794ca91a91da7a8be946b756346710a9b279cc7e3fa" + "value": "95666c447f182dc1356864c4188163764c6923b33bfe6b6a0e87b1d87668e25b" }, - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd": { + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd": { "type": "sha256", - "value": "ca2bdc7d2bb6184036e5a3b247935a25979d7ec5381dd5b94058a0a50cc6b870" + "value": "b025ca223f09130e86a5c7747bd4fb71ef1d03d785aea0a738a2bd35b0515450" }, "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_amd64_linux.tar.xz": { "type": "sha256", diff --git a/packages/std/runtime_utils.bri b/packages/std/runtime_utils.bri index e6df1449..adb81ad3 100644 --- a/packages/std/runtime_utils.bri +++ b/packages/std/runtime_utils.bri @@ -5,10 +5,10 @@ const PLATFORM_RUNTIME_UTILS: Record< std.Recipe | undefined > = { "x86_64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), "aarch64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), }; diff --git a/packages/std/toolchain/utils.bri b/packages/std/toolchain/utils.bri index 06918743..b31598b2 100644 --- a/packages/std/toolchain/utils.bri +++ b/packages/std/toolchain/utils.bri @@ -5,10 +5,10 @@ const PLATFORM_RUNTIME_UTILS: Record< std.Recipe | undefined > = { "x86_64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/x86_64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), "aarch64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/bd8af11dcd61855df38cc12401f5ddc4ff5466e0/aarch64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), }; From bf4894309f226d78e8bbcd184dccd160cff13e2f Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Thu, 19 Jun 2025 22:48:45 -0700 Subject: [PATCH 10/24] Update GH Actions build workflow to skip platforms based on magic comment --- .github/workflows/_build.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index f3da16ae..5467d76a 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -46,11 +46,16 @@ jobs: for package in "${packages[@]}"; do label="$package ($n / ${#packages[@]})" ((n++)) - echo "::group::$label" - brioche build -p "$package" --sync --locked --display plain-reduced - echo "::endgroup::" + if grep -q "@brioche-packages skip-platform $PLATFORM" "$package/project.bri"; then + echo "$label: skipping (does not support $PLATFORM)" + else + echo "::group::$label" + brioche build -p "$package" --sync --locked --display plain-reduced + echo "::endgroup::" + fi done env: + PLATFORM: ${{ matrix.host.platform }} BRIOCHE_REGISTRY_PASSWORD: ${{ secrets.BRIOCHE_REGISTRY_PASSWORD }} BRIOCHE_CACHE_URL: ${{ vars.BRIOCHE_CACHE_URL }} AWS_ACCESS_KEY_ID: ${{ secrets.CACHE_AWS_ACCESS_KEY_ID }} From 5b6c0332bc8565b93cf064af07005d57a236e087 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Thu, 19 Jun 2025 22:48:45 -0700 Subject: [PATCH 11/24] Disable build of `bugstalker` for aarch64 --- packages/bugstalker/project.bri | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/bugstalker/project.bri b/packages/bugstalker/project.bri index 826024a4..d20ccdb3 100644 --- a/packages/bugstalker/project.bri +++ b/packages/bugstalker/project.bri @@ -2,6 +2,8 @@ import * as std from "std"; import libunwind from "libunwind"; import { cargoBuild } from "rust"; +// Currently, BugStalker only support x86-64 Linux +// @brioche-packages skip-platform aarch64-linux export const project = { name: "bugstalker", version: "0.3.1", @@ -14,6 +16,11 @@ const source = Brioche.gitCheckout({ }); export default function bugstalker(): std.Recipe { + std.assert( + std.CURRENT_PLATFORM === "x86_64-linux", + `BugStalker does not currently support the platform '${std.CURRENT_PLATFORM}'`, + ); + return cargoBuild({ source, runnable: "bin/bs", From e406f64aa5088d7f6f5abd439c5cf196b60fc483 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Fri, 20 Jun 2025 00:58:05 -0700 Subject: [PATCH 12/24] Fix `gitui` build for aarch64-linux --- packages/gitui/project.bri | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/gitui/project.bri b/packages/gitui/project.bri index e57955e9..99c05775 100644 --- a/packages/gitui/project.bri +++ b/packages/gitui/project.bri @@ -12,7 +12,11 @@ export const project = { const source = Brioche.gitCheckout({ repository: project.repository, ref: `v${project.version}`, -}); +}) + // Remove upstream's custom Cargo `config.toml`, which overrides the linker + // for various targets (for cross-compilation). This can interfere with + // our default working linker configuration. + .remove(".cargo/config.toml"); export default function gitui(): std.Recipe { return cargoBuild({ From a335b6bc2d04f6d64eebdee00a8d053e88abc405 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Fri, 20 Jun 2025 14:20:32 -0700 Subject: [PATCH 13/24] Fix `linux` build on aarch64 by adding missing `python` dependency --- packages/linux/project.bri | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/linux/project.bri b/packages/linux/project.bri index 9c536383..9db7c836 100644 --- a/packages/linux/project.bri +++ b/packages/linux/project.bri @@ -1,6 +1,7 @@ import * as std from "std"; import kmod from "kmod"; import openssl from "openssl"; +import python from "python"; import nushell from "nushell"; export const project = { @@ -107,7 +108,14 @@ export default function linux( make modules_install ` .workDir(source) - .dependencies(...dependencies, openssl, kmod, ldWrapper, std.toolchain) + .dependencies( + ...dependencies, + kmod, + openssl, + python, + ldWrapper, + std.toolchain, + ) .env({ INSTALL_MOD_PATH: std.outputPath, From 3f849379ef73d585268098bdce8de28773702c31 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Fri, 20 Jun 2025 22:13:59 -0700 Subject: [PATCH 14/24] Adjust LLVM build parallelism for aarch64 --- packages/llvm/project.bri | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/llvm/project.bri b/packages/llvm/project.bri index 7f5327ba..242e2caf 100644 --- a/packages/llvm/project.bri +++ b/packages/llvm/project.bri @@ -22,7 +22,11 @@ export default function llvm(): std.Recipe { CMAKE_BUILD_TYPE: "Release", }, env: { - CMAKE_BUILD_PARALLEL_LEVEL: "16", + // HACK: Building LLVM can use A LOT of memory, especially when building + // in parallel. These values are tuned based on the CI runners currently + // in use in the `brioche-packages` repo. + CMAKE_BUILD_PARALLEL_LEVEL: + std.CURRENT_PLATFORM === "x86_64-linux" ? "16" : "8", }, dependencies: [std.toolchain, python], }).pipe((recipe) => From 4e2e383aef320e94bf081b164f28e05f0c72e789 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 21 Jun 2025 14:04:00 -0700 Subject: [PATCH 15/24] Fix `proot` build on aarch64 --- packages/proot/project.bri | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/proot/project.bri b/packages/proot/project.bri index 75bd900f..65b9e3bd 100644 --- a/packages/proot/project.bri +++ b/packages/proot/project.bri @@ -27,7 +27,19 @@ const source = std.recipe(() => { export default function proot(): std.Recipe { return std.runBash` - BRIOCHE_LD_AUTOPACK=false make -C src loader.elf loader-m32.elf build.h + case "$(uname -m)" in + x86_64) + BRIOCHE_LD_AUTOPACK=false make -C src loader.elf loader-m32.elf build.h + ;; + aarch64) + BRIOCHE_LD_AUTOPACK=false make -C src loader.elf build.h + ;; + *) + echo "Unhandled architecture for PRoot package" + exit 1 + ;; + esac + make -C src proot care make -C src install PREFIX="$BRIOCHE_OUTPUT" ` From 502476c7753a6bfad61f623f50905dc06aa76fb6 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 21 Jun 2025 14:04:00 -0700 Subject: [PATCH 16/24] Fix `strace` build on aarch64 --- packages/strace/project.bri | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/strace/project.bri b/packages/strace/project.bri index c8aba23b..cbe84ca5 100644 --- a/packages/strace/project.bri +++ b/packages/strace/project.bri @@ -14,7 +14,18 @@ const source = Brioche.download( export default function strace(): std.Recipe { return std.runBash` - ./configure --prefix=/ + case "$(uname -m)" in + aarch64) + # Disable multiple personality support for aarch64 for now + ./configure \\ + --prefix=/ \\ + --enable-mpers=no + ;; + *) + ./configure --prefix=/ + ;; + esac + make -j16 make install DESTDIR="$BRIOCHE_OUTPUT" ` From d6005b0e6953a294987a3b61efc2e43b63840cb5 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 21 Jun 2025 14:04:00 -0700 Subject: [PATCH 17/24] Update CI to continue build even if one platform fails --- .github/workflows/_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 5467d76a..d7ff7a6e 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -12,6 +12,7 @@ jobs: name: Build packages [${{ matrix.host.platform }}] if: inputs.enabled strategy: + fail-fast: false matrix: host: - platform: x86_64-linux From c57e9611746c0ccc865d7a78df9ccd090c2dd115 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 21 Jun 2025 19:04:50 -0700 Subject: [PATCH 18/24] Fix `xplr` build on aarch64 --- packages/xplr/project.bri | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/xplr/project.bri b/packages/xplr/project.bri index 9e381afa..32181f78 100644 --- a/packages/xplr/project.bri +++ b/packages/xplr/project.bri @@ -7,21 +7,22 @@ export const project = { repository: "https://github.com/sayanarijit/xplr.git", }; -const source = (() => { - let source = Brioche.gitCheckout({ - repository: project.repository, - ref: `v${project.version}`, - }); - +const source = Brioche.gitCheckout({ + repository: project.repository, + ref: `v${project.version}`, +}) + // Remove upstream's custom Cargo `config.toml`, which overrides the linker + // for various targets (for cross-compilation). This can interfere with + // our default working linker configuration. + .remove(".cargo/config.toml") // HACK: Workaround for https://github.com/LukeMathWalker/cargo-chef/issues/295#issuecomment-2619963413 - source = std.runBash` - sed -i "s|path = './benches/|path = 'benches/|g" "$BRIOCHE_OUTPUT/Cargo.toml" - ` - .outputScaffold(source) - .toDirectory(); - - return source; -})(); + .pipe((source) => + std.runBash` + sed -i "s|path = './benches/|path = 'benches/|g" "$BRIOCHE_OUTPUT/Cargo.toml" + ` + .outputScaffold(source) + .toDirectory(), + ); export default function xplr(): std.Recipe { return cargoBuild({ From ce42359e5330ae3011f4df1fbf89e7558a7e0825 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 21 Jun 2025 23:38:19 -0700 Subject: [PATCH 19/24] Update GH Actions workflow to skip tests too when platform is disabled --- .github/workflows/_build.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index d7ff7a6e..2b815848 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -76,9 +76,13 @@ jobs: ((n++)) if grep -q 'export.*test' "$package/project.bri"; then - echo "::group::$label" - brioche build -p "$package" -e test --sync --locked - echo "::endgroup::" + if grep -q "@brioche-packages skip-platform $PLATFORM" "$package/project.bri"; then + echo "$label: skipping (does not support $PLATFORM)" + else + echo "::group::$label" + brioche build -p "$package" -e test --sync --locked + echo "::endgroup::" + fi else echo "$label: no tests found" fi From 720ab1347822a869c3b0dcc8f42777c68b800cef Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 22 Jun 2025 01:40:03 -0700 Subject: [PATCH 20/24] Upgrade runtime utils --- packages/std/brioche.lock | 8 ++++---- packages/std/runtime_utils.bri | 4 ++-- packages/std/toolchain/utils.bri | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/std/brioche.lock b/packages/std/brioche.lock index 8b1e9633..6fee5a09 100644 --- a/packages/std/brioche.lock +++ b/packages/std/brioche.lock @@ -13,13 +13,13 @@ "type": "sha256", "value": "0cabcd0a074e08ac132281f711f884777b47def17fbeff2a82ba011836b83d11" }, - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd": { + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/aarch64-linux/brioche-runtime-utils.tar.zstd": { "type": "sha256", - "value": "95666c447f182dc1356864c4188163764c6923b33bfe6b6a0e87b1d87668e25b" + "value": "3a5aef8493d087ff42bc178c5f56a77867d11e2429556dfe6768257248fd74b6" }, - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd": { + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/x86_64-linux/brioche-runtime-utils.tar.zstd": { "type": "sha256", - "value": "b025ca223f09130e86a5c7747bd4fb71ef1d03d785aea0a738a2bd35b0515450" + "value": "1ea74d7c2ea1e806876bac4cc3c210f15197195f7c9a2943a2fced35d55a3c43" }, "https://development-content.brioche.dev/github.com/tangramdotdev/bootstrap/2022-10-31/busybox_amd64_linux.tar.xz": { "type": "sha256", diff --git a/packages/std/runtime_utils.bri b/packages/std/runtime_utils.bri index adb81ad3..61fe6c7a 100644 --- a/packages/std/runtime_utils.bri +++ b/packages/std/runtime_utils.bri @@ -5,10 +5,10 @@ const PLATFORM_RUNTIME_UTILS: Record< std.Recipe | undefined > = { "x86_64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/x86_64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), "aarch64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/aarch64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), }; diff --git a/packages/std/toolchain/utils.bri b/packages/std/toolchain/utils.bri index b31598b2..577cd024 100644 --- a/packages/std/toolchain/utils.bri +++ b/packages/std/toolchain/utils.bri @@ -5,10 +5,10 @@ const PLATFORM_RUNTIME_UTILS: Record< std.Recipe | undefined > = { "x86_64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/x86_64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/x86_64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), "aarch64-linux": Brioche.download( - "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/51a8c49dafca2ab1b91a80755eed03799c9cb10b/aarch64-linux/brioche-runtime-utils.tar.zstd", + "https://development-content.brioche.dev/github.com/brioche-dev/brioche-runtime-utils/commits/fa9ce0565ea067c84216838073c22176bb4a6399/aarch64-linux/brioche-runtime-utils.tar.zstd", ).unarchive("tar", "zstd"), }; From fe6edaabc6c34b7996dae2fa82b2d22913547011 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sun, 22 Jun 2025 19:43:16 -0700 Subject: [PATCH 21/24] Bump up GH Actions workflow timeout to 24 hours --- .github/workflows/_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 2b815848..7444d13e 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -21,7 +21,7 @@ jobs: runs-on: brioche-dev-builder-runner-aarch64 runs-on: ${{ matrix.host.runs-on }} - timeout-minutes: 720 + timeout-minutes: 1440 steps: - name: Install system packages run: | From a57cace1368dd05ae1ada7fdbee5fe4d4ee39d04 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 28 Jun 2025 01:45:21 -0700 Subject: [PATCH 22/24] Add "All builds passed" job This is intended to be used as a check requirement for PRs, similar to the "All tests passed" job from the main Brioche repo --- .github/workflows/_build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 7444d13e..9f800c95 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -125,3 +125,11 @@ jobs: brioche jobs logs "$process_event" fi fi + + # Extra job that succeeds when all build jobs succeed (useful for PR requirements) + all-builds-passed: + name: All builds passed + needs: [build] + runs-on: ubuntu-24.04 + steps: + - run: ':' From ac0d5bb5937b5a845943a972d4a41a502bc0a328 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 28 Jun 2025 01:49:13 -0700 Subject: [PATCH 23/24] Update "Show failed processes" to show all failed process event files --- .github/workflows/_build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 9f800c95..c16670e9 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -109,9 +109,10 @@ jobs: if: failure() run: | process_events=(~/.local/share/brioche/process-temp/*/events.bin.zst) - process_event="${process_events[0]}" - if [ -f "$process_event" ]; then + for process_event in "${process_events[@]}"; do + echo "::group::$process_event" + truncated_line_count="$(brioche jobs logs "$process_event" --limit 200 | wc -l)" if [ "$truncated_line_count" -gt 190 ]; then # Looks like the output might be long, so show the first 80 @@ -124,7 +125,9 @@ jobs: # Looks like the output might be short, so show the whole file brioche jobs logs "$process_event" fi - fi + + echo "::endgroup::" + done # Extra job that succeeds when all build jobs succeed (useful for PR requirements) all-builds-passed: From 76de683ff862ecd53f6a10415773b5b181a8a136 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 28 Jun 2025 01:50:27 -0700 Subject: [PATCH 24/24] Update "Show failed processes" to show more lines of output --- .github/workflows/_build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index c16670e9..116051be 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -114,13 +114,13 @@ jobs: echo "::group::$process_event" truncated_line_count="$(brioche jobs logs "$process_event" --limit 200 | wc -l)" - if [ "$truncated_line_count" -gt 190 ]; then - # Looks like the output might be long, so show the first 80 - # lines and the last 80 lines + if [ "$truncated_line_count" -gt 1200 ]; then + # Looks like the output might be long, so show the first 500 + # lines and the last 500 lines - brioche jobs logs "$process_event" --limit 80 | head -n80 + brioche jobs logs "$process_event" --limit 500 | head -n500 echo "..." - brioche jobs logs "$process_event" | tail -n80 + brioche jobs logs "$process_event" | tail -n500 else # Looks like the output might be short, so show the whole file brioche jobs logs "$process_event"