Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
2.2 kB · 49 lines
at buck2-port
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950load("//buck/rules:cc.bzl", "cc_binary")load("//buck/rules:rust.bzl", "rust_binary")# wrapgen: writes the Mach-O stub that lets a Darwin program call into a HOST ELF library.## Cider reaches host libraries (fuse, X11, the ffmpeg family) through libelfloader, and the guest# side of that bridge is a generated stub dylib per host library: elf_wrapper() in# buck/rules/codegen.bzl runs this tool over the ELF dynamic symbol table at BUILD TIME (it# dlopen()s the real .so while it runs) and emits a Mach-O whose every export forwards through# libelfloader. So this is a build-time HOST tool, not something that ships.## THE RUST ONE IS THE BUILD TOOL (#76). The three consumers name //src/linux/libelfloader:wrapgen and# get this; nothing had to change at those call sites. Gated on generated output rather than on# behaviour: all 22 libraries the consumers feed it come out byte identical in the .c, the vars# .h, stdout, stderr and exit code, as do five error paths.rust_binary( name = "wrapgen", crate_root = "wrapgen/wrapgen.rs", deps = ["//vendor/rust:libc"], visibility = ["PUBLIC"],)# The C++ original stays beside it as wrapgen_c, the arrangement getuuid_c and elfdep_c already# have, and for the same reason: scripts/buck-hosttools-parity.nu needs both binaries present to# compare them, so deleting this would delete the check.## A single translation unit against host headers only (elf.h, link.h, dlfcn.h), linked with the# C++ driver and -ldl, exactly as the reference does.# buck-registry: src/libelfloader/wrapgen/wrapgen = wrapgen_c## Same reason as PlistBuddy_c: #76 gave the canonical name to the Rust rewrite, and the artifact# the REFERENCE build produced comes from wrapgen.cpp, which is this target.cc_binary( name = "wrapgen_c", srcs = ["wrapgen/wrapgen.cpp"], compiler_flags = [ "-DDARLING", "-Wno-error=implicit-function-declaration", "-Wno-nullability-completeness", "-Wno-deprecated-declarations", "-Wno-availability", "-Wno-expansion-to-defined", "-Wno-elaborated-enum-base", "-Wno-undef-prefix", ], link_cxx = True, linker_flags = ["-ldl"], visibility = ["PUBLIC"],)