diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index 544fe0bd9f..5802a46133 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -1200,6 +1200,28 @@ set_target_properties(${bun} PROPERTIES LINK_DEPENDS ${BUN_SYMBOLS_PATH}) include(SetupWebKit) +if(BUN_LINK_ONLY) + register_command( + TARGET + ${bun} + TARGET_PHASE + POST_BUILD + COMMENT + "Uploading link metadata" + COMMAND + ${CMAKE_COMMAND} -E env + WEBKIT_DOWNLOAD_URL=${WEBKIT_DOWNLOAD_URL} + WEBKIT_VERSION=${WEBKIT_VERSION} + ZIG_COMMIT=${ZIG_COMMIT} + ${BUN_EXECUTABLE} ${CWD}/scripts/create-link-metadata.mjs ${BUILD_PATH} ${bun} + SOURCES + ${BUN_ZIG_OUTPUT} + ${BUN_CPP_OUTPUT} + ARTIFACTS + ${BUILD_PATH}/link-metadata.json + ) +endif() + if(WIN32) if(DEBUG) target_link_libraries(${bun} PRIVATE diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..cd0e2cbf07 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly-2025-12-10" \ No newline at end of file diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 8fb608a6a5..975a785dcf 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Version: 21 +# Version: 24 # A script that installs the dependencies needed to build and test Bun. # This should work on macOS and Linux with a POSIX shell. @@ -1155,23 +1155,22 @@ llvm_version() { install_llvm() { case "$pm" in apt) - bash="$(require bash)" - llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")" - - # Debian trixie and newer don't have their own LLVM apt repo, use unstable - llvm_codename_arg="" + # Debian 13 (Trixie) has LLVM 19 natively, and apt.llvm.org doesn't have a trixie repo if [ "$distro" = "debian" ]; then - case "$VERSION_CODENAME" in - trixie|forky) - llvm_codename_arg="-n=unstable" - ;; - esac + install_packages \ + "llvm-$(llvm_version)" \ + "clang-$(llvm_version)" \ + "lld-$(llvm_version)" \ + "llvm-$(llvm_version)-dev" \ + "llvm-$(llvm_version)-tools" + else + bash="$(require bash)" + llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")" + execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all + + # Install llvm-symbolizer explicitly to ensure it's available for ASAN + install_packages "llvm-$(llvm_version)-tools" fi - - execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all $llvm_codename_arg - - # Install llvm-symbolizer explicitly to ensure it's available for ASAN - install_packages "llvm-$(llvm_version)-tools" ;; brew) install_packages "llvm@$(llvm_version)" @@ -1308,11 +1307,6 @@ install_sccache() { install_rust() { case "$distro" in - alpine) - install_packages \ - rust \ - cargo - ;; freebsd) install_packages lang/rust create_directory "$HOME/.cargo/bin" @@ -1328,6 +1322,9 @@ install_rust() { rustup_script=$(download_file "https://sh.rustup.rs") execute "$sh" -lc "$rustup_script -y --no-modify-path" append_to_path "$rust_home/bin" + + # Ensure all rustup files are accessible (for CI builds where different users run builds) + grant_to_user "$rust_home" ;; esac diff --git a/scripts/create-link-metadata.mjs b/scripts/create-link-metadata.mjs new file mode 100644 index 0000000000..39042420d6 --- /dev/null +++ b/scripts/create-link-metadata.mjs @@ -0,0 +1,49 @@ +#!/usr/bin/env bun +/** + * Creates link-metadata.json with link command and build metadata + * + * Usage: bun scripts/create-link-metadata.mjs + */ + +import { $ } from "bun"; +import { dirname, join } from "path"; + +const [buildPath, bunTarget] = process.argv.slice(2); + +if (!buildPath || !bunTarget) { + console.error("Usage: bun scripts/create-link-metadata.mjs "); + process.exit(1); +} + +// Get the repo root (parent of scripts directory) +const repoRoot = dirname(import.meta.dir); + +// Extract link command using ninja +console.log("Extracting link command..."); +const linkCommandResult = await $`ninja -C ${buildPath} -t commands ${bunTarget}`.quiet(); +const linkCommand = linkCommandResult.stdout.toString().trim(); + +// Read linker-related files from src/ +console.log("Reading linker files..."); +const linkerLds = await Bun.file(join(repoRoot, "src", "linker.lds")).text(); +const symbolsDyn = await Bun.file(join(repoRoot, "src", "symbols.dyn")).text(); +const symbolsTxt = await Bun.file(join(repoRoot, "src", "symbols.txt")).text(); + +// Create metadata JSON with link command included +const metadata = { + webkit_url: process.env.WEBKIT_DOWNLOAD_URL || "", + webkit_version: process.env.WEBKIT_VERSION || "", + zig_commit: process.env.ZIG_COMMIT || "", + target: bunTarget, + timestamp: new Date().toISOString(), + link_command: linkCommand, + linker_lds: linkerLds, + symbols_dyn: symbolsDyn, + symbols_txt: symbolsTxt, +}; + +const metadataPath = join(buildPath, "link-metadata.json"); +await Bun.write(metadataPath, JSON.stringify(metadata, null, 2)); +console.log(`Written to ${metadataPath}`); + +console.log("Done");