| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 1 | load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") |
| 2 | load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain") |
| 3 | load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain") |
| 4 | load("@prelude//toolchains:rust.bzl", "system_rust_toolchain") |
| 5 | |
| 6 | # 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 ago | 7 | # pinned upstream releases rather than whatever the host happens to have. |
| 8 | # |
| 9 | # The paths are absolute, and read out of .buckconfig.local rather than written |
| 10 | # here, because neither of the obvious spellings works. A build script runs in |
| 11 | # a directory of its own, and the prelude re-execs the compiler from there, so |
| 12 | # a project-relative `scripts/zcc` is not found; and the shim that does the |
| 13 | # re-exec calls os.execl rather than os.execlp, so a bare `zcc` on PATH is not |
| 14 | # found either. aws-lc-sys is where both show up. The `buck` recipe in justfile |
| 15 | # writes that file, so the absolute paths are generated rather than committed. |
| 16 | _SCRIPTS = read_root_config("jolt", "scripts", "scripts") |
| 17 | |
| 18 | # The compiler's version, written by the `buck` recipe alongside the paths. |
| 19 | # |
| 20 | # It has to reach the actions somehow, because the prelude names rustc as the |
| 21 | # bare string "rustc" — the binary is not an input, so its identity is not in |
| 22 | # any action's cache digest. Two compilers therefore produce artifacts under |
| 23 | # the same digest, and a shared cache will hand one build the other's rlibs; |
| 24 | # the failure is E0514, a long way from the cause. Naming the version in a cfg |
| 25 | # nothing reads is enough to keep the digests apart. |
| 26 | _RUSTC_VERSION = read_root_config("jolt", "rustc_version", "unknown") |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 27 | # |
| 28 | # This is the same arrangement .cargo/config.toml used to describe: zig cc |
| 29 | # carries its own glibc sysroot, which is why this repo builds on a machine |
| 30 | # with no `cc` at all. Unlike vidya there is no Android row here — both shared |
| 31 | # objects this repo ships are desktop, and the APK takes its libvidya from |
| 32 | # vidya's own buck2 build. |
| 33 | system_cxx_toolchain( |
| 34 | name = "cxx", |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 35 | # `ar` would otherwise come off the host, which is the one thing this |
| 36 | # toolchain is arranged not to do. |
| 37 | archiver = _SCRIPTS + "/zar", |
| 38 | compiler = _SCRIPTS + "/zcc", |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 39 | compiler_type = "clang", |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 40 | cxx_compiler = _SCRIPTS + "/zxx", |
| 41 | linker = _SCRIPTS + "/zcc", |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 42 | visibility = ["PUBLIC"], |
| 43 | ) |
| 44 | |
| 45 | system_genrule_toolchain( |
| 46 | name = "genrule", |
| 47 | visibility = ["PUBLIC"], |
| 48 | ) |
| 49 | |
| 50 | system_python_bootstrap_toolchain( |
| 51 | name = "python_bootstrap", |
| 52 | visibility = ["PUBLIC"], |
| 53 | ) |
| 54 | |
| 55 | system_rust_toolchain( |
| 56 | name = "rust", |
| 57 | default_edition = "2021", |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 58 | rustc_flags = [ |
| 59 | "-Clinker=" + _SCRIPTS + "/zcc", |
| 60 | # What [profile.release] in Cargo.toml says, and for the reason given |
| 61 | # there: the tree walk and the texture uploads are hot every frame, and |
| 62 | # the media plane decodes H.264. buck2 optimises nothing by default, so |
| 63 | # without this the two objects are debug builds wearing release names. |
| 64 | # OPT_LEVEL=2 in the buildscript fixups is the same setting for the C. |
| 65 | "-Copt-level=2", |
| 66 | "--cfg=jolt_rustc=\"" + _RUSTC_VERSION + "\"", |
| 67 | ], |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 68 | rustc_target_triple = select({ |
| 69 | "prelude//os:linux": select({ |
| 70 | "prelude//cpu:arm64": "aarch64-unknown-linux-gnu", |
| 71 | "prelude//cpu:x86_64": "x86_64-unknown-linux-gnu", |
| 72 | }), |
| 73 | "prelude//os:macos": select({ |
| 74 | "prelude//cpu:arm64": "aarch64-apple-darwin", |
| 75 | "prelude//cpu:x86_64": "x86_64-apple-darwin", |
| 76 | }), |
| 77 | }), |
| 78 | visibility = ["PUBLIC"], |
| 79 | ) |