buck2 icon indicating copy to clipboard operation
buck2 copied to clipboard

prelude: Support more cargo instructions in rust rules

Open jjl9807 opened this issue 5 months ago • 0 comments

Currently, the rust rules in Buck2's prelude only support a limited subset of cargo instructions, specifically:

  • cargo:rustc-cfg=...
  • cargo:rustc-env=...

However, cargo supports many more instructions that are commonly used in Rust build scripts to influence compilation behavior, such as:

  • cargo:rustc-link-lib=...
  • cargo:rustc-link-search=...
  • cargo:rustc-flags=...
  • ...

These instructions are essential for integrating with native dependencies (e.g., linking system libraries, setting include paths, or passing custom flags to the linker). Many Rust crates rely on them via cc, bindgen, or custom build logic.

Extending the rust rules to interpret and act on these additional cargo instructions would significantly improve compatibility with existing rust crates and reduce the effort required to write and maintain BUCK files for complex rust projects.

jjl9807 avatar Jul 16 '25 12:07 jjl9807