Skip to content

Commit c4505b3

Browse files
bryan-minimalclaude
andcommitted
Add gn 0.2511 + bindgen 0.72.1 — chromium-from-source build prerequisites
The #681 spike (pkgmgr-rs) settled that a source-built chromium must use system toolchains on arm64 — every prebuilt in Google's official tarball (clang, rustc, bindgen, gn, node) is an x86-64 ELF. These are the two tools we didn't already package; esbuild/go/llvm/rust/ninja/python all exist at or above the distro-proven floors. gn: no upstream releases — its version IS the commit position (Gentoo's 0.<position> scheme; `gn --version` prints "2511 (7324363900cc)"). Source is a git-archive of that commit mirrored to gs:// because gitiles /+archive/ tarballs are generated on the fly and can't be sha256-pinned. The smoketest greps the pinned position out of --version so the no-.git fallback ("0 (UNKNOWN)") can never ship silently. Update-dark for now, declared in-file: no provenance category fits googlesource and repology's gn project is all-noscheme; follow-up is a curated NAME_KEYED_VERSION_CHECK reading the gitiles API. bindgen: 0.72.1 = exactly Gentoo's floor for chromium 151. libclang + clang resource headers are RUNTIME deps (bindgen dlopens libclang to parse headers) — subsetOf llvm. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 9a5c791 commit c4505b3

4 files changed

Lines changed: 187 additions & 0 deletions

File tree

packages/bindgen/build.ncl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
let { standaloneTest, subsetOf, Attrs, BuildSpec, Local, OutputBin, Source, Test, .. } = import "minimal.ncl" in
2+
let base = import "../base/build.ncl" in
3+
let rust = import "../rust/build.ncl" in
4+
let toolchain = import "../toolchain/build.ncl" in
5+
6+
let glibc = import "../glibc/build.ncl" in
7+
let gcc = import "../gcc/build.ncl" in
8+
let llvm = import "../llvm/build.ncl" in
9+
10+
# bindgen — generates Rust FFI bindings from C/C++ headers by driving
11+
# libclang. Packaged as a chromium-from-source build prerequisite
12+
# (pkgmgr-rs#681): chromium's gn wires `rust_bindgen_root` and the
13+
# official tarball's bundled bindgen is an x86-64-only prebuilt, so the
14+
# arm64 build needs a system one. 0.72.1 is exactly Gentoo's floor for
15+
# chromium 151.
16+
#
17+
# libclang is a RUNTIME dependency: bindgen dlopens libclang.so to parse
18+
# headers, and needs clang's resource headers (usr/lib/clang/<ver>/) for
19+
# builtin includes — both from the llvm package.
20+
let version = "0.72.1" in
21+
{
22+
name = "bindgen",
23+
build_deps = [
24+
{ file = "build.sh" } | Local,
25+
{
26+
url = "gs://minimal-staging-archives/rust-lang/rust-bindgen/v%{version}.tar.gz",
27+
sha256 = "4ffb17061b2d71f19c5062d2e17e64107248f484f9775c0b7d30a16a8238dfd1",
28+
extract = true,
29+
strip_prefix = "rust-bindgen-%{version}",
30+
} | Source,
31+
base,
32+
rust,
33+
toolchain,
34+
],
35+
runtime_deps = [
36+
glibc,
37+
subsetOf gcc ["libgcc"],
38+
subsetOf llvm ["libclang", "libs_clang"],
39+
],
40+
41+
cmd = "./build.sh",
42+
43+
outputs = {
44+
bindgen = { glob = "usr/bin/bindgen" } | OutputBin,
45+
},
46+
47+
attrs =
48+
{
49+
upstream_version = version,
50+
license_spdx = "BSD-3-Clause",
51+
source_provenance = {
52+
category = 'GithubRepo,
53+
owner = "rust-lang",
54+
repo = "rust-bindgen",
55+
},
56+
} | Attrs,
57+
58+
tests = {
59+
smoketest = standaloneTest "/bin/bindgen --version",
60+
},
61+
} | BuildSpec

packages/bindgen/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
export CC=gcc
5+
export LD=gcc
6+
export RUSTFLAGS="-C linker=gcc --remap-path-prefix=$(pwd)=/builddir --remap-path-prefix=$HOME/.cargo=/cargo"
7+
8+
# The workspace's CLI crate; the library crate is what other projects
9+
# vendor themselves.
10+
cargo build --release -p bindgen-cli
11+
12+
install -D -m 0755 target/release/bindgen "$OUTPUT_DIR/usr/bin/bindgen"

packages/gn/build.ncl

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
let { standaloneTest, subsetOf, Attrs, BuildSpec, Local, OutputBin, Source, Test, .. } = import "minimal.ncl" in
2+
let base = import "../base/build.ncl" in
3+
let python = import "../python/build.ncl" in
4+
let ninja = import "../ninja/build.ncl" in
5+
let toolchain = import "../toolchain/build.ncl" in
6+
7+
let glibc = import "../glibc/build.ncl" in
8+
let gcc = import "../gcc/build.ncl" in
9+
10+
# gn — Google's meta-build system generator (generates ninja files).
11+
# Packaged as a chromium-from-source build prerequisite (pkgmgr-rs#681):
12+
# the official chromium tarball ships only an x86-64 prebuilt gn, so the
13+
# arm64 build needs a system gn either way, and a package beats
14+
# re-bootstrapping it inside every chromium build.
15+
#
16+
# Versioning: upstream has NO releases or tags beyond `initial-commit`;
17+
# its version IS the commit position — `gn --version` prints
18+
# "<position> (<12-char sha>)", derived from `git describe`. We follow
19+
# Gentoo's scheme: version 0.<position>. Source is a `git archive` of
20+
# that commit mirrored to gs:// — gitiles' own /+archive/ tarballs are
21+
# generated on the fly and NOT byte-stable, so they can never be
22+
# sha256-pinned directly. Bumping = new archive from a newer commit,
23+
# update `version` here AND the position/sha pinned in build.sh.
24+
#
25+
# ⚠ Version-tracking: update-dark for now. Upstream is
26+
# gn.googlesource.com (no provenance category fits), and repology's
27+
# `gn` project is all-`noscheme` (each distro invents its own scheme:
28+
# dates, short hashes, positions) so `repology_project` would propose
29+
# garbage. The clean fix is a curated NAME_KEYED_VERSION_CHECK entry in
30+
# pkgmgr-rs reading the gitiles API for the latest commit position —
31+
# tracked as a follow-up on pkgmgr-rs#681.
32+
let version = "0.2511" in
33+
{
34+
name = "gn",
35+
build_deps = [
36+
{ file = "build.sh" } | Local,
37+
{
38+
url = "gs://minimal-staging-archives/gn/gn/%{version}.tar.gz",
39+
sha256 = "3e85ceeb08cdb563a5db995175f9e5173a337f7e0b4822078f514a0bb7c991bf",
40+
extract = true,
41+
strip_prefix = "gn-%{version}",
42+
} | Source,
43+
base,
44+
python,
45+
ninja,
46+
toolchain,
47+
],
48+
runtime_deps = [
49+
glibc,
50+
subsetOf gcc ["libstdcpp"],
51+
],
52+
53+
cmd = "./build.sh",
54+
55+
outputs = {
56+
gn = { glob = "usr/bin/gn" } | OutputBin,
57+
},
58+
59+
attrs =
60+
{
61+
upstream_version = version,
62+
license_spdx = "BSD-3-Clause",
63+
} | Attrs,
64+
65+
tests = {
66+
# Pins the version header wired in build.sh: `gn --version` must
67+
# print the pinned commit position, not 0 (UNKNOWN) — the tarball
68+
# has no .git, so a silent fallback would ship a gn that lies about
69+
# what it is.
70+
smoketest =
71+
{
72+
class = 'Standalone,
73+
test_deps = [base],
74+
cmds = [
75+
["/bin/bash", "-c", "/bin/gn --version | grep -q '^2511 '"],
76+
],
77+
} | Test,
78+
},
79+
} | BuildSpec

packages/gn/build.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
export CXX=g++
5+
export AR=ar
6+
export LD=g++
7+
# Reproducibility per AGENTS.md; gen.py appends env CFLAGS/CXXFLAGS/LDFLAGS
8+
# to its own flag set.
9+
export CXXFLAGS="-ffile-prefix-map=$(pwd)=/builddir -gno-record-gcc-switches"
10+
export LDFLAGS="-Wl,--build-id=none"
11+
12+
# gen.py derives the version header from `git describe`; a tarball has no
13+
# .git, so pin it here. MUST move in lockstep with `version` in build.ncl
14+
# (0.<NUM>) and the commit the mirrored archive was cut from — the
15+
# smoketest greps for the number.
16+
mkdir -p out
17+
cat > out/last_commit_position.h <<'EOF'
18+
// Generated by build/gen.py.
19+
20+
#ifndef OUT_LAST_COMMIT_POSITION_H_
21+
#define OUT_LAST_COMMIT_POSITION_H_
22+
23+
#define LAST_COMMIT_POSITION_NUM 2511
24+
#define LAST_COMMIT_POSITION "2511 (7324363900cc)"
25+
26+
#endif // OUT_LAST_COMMIT_POSITION_H_
27+
EOF
28+
29+
# --no-static-libstdc++: link the system libstdc++ (runtime_deps carries
30+
# gcc/libstdcpp) instead of gen.py's static default.
31+
python3 build/gen.py --no-last-commit-position --no-static-libstdc++ --allow-warnings
32+
ninja -C out gn
33+
34+
mkdir -p "$OUTPUT_DIR/usr/bin"
35+
install -m 0755 out/gn "$OUTPUT_DIR/usr/bin/"

0 commit comments

Comments
 (0)