# genrule toolchain: the cargo-backed targets (cargo.bzl) still need this — # host/ and android/ themselves aren't buckified yet, so they still shell # out to pixi's own cargo/rustc directly; only the native rust_library/ # rust_binary graph under third-party/ (reindeer-vendored) uses the # hermetic toolchains below. # # rust + cxx toolchains: buck2-fetched and pinned, no pixi/system deps — # see rust_dist.bzl for the rustc/rust-std/clippy sysroot merge, and # @prelude//toolchains/cxx/zig for the zig-cc-based C/C++ toolchain (zig # bundles its own libc for a chosen glibc version, picked below to match # what conda's compiler packages targeted — see scripts/pixi-activate.sh's # __isoc23_sscanf comment for why that pin matters — and its own linker, # replacing pixi's mold). load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain") load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain") load("@prelude//toolchains/cxx/zig:defs.bzl", "download_zig_distribution") load(":conda_pkg.bzl", "conda_pkg") load(":cxx_zig_toolchain.bzl", "cxx_zig_toolchain") load(":rust.bzl", "hermetic_rust_toolchain") load(":rust_dist.bzl", "rust_dist_sysroot") system_genrule_toolchain( name = "genrule", visibility = ["PUBLIC"], ) # cxx_zig_toolchain.bzl's default for its internal `_target_filter` attr # needs a real target label to reference, not just a bare package-relative # path (that's only coercible from within a BUCK file, not a .bzl module). export_file( name = "zig_target_filter.sh", visibility = [], ) export_file( name = "zig_cc.sh", visibility = [], ) export_file( name = "sitecustomize.py", src = "python_compat/sitecustomize.py", visibility = [], ) genrule( name = "python-compat", srcs = [":sitecustomize.py"], out = "python-compat", cmd = "mkdir -p $OUT && cp $(location :sitecustomize.py) $OUT/sitecustomize.py", visibility = ["PUBLIC"], ) rust_dist_sysroot( name = "rust-sysroot", visibility = [], ) hermetic_rust_toolchain( name = "rust", sysroot = ":rust-sysroot", visibility = ["PUBLIC"], ) # rust rules' internal tooling (transitive_dependency_symlinks, etc.) needs # this — whatever python3 is on PATH is fine, it's only used for small # build-time helper scripts, not part of the actual toolchain output. system_python_bootstrap_toolchain( name = "python_bootstrap", visibility = ["PUBLIC"], ) http_archive( name = "zstd-src", urls = ["https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz"], sha256 = "eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3", strip_prefix = "zstd-1.5.7", ) # GNU tar delegates .tar.zst decoding to a `zstd` executable. Build that small # bootstrap tool from source so conda package extraction is hermetic on remote # workers instead of depending on the worker image's PATH. genrule( name = "zstd", srcs = [":zstd-src"], out = "zstd", cmd = "mkdir zstd-build && cp -R $(location :zstd-src)/. zstd-build/ && make -C zstd-build/programs -j2 zstd && cp zstd-build/programs/zstd $OUT", executable = True, visibility = ["PUBLIC"], ) download_zig_distribution( name = "zig-dist", version = "0.14.0", ) cxx_zig_toolchain( name = "cxx", distribution = ":zig-dist", # Matches conda-forge's cross-compiler packages' bundled glibc (2.28) — # zig statically bundles glibc-version-specific compat shims per # target, so this is the same trick conda-forge's compiler packages # use, just buck2-fetched instead of pixi-installed. visibility = ["PUBLIC"], ) # Native libs for -sys crates whose build.rs shells out to pkg-config # (alsa-sys, libspa-sys, pipewire-sys) — same conda-forge packages pixi.lock # already pins (see pixi.lock for the exact URLs/versions), just # buck2-fetched instead of pixi-installed. See conda_pkg.bzl for the # .conda unpacking + .pc placeholder-prefix rewrite. conda_pkg( name = "alsa-lib", url = "https://conda.anaconda.org/conda-forge/linux-64/alsa-lib-1.2.16.1-hb03c661_0.conda", sha256 = "cf93ca0f1f107e95a35969a4622684e08fcb8cf37f8cf4a1e9e424828386c921", visibility = ["PUBLIC"], ) # Bundles both libpipewire-0.3.pc and libspa-0.2.pc (libspa-sys needs the # latter) plus spa-0.2 headers — verified no separate libspa conda package # exists; pipewire's own package carries it all. conda_pkg( name = "pipewire", url = "https://conda.anaconda.org/conda-forge/linux-64/pipewire-1.6.8-h9c4946d_0.conda", sha256 = "280bee17c37030b0d694a41cc33e3ff43c5ddece750f16f89970b87ee1d0f227", visibility = ["PUBLIC"], ) # `pkg-config` itself — none of the buildscript_run actions have it on # PATH otherwise. conda's own bin/pkg-config is an activation-aware bash # wrapper around bin/pkg-config.bin that assembles PKG_CONFIG_LIBDIR from # ${CC} -print-sysroot and friends; we don't need any of that; the plain # ELF binary works standalone given a real PKG_CONFIG_PATH (see the # fixups.toml files under third-party/fixups/*-sys for how it's wired in). conda_pkg( name = "pkgconfig", url = "https://conda.anaconda.org/conda-forge/linux-64/pkg-config-0.29.2-h7c397b8_1011.conda", sha256 = "ff8d0023722ef5600850074a9bbf418be4d2ec78edbf4d5db45d9f0331f248e4", visibility = ["PUBLIC"], ) # libclang for bindgen (libspa-sys/pipewire-sys's build.rs). `libclang` is a # thin meta-package (just a symlink); the real payload is split across # libclang13 (libclang.so.13, matches clang-sys's `libclang.so.*` probe # pattern directly, no rename needed) and libllvm22 (libclang's own # libLLVM.so.22.1 dependency) — verified via ldd that every *other* # transitive dep of both (libstdc++, libz, libzstd, libxml2, libicuuc, # libicudata, libgcc_s, ...) already resolves from this machine's own # /usr/lib, so those two are the only conda packages actually needed. # libclang.so.13 carries `RPATH=$ORIGIN/:$ORIGIN/../lib` (verified via # readelf -d), so merging both packages' lib/ into one directory is enough # for the dynamic loader to find libLLVM.so.22.1 — no LD_LIBRARY_PATH. conda_pkg( name = "libclang13", url = "https://conda.anaconda.org/conda-forge/linux-64/libclang13-22.1.8-default_hd70ba2e_6.conda", sha256 = "8475136d3be6c2d16bdb801dcaf8769cb2ba372cad239c89ebd6a58912e14465", ) conda_pkg( name = "libllvm22", url = "https://conda.anaconda.org/conda-forge/linux-64/libllvm22-22.1.8-hf7376ad_1.conda", sha256 = "e9b5f301d6b001a9b8ce782157f56b75c92c4fbc9eba95dc6345c1139251d13b", ) conda_pkg( name = "libxml2", url = "https://api.anaconda.org/download/conda-forge/libxml2-16/2.14.6/linux-64/libxml2-16-2.14.6-hca6bf5a_3.conda", sha256 = "0e6821603d387ccb490dbf71b9ec8525e33a9daab0a48d0d59de74b83ba6d8e2", ) conda_pkg( name = "icu", url = "https://api.anaconda.org/download/conda-forge/icu/78.1/linux-64/icu-78.1-h33c6efd_0.conda", sha256 = "7d6463d0be5092b2ae8f2fad34dc84de83eab8bd44cc0d4be8931881c973c48f", ) conda_pkg( name = "libiconv", url = "https://conda.anaconda.org/conda-forge/linux-64/libiconv-1.18-h3b78370_2.conda", sha256 = "c467851a7312765447155e071752d7bf9bf44d610a5687e32706f480aad2833f", ) conda_pkg( name = "liblzma", url = "https://conda.anaconda.org/conda-forge/linux-64/liblzma-5.8.3-hb03c661_1.conda", sha256 = "9787df8c22a59c9a70d3e5a10db9ad663485e75e9ccc3f09bd092cb7b95e0dab", ) conda_pkg( name = "libzlib", url = "https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_3.conda", sha256 = "eb8a0db0aa570124f7d2a93d7c7f596e3390df5e047818d873baad32985fc736", ) # bindgen's dlopen'd libclang doesn't auto-detect its own resource-dir # (stdbool.h, stddef.h, ...) the way a real `clang` binary would — without # it, parsing any header that includes them fails ("fatal error: 'stdbool.h' # file not found"). This is the same package pixi.toml's `clang` + # pixi-activate.sh's clang-resource-dir discovery covered; we only need # lib/clang//include/ out of it, not the actual clang binary (zig cc # is our C compiler). conda_pkg( name = "clang-resource-dir", url = "https://conda.anaconda.org/conda-forge/linux-64/clang-22-22.1.8-default_hd70ba2e_6.conda", sha256 = "cd5a792ce357ba33957a63465f74d3b67aef22e340a969dbdde391e28854ddc4", visibility = ["PUBLIC"], ) genrule( name = "libclang", # No `srcs =` here on purpose: buck2 genrule's `srcs` stages each dep # into a shared `srcs/` dir keyed by its *default output's basename* # — both conda_pkg targets output a directory literally named "out" # (see conda_pkg.bzl), which collides. `$(location ...)` macros in # `cmd` create the dependency edge on their own, no `srcs` entry needed. out = "lib", cmd = "mkdir -p $OUT && for dep in $(location :libclang13) $(location :libllvm22) $(location :libxml2) $(location :icu) $(location :libiconv) $(location :liblzma) $(location :libzlib); do cp -RL $dep/lib/. $OUT/; done", visibility = ["PUBLIC"], )