nandi/jolt-nativepublic Fork 0
5a37b4b044d0c02bb0e22fdb43377b5700f17800
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

BUCK · 97 lines · 4.3 KBPython Blame HistoryRaw
Make the C toolchain a dependency too, so zig travels with the action 6391496 nandi 19d ago1load(":defs.bzl", "hermetic_cxx_toolchain", "hermetic_rust_toolchain")
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago2load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
3load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain")
4
5# Tools come from the DotSlash files in scripts/, so the build depends on
Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago6# pinned upstream releases rather than whatever the host happens to have.
7#
8# The paths are absolute, and read out of .buckconfig.local rather than written
9# here, because neither of the obvious spellings works. A build script runs in
10# a directory of its own, and the prelude re-execs the compiler from there, so
11# a project-relative `scripts/zcc` is not found; and the shim that does the
12# re-exec calls os.execl rather than os.execlp, so a bare `zcc` on PATH is not
13# found either. aws-lc-sys is where both show up. The `buck` recipe in justfile
14# writes that file, so the absolute paths are generated rather than committed.
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago15#
16# rustc does not come this way any more — see the toolchain at the bottom of
17# this file. These three are what is left to make into dependencies.
Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago18_SCRIPTS = read_root_config("jolt", "scripts", "scripts")
19
20# The compiler's version, written by the `buck` recipe alongside the paths.
21#
22# It has to reach the actions somehow, because the prelude names rustc as the
23# bare string "rustc" — the binary is not an input, so its identity is not in
24# any action's cache digest. Two compilers therefore produce artifacts under
25# the same digest, and a shared cache will hand one build the other's rlibs;
26# the failure is E0514, a long way from the cause. Naming the version in a cfg
27# nothing reads is enough to keep the digests apart.
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago28# The C toolchain's version, written by the `buck` recipe alongside the paths.
29#
30# rustc no longer needs this: it is a dependency now, so its identity is in
31# every action's digest and two compilers cannot collide on one cache entry.
32# zig still does. It is named by an absolute path that does not change when the
33# binary behind it does, so a version bump would silently reuse entries built
34# by the old one — the E0514 failure, one toolchain over. Naming the version in
35# a cfg nothing reads keeps the digests apart until zig is a dependency too.
36_ZIG_VERSION = read_root_config("jolt", "zig_version", "unknown")
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago37#
38# This is the same arrangement .cargo/config.toml used to describe: zig cc
39# carries its own glibc sysroot, which is why this repo builds on a machine
40# with no `cc` at all. Unlike vidya there is no Android row here — both shared
41# objects this repo ships are desktop, and the APK takes its libvidya from
42# vidya's own buck2 build.
Make the C toolchain a dependency too, so zig travels with the action 6391496 nandi 19d ago43hermetic_cxx_toolchain(
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago44 name = "cxx",
Make the C toolchain a dependency too, so zig travels with the action 6391496 nandi 19d ago45 dist = "toolchains//dist:zig",
46 wrapper = "toolchains//:zcc.sh",
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago47 visibility = ["PUBLIC"],
48)
49
50system_genrule_toolchain(
51 name = "genrule",
52 visibility = ["PUBLIC"],
53)
54
55system_python_bootstrap_toolchain(
56 name = "python_bootstrap",
57 visibility = ["PUBLIC"],
58)
59
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago60# The compiler is the dist tarball in toolchains//dist, not a name resolved
61# against the machine. See defs.bzl for why that distinction is the whole
62# point, and dist.bzl for where the tarball comes from.
63hermetic_rust_toolchain(
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago64 name = "rust",
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago65 dist = "toolchains//dist:rust",
66 wrapper = "toolchains//:rustc.sh",
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago67 default_edition = "2021",
Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago68 rustc_flags = [
69 "-Clinker=" + _SCRIPTS + "/zcc",
70 # What [profile.release] in Cargo.toml says, and for the reason given
71 # there: the tree walk and the texture uploads are hot every frame, and
72 # the media plane decodes H.264. buck2 optimises nothing by default, so
73 # without this the two objects are debug builds wearing release names.
74 # OPT_LEVEL=2 in the buildscript fixups is the same setting for the C.
75 "-Copt-level=2",
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago76 "--cfg=jolt_cc=\"" + _ZIG_VERSION + "\"",
Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago77 ],
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago78 # A plain string rather than a select: the sysroot path inside the dist
79 # tarball is built from this, and only the triples dist.bzl fetches an
80 # archive for can be named here.
81 rustc_target_triple = "x86_64-unknown-linux-gnu",
82 visibility = ["PUBLIC"],
83)
84
85# The wrapper the Rust toolchain runs rustc through, as an artifact so it is an
86# input to every action that compiles anything.
Make the C toolchain a dependency too, so zig travels with the action 6391496 nandi 19d ago87export_file(
88 name = "zcc.sh",
89 mode = "reference",
90 visibility = ["PUBLIC"],
91)
92
Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago93export_file(
94 name = "rustc.sh",
95 mode = "reference",
Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago96 visibility = ["PUBLIC"],
97)