Skip to content

Commit 698b004

Browse files
dylan-conwayclaude
andauthored
Add step in CI to upload link metadata (#25448)
### What does this PR do? ### How did you verify your code works? --------- Co-authored-by: Claude <[email protected]>
1 parent b135c20 commit 698b004

File tree

4 files changed

+91
-21
lines changed

4 files changed

+91
-21
lines changed

cmake/targets/BuildBun.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,28 @@ set_target_properties(${bun} PROPERTIES LINK_DEPENDS ${BUN_SYMBOLS_PATH})
12001200

12011201
include(SetupWebKit)
12021202

1203+
if(BUN_LINK_ONLY)
1204+
register_command(
1205+
TARGET
1206+
${bun}
1207+
TARGET_PHASE
1208+
POST_BUILD
1209+
COMMENT
1210+
"Uploading link metadata"
1211+
COMMAND
1212+
${CMAKE_COMMAND} -E env
1213+
WEBKIT_DOWNLOAD_URL=${WEBKIT_DOWNLOAD_URL}
1214+
WEBKIT_VERSION=${WEBKIT_VERSION}
1215+
ZIG_COMMIT=${ZIG_COMMIT}
1216+
${BUN_EXECUTABLE} ${CWD}/scripts/create-link-metadata.mjs ${BUILD_PATH} ${bun}
1217+
SOURCES
1218+
${BUN_ZIG_OUTPUT}
1219+
${BUN_CPP_OUTPUT}
1220+
ARTIFACTS
1221+
${BUILD_PATH}/link-metadata.json
1222+
)
1223+
endif()
1224+
12031225
if(WIN32)
12041226
if(DEBUG)
12051227
target_link_libraries(${bun} PRIVATE

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly-2025-12-10"

scripts/bootstrap.sh

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# Version: 21
2+
# Version: 24
33

44
# A script that installs the dependencies needed to build and test Bun.
55
# This should work on macOS and Linux with a POSIX shell.
@@ -1155,23 +1155,22 @@ llvm_version() {
11551155
install_llvm() {
11561156
case "$pm" in
11571157
apt)
1158-
bash="$(require bash)"
1159-
llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")"
1160-
1161-
# Debian trixie and newer don't have their own LLVM apt repo, use unstable
1162-
llvm_codename_arg=""
1158+
# Debian 13 (Trixie) has LLVM 19 natively, and apt.llvm.org doesn't have a trixie repo
11631159
if [ "$distro" = "debian" ]; then
1164-
case "$VERSION_CODENAME" in
1165-
trixie|forky)
1166-
llvm_codename_arg="-n=unstable"
1167-
;;
1168-
esac
1169-
fi
1170-
1171-
execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all $llvm_codename_arg
1160+
install_packages \
1161+
"llvm-$(llvm_version)" \
1162+
"clang-$(llvm_version)" \
1163+
"lld-$(llvm_version)" \
1164+
"llvm-$(llvm_version)-dev" \
1165+
"llvm-$(llvm_version)-tools"
1166+
else
1167+
bash="$(require bash)"
1168+
llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")"
1169+
execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all
11721170

1173-
# Install llvm-symbolizer explicitly to ensure it's available for ASAN
1174-
install_packages "llvm-$(llvm_version)-tools"
1171+
# Install llvm-symbolizer explicitly to ensure it's available for ASAN
1172+
install_packages "llvm-$(llvm_version)-tools"
1173+
fi
11751174
;;
11761175
brew)
11771176
install_packages "llvm@$(llvm_version)"
@@ -1308,11 +1307,6 @@ install_sccache() {
13081307

13091308
install_rust() {
13101309
case "$distro" in
1311-
alpine)
1312-
install_packages \
1313-
rust \
1314-
cargo
1315-
;;
13161310
freebsd)
13171311
install_packages lang/rust
13181312
create_directory "$HOME/.cargo/bin"
@@ -1328,6 +1322,9 @@ install_rust() {
13281322
rustup_script=$(download_file "https://sh.rustup.rs")
13291323
execute "$sh" -lc "$rustup_script -y --no-modify-path"
13301324
append_to_path "$rust_home/bin"
1325+
1326+
# Ensure all rustup files are accessible (for CI builds where different users run builds)
1327+
grant_to_user "$rust_home"
13311328
;;
13321329
esac
13331330

scripts/create-link-metadata.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bun
2+
/**
3+
* Creates link-metadata.json with link command and build metadata
4+
*
5+
* Usage: bun scripts/create-link-metadata.mjs <build-path> <bun-target>
6+
*/
7+
8+
import { $ } from "bun";
9+
import { dirname, join } from "path";
10+
11+
const [buildPath, bunTarget] = process.argv.slice(2);
12+
13+
if (!buildPath || !bunTarget) {
14+
console.error("Usage: bun scripts/create-link-metadata.mjs <build-path> <bun-target>");
15+
process.exit(1);
16+
}
17+
18+
// Get the repo root (parent of scripts directory)
19+
const repoRoot = dirname(import.meta.dir);
20+
21+
// Extract link command using ninja
22+
console.log("Extracting link command...");
23+
const linkCommandResult = await $`ninja -C ${buildPath} -t commands ${bunTarget}`.quiet();
24+
const linkCommand = linkCommandResult.stdout.toString().trim();
25+
26+
// Read linker-related files from src/
27+
console.log("Reading linker files...");
28+
const linkerLds = await Bun.file(join(repoRoot, "src", "linker.lds")).text();
29+
const symbolsDyn = await Bun.file(join(repoRoot, "src", "symbols.dyn")).text();
30+
const symbolsTxt = await Bun.file(join(repoRoot, "src", "symbols.txt")).text();
31+
32+
// Create metadata JSON with link command included
33+
const metadata = {
34+
webkit_url: process.env.WEBKIT_DOWNLOAD_URL || "",
35+
webkit_version: process.env.WEBKIT_VERSION || "",
36+
zig_commit: process.env.ZIG_COMMIT || "",
37+
target: bunTarget,
38+
timestamp: new Date().toISOString(),
39+
link_command: linkCommand,
40+
linker_lds: linkerLds,
41+
symbols_dyn: symbolsDyn,
42+
symbols_txt: symbolsTxt,
43+
};
44+
45+
const metadataPath = join(buildPath, "link-metadata.json");
46+
await Bun.write(metadataPath, JSON.stringify(metadata, null, 2));
47+
console.log(`Written to ${metadataPath}`);
48+
49+
console.log("Done");

0 commit comments

Comments
 (0)