Skip to content

Commit

Permalink
Strip RUST_BACKTTRACE and RUST_LIB_BACKTRACE before invoking buck2
Browse files Browse the repository at this point in the history
Summary:
Buck has a [known issue](https://github.com/facebook/buck2/blob/71da19b58242cb6ad9fd4b3d126ed6d20ae659bc/app/buck2_interpreter_for_build/src/attrs/coerce/attr_type/source.rs#L48) where the daemon becomes extremely slow if invoked with the `RUST_BACKTRACE` env variable set.

In ELP, we set the RUST_BACKTRACE variable while configuring logging. Later on, we invoke Buck during project loading.

While there's no evidence of Buck2 builds being particularly slow, we can be on the safe side and apply the same patch that Rust Analyzer applied, stripping those two environment variables before the Buck2 invocation.

Reviewed By: davidbarsky

Differential Revision: D61392415

fbshipit-source-id: 177e9ec79ef54f0bd3bf3dfe2a186e803a7b8589
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Aug 16, 2024
1 parent ca3a117 commit 1ae1007
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/project_model/src/buck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ impl BuckConfig {
static BUCK_GLOBAL_LOCK: Mutex<()> = Mutex::new(());
let guard = BUCK_GLOBAL_LOCK.lock();
let mut cmd = Command::new("buck2");
// buck2 doesn't handle the RUST_BACKTRACE option well and can become extremely
// slow. Until that is fixed ensure the option is not propagated to buck2.
cmd.env_remove("RUST_BACKTRACE")
.env_remove("RUST_LIB_BACKTRACE");
cmd.arg("--isolation-dir");
cmd.arg("lsp");
cmd.current_dir(self.buck_root());
Expand Down

0 comments on commit 1ae1007

Please sign in to comment.