nandi/jolt-nativepublic Fork 0
600f207e2f91fc746a6545b141494a260e410f60
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.

Build both objects under buck2, against the BuildBuddy cache 600f207 · on 600f207e2f91fc746a6545b141494a260e410f60 · nandi · 19d ago
BUCK · 79 lines · 3.4 KBPython Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain")
load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain")
load("@prelude//toolchains:rust.bzl", "system_rust_toolchain")

# Tools come from the DotSlash files in scripts/, so the build depends on
# pinned upstream releases rather than whatever the host happens to have.
#
# The paths are absolute, and read out of .buckconfig.local rather than written
# here, because neither of the obvious spellings works. A build script runs in
# a directory of its own, and the prelude re-execs the compiler from there, so
# a project-relative `scripts/zcc` is not found; and the shim that does the
# re-exec calls os.execl rather than os.execlp, so a bare `zcc` on PATH is not
# found either. aws-lc-sys is where both show up. The `buck` recipe in justfile
# writes that file, so the absolute paths are generated rather than committed.
_SCRIPTS = read_root_config("jolt", "scripts", "scripts")

# The compiler's version, written by the `buck` recipe alongside the paths.
#
# It has to reach the actions somehow, because the prelude names rustc as the
# bare string "rustc" — the binary is not an input, so its identity is not in
# any action's cache digest. Two compilers therefore produce artifacts under
# the same digest, and a shared cache will hand one build the other's rlibs;
# the failure is E0514, a long way from the cause. Naming the version in a cfg
# nothing reads is enough to keep the digests apart.
_RUSTC_VERSION = read_root_config("jolt", "rustc_version", "unknown")
#
# This is the same arrangement .cargo/config.toml used to describe: zig cc
# carries its own glibc sysroot, which is why this repo builds on a machine
# with no `cc` at all. Unlike vidya there is no Android row here — both shared
# objects this repo ships are desktop, and the APK takes its libvidya from
# vidya's own buck2 build.
system_cxx_toolchain(
    name = "cxx",
    # `ar` would otherwise come off the host, which is the one thing this
    # toolchain is arranged not to do.
    archiver = _SCRIPTS + "/zar",
    compiler = _SCRIPTS + "/zcc",
    compiler_type = "clang",
    cxx_compiler = _SCRIPTS + "/zxx",
    linker = _SCRIPTS + "/zcc",
    visibility = ["PUBLIC"],
)

system_genrule_toolchain(
    name = "genrule",
    visibility = ["PUBLIC"],
)

system_python_bootstrap_toolchain(
    name = "python_bootstrap",
    visibility = ["PUBLIC"],
)

system_rust_toolchain(
    name = "rust",
    default_edition = "2021",
    rustc_flags = [
        "-Clinker=" + _SCRIPTS + "/zcc",
        # What [profile.release] in Cargo.toml says, and for the reason given
        # there: the tree walk and the texture uploads are hot every frame, and
        # the media plane decodes H.264. buck2 optimises nothing by default, so
        # without this the two objects are debug builds wearing release names.
        # OPT_LEVEL=2 in the buildscript fixups is the same setting for the C.
        "-Copt-level=2",
        "--cfg=jolt_rustc=\"" + _RUSTC_VERSION + "\"",
    ],
    rustc_target_triple = select({
        "prelude//os:linux": select({
            "prelude//cpu:arm64": "aarch64-unknown-linux-gnu",
            "prelude//cpu:x86_64": "x86_64-unknown-linux-gnu",
        }),
        "prelude//os:macos": select({
            "prelude//cpu:arm64": "aarch64-apple-darwin",
            "prelude//cpu:x86_64": "x86_64-apple-darwin",
        }),
    }),
    visibility = ["PUBLIC"],
)