Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2765bc9
feat: support configuring the manifold URL
lf- May 28, 2025
b2b16d8
`//A/B/C` is a valid name for `//A/B/C:C`
9999years Apr 28, 2025
e73f56c
test output flag patch
josephsumabat Mar 11, 2026
0c40b53
test caching dice patch
josephsumabat Mar 11, 2026
331d8c7
UX: warn on misuse of include/exclude
josephsumabat Mar 11, 2026
6231a9f
Allow BXLs to aquery actions directly; used for action debugging.
josephsumabat Mar 11, 2026
aa71644
Allow BXLs to make atarget_set. For symmetry with the other target se…
josephsumabat Mar 11, 2026
eaebab5
bug fix for https://linear.app/mercury/issue/DUX-4404/error-during-pr…
josephsumabat Mar 11, 2026
b5def92
remote_execution: Retry BatchReadBlobs requests
josephsumabat Mar 11, 2026
974bc41
Disable cell segmentation indiscriminately as a workaround.
josephsumabat Mar 11, 2026
628367c
RPC retry and timeout improvements for remote execution
josephsumabat Mar 11, 2026
89deb83
More semaphores for grpc
josephsumabat Mar 11, 2026
d3c7943
Add contribution guidelines
josephsumabat Mar 25, 2026
067b67f
Fix regression after DirectIoExecutor by default on macOS (#4)
wavewave Apr 3, 2026
f31d8a7
Use fork patches for hyper and tonic
josephsumabat Apr 14, 2026
eebc1b0
Improve reliability and observability of remote exeution gRPC client …
avdv Apr 17, 2026
3e9e553
buck2_external_cells: Don't inherit Git environment variables
9999years Jun 10, 2026
9fb4f3a
buck2_server: Implement Git revision data (#15)
9999years Jun 29, 2026
41e30f2
buck2_events: Add OpenTelemetry `EventSink` (#14)
9999years Jul 2, 2026
a5cf021
Stop doing a tset projection walk in write_json validation (#16)
csamak Jul 6, 2026
df68890
DUX-5483 Cargo.toml: opentelemetry-otlp: Add reqwest-rustls (#17)
9999years Jul 6, 2026
5ada3fb
DUX-5497 OpenTelemetry: Respect `$TRACEPARENT` and similar (#18)
9999years Jul 6, 2026
fe47b62
GHA: Fix CI (#21)
9999years Jul 7, 2026
4c819e9
buck2_core: Use patched opentelemetry-sdk for percent-decoding (#20)
9999years Jul 8, 2026
47423b2
GHA: build-and-test: Don't run on `mercury-head` (#23)
9999years Jul 8, 2026
06a7233
DUX-5509 re_grpc: request zstd-compressed `BatchReadBlobs` responses …
9999years Jul 9, 2026
02bfd31
DUX-5510 re_grpc: zstd-compress large `BatchUpdateBlobs` blobs (#26)
9999years Jul 9, 2026
780ef13
Fix clang-specific cc/cxx invocations in cargo_buildscript
hdgarrood Jul 14, 2026
d58a734
buck2_test: add an allowlist for env-vars in buckconfig
lf- Jul 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: 16.4.0
xcode-version: latest-stable
- uses: actions/checkout@v6
- uses: ./.github/actions/setup_macos_env
- uses: ./.github/actions/init_opam
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- uses: ./.github/actions/setup_reindeer
- uses: ./.github/actions/build_bootstrap
windows-build-examples:
runs-on: windows-8-core
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup_windows_env
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Build and test
on:
push:
branches:
- mercury-head
pull_request:
workflow_dispatch: # allows manual triggering
jobs:
linux-build-and-test:
runs-on: 4-core-ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup_linux_env
Expand All @@ -16,13 +18,13 @@ jobs:
steps:
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: 16.4.0
xcode-version: latest-stable
- uses: actions/checkout@v6
- uses: ./.github/actions/setup_macos_env
- uses: ./.github/actions/build_debug
- uses: ./.github/actions/run_test_py
windows-build-and-test:
runs-on: windows-8-core
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup_windows_env
Expand Down
23 changes: 18 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ http-body-util = "0.1.0"
httparse = "1.7.1"
httptest = "0.16"
humantime = "2.1"
hyper = { version = "1.8.1", features = ["client", "http1", "http2"] }
hyper = { version = "1.9", features = ["client", "http1", "http2"] }
hyper-http-proxy = "1.0"
hyper-rustls = { version = "0.27.0", features = ["http2"] }
hyper-timeout = "0.5"
Expand Down Expand Up @@ -259,6 +259,13 @@ num_cpus = "1.16"
num_enum = "0.7.4"
object = "0.36.7"
once_cell = "1.21"
# See:
# - https://github.com/open-telemetry/opentelemetry-rust/pull/3586
# - https://github.com/open-telemetry/opentelemetry-rust/pull/3587
opentelemetry = { version = "0.32.0", git = "https://github.com/MercuryTechnologies/opentelemetry-rust.git", branch = "mercury-head", features = ["experimental_propagation_env_carrier"] }
opentelemetry-otlp = { version = "0.32.0", git = "https://github.com/MercuryTechnologies/opentelemetry-rust.git", branch = "mercury-head", default-features = false, features = ["trace", "http-proto", "reqwest-blocking-client", "reqwest-rustls"] }
opentelemetry-semantic-conventions = { version = "0.32.0", git = "https://github.com/MercuryTechnologies/opentelemetry-rust.git", branch = "mercury-head", features = ["semconv_experimental"] }
opentelemetry_sdk = { version = "0.32.1", git = "https://github.com/MercuryTechnologies/opentelemetry-rust.git", branch = "mercury-head" }
os_str_bytes = { version = "6.6.0", features = ["conversions"] }
parking_lot = { version = "0.12.1", features = ["send_guard"] }
paste = "1.0.15"
Expand All @@ -271,10 +278,10 @@ postcard = { version = "1.0.8", features = ["use-crc", "use-std"] }
pretty_assertions = "1.2.1"
probminhash = { git = "https://github.com/krallin/probminhash", rev = "3d6b7a5315305c2893a7a04e0de9e23b305992c5", default-features = false } # WAITING_FOR_PR https://github.com/jean-pierreBoth/probminhash/pull/4
proc-macro2 = "1.0.106"
prost = "0.14.3"
prost-build = "0.14.3"
prost-derive = "0.14.3"
prost-types = "0.14.3"
prost = "0.14"
prost-build = "0.14"
prost-derive = "0.14"
prost-types = "0.14"
protoc-bin-vendored = "3.0.0"
psutil = "3.2"
quick-xml = { version = "0.37", features = ["overlapped-lists", "serialize"] }
Expand Down Expand Up @@ -510,3 +517,9 @@ incremental = true
# Base on the comment in https://github.com/jimblandy/perf-event/pull/53, we will no long need this patch in future.
perf-event = { git = "https://github.com/Nero5023/perf-event.git", rev = "6dae86b6d4807acec081e6dc0a53167f57f8c0f4", version = "0.4" }
perf-event-open-sys = { git = "https://github.com/Nero5023/perf-event.git", rev = "6dae86b6d4807acec081e6dc0a53167f57f8c0f4", version = "5.0" }
hyper = { git = "https://github.com/arianvp/hyper.git", branch = "push-ktssyytnyrru" }
tonic = { git = "https://github.com/edef1c/tonic.git", branch = "push-rosuyzxnysvw" }
tonic-health = { git = "https://github.com/edef1c/tonic.git", branch = "push-rosuyzxnysvw" }
tonic-reflection = { git = "https://github.com/edef1c/tonic.git", branch = "push-rosuyzxnysvw" }
tonic-prost = { git = "https://github.com/edef1c/tonic.git", branch = "push-rosuyzxnysvw" }
tonic-prost-build = { git = "https://github.com/edef1c/tonic.git", branch = "push-rosuyzxnysvw" }
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing to Mercury's Buck2 fork (mercury-head)

This repo is Mercury's internal fork of [Buck2](https://github.com/facebook/buck2). The `mercury-head` branch is our maintained head.

## Workflow

### 1. Branch from mercury-head

```bash
git fetch origin
git checkout -b my-feature origin/mercury-head
```

### 2. Make a PR to mercury-head

Open a pull request targeting the `mercury-head` branch (not `main`).

### 3. After merging, create a tag

Once your PR is merged, tag the new `mercury-head` HEAD using the format:

```
mwb-<date>-base-<fb-base-tag>
```

Where:
- `<date>` is today's date in `YYYY-MM-DD` format
- `<fb-base-tag>` is the date tag of the FB upstream commit that `mercury` is currently based on (e.g. `2026-01-19`)

Example:

```bash
# Find the current mercury HEAD
git fetch origin
git rev-parse origin/mercury-head

# Create and push the tag
git tag mwb-2026-03-25-base-2026-01-19 origin/mercury
git push origin mwb-2026-03-25-base-2026-01-19
```

To find the correct `<fb-base-tag>`: look at the FB upstream tags in this repo (e.g. `2026-01-19`, `2026-03-15`) and identify which one the current `mercury-head` branch is based on.

### 4. Update buck2-source in mwb

In the [mercury-web-backend](https://github.com/MercuryTechnologies/mercury-web-backend) repo, update the `buck2-source` reference to point to your new tag.
17 changes: 17 additions & 0 deletions app/buck2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,23 @@ impl CommandKind {
recorder.update_for_client_ctx(&command_ctx, self.command_name());
}

// Build the client's OTLP exporter now. The client process emits the invocation record (and,
// when `tracing`-span export is enabled, the bulk of the spans), and unlike the daemon it
// never `fork()`s without an immediate `exec()`, so it is safe to spawn the exporter's
// background threads here. Only the client activates today; a future daemon exporter would
// have to activate separately, after daemonizing. Skip the forking helpers, which fork+exec
// constantly and have nothing to export.
#[cfg(not(client_only))]
let enable_telemetry = !matches!(
self,
CommandKind::Forkserver(..) | CommandKind::InternalTestRunner(..)
);
#[cfg(client_only)]
let enable_telemetry = true;
if enable_telemetry {
buck2_core::logging::otel::activate(BuckVersion::get_version_for_clap());
}

match self {
#[cfg(not(client_only))]
CommandKind::Daemon(..) => unreachable!("Checked earlier"),
Expand Down
9 changes: 8 additions & 1 deletion app/buck2_build_api/src/actions/impls/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ impl<'a, 'v> Serialize for SerializeValue<'a, 'v> {
}
JsonUnpack::Enum(x) => x.serialize(serializer),
JsonUnpack::TransitiveSetJsonProjection(x) => {
serializer.collect_seq(err(x.iter_values())?.map(|v| self.with_value(v)))
match self.fs {
// Skip validation when fs == None because it can be expensive.
// TransitiveSet::new already did validate_json for projected values.
None => serializer.collect_seq(std::iter::empty::<u8>()),
Some(_) => {
serializer.collect_seq(err(x.iter_values())?.map(|v| self.with_value(v)))
}
}
}
JsonUnpack::TargetLabel(x) => {
// Users could do this with `str(ctx.label.raw_target())`, but in some benchmarks that causes
Expand Down
6 changes: 6 additions & 0 deletions app/buck2_build_api/src/query/bxl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::future::Future;
use std::pin::Pin;

use async_trait::async_trait;
use buck2_artifact::actions::key::ActionKey;
use buck2_core::cells::CellResolver;
use buck2_core::cells::name::CellName;
use buck2_core::configuration::compatibility::MaybeCompatible;
Expand Down Expand Up @@ -183,6 +184,11 @@ pub trait BxlAqueryFunctions: Send {
dice: &mut DiceComputations<'_>,
targets: &TargetSet<ActionQueryNode>,
) -> buck2_error::Result<TargetSet<ActionQueryNode>>;
async fn get_action_nodes(
&self,
dice: &mut DiceComputations<'_>,
action_keys: Vec<ActionKey>,
) -> buck2_error::Result<TargetSet<ActionQueryNode>>;
}

pub static NEW_BXL_CQUERY_FUNCTIONS: LateBinding<
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_build_signals_impl/src/enhancement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl CriticalPathProtoEnhancer {
let duration_proto = duration_to_proto_saturating(duration);
buck2_data::CriticalPathEntry2 {
span_ids: Vec::new(),
duration: Some(duration_proto),
duration: Some(duration_proto.clone()),
user_duration: Some(prost_types::Duration::default()),
queue_duration: None,
total_duration: Some(duration_proto),
Expand Down
17 changes: 17 additions & 0 deletions app/buck2_bxl/src/bxl/starlark_defs/analysis_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use buck2_build_api::analysis::AnalysisResult;
use buck2_build_api::interpreter::rule_defs::provider::collection::FrozenProviderCollection;
use buck2_build_api::interpreter::rule_defs::provider::dependency::Dependency;
use buck2_core::provider::label::ConfiguredProvidersLabel;
use buck2_interpreter::types::configured_providers_label::StarlarkConfiguredProvidersLabel;
use dupe::Dupe;
use starlark::any::ProvidesStaticType;
use starlark::environment::Methods;
Expand Down Expand Up @@ -149,6 +150,22 @@ fn starlark_analysis_result_methods(builder: &mut MethodsBuilder) {
Ok(heap.alloc(result))
}

/// Gets the configured providers label for this analysis result.
///
/// Sample usage:
/// ```python
/// def _impl_label(ctx):
/// actions = ctx.aquery().all_actions("//target")
/// for node in actions:
/// if analysis := node.analysis():
/// ctx.output.print(analysis.label())
/// ```
fn label<'v>(
this: &StarlarkAnalysisResult,
) -> starlark::Result<StarlarkConfiguredProvidersLabel> {
Ok(StarlarkConfiguredProvidersLabel::new(this.label.dupe()))
}

/// Converts the analysis result into a `Dependency`. Currently, you can only get a `Dependency` without any
/// transitions. This means that you cannot create an exec dep or toolchain from an analysis result.
///
Expand Down
16 changes: 16 additions & 0 deletions app/buck2_bxl/src/bxl/starlark_defs/aquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use allocative::Allocative;
use buck2_artifact::actions::key::ActionKey;
use buck2_build_api::actions::query::ActionQueryNode;
use buck2_build_api::query::bxl::BxlAqueryFunctions;
use buck2_build_api::query::bxl::NEW_BXL_AQUERY_FUNCTIONS;
Expand Down Expand Up @@ -46,6 +47,7 @@ use starlark::values::type_repr::StarlarkTypeRepr;

use crate::bxl::starlark_defs::context::BxlContext;
use crate::bxl::starlark_defs::context::ErrorPrinter;
use crate::bxl::starlark_defs::nodes::action::StarlarkAction;
use crate::bxl::starlark_defs::nodes::action::StarlarkActionQueryNode;
use crate::bxl::starlark_defs::providers_expr::AnyProvidersExprArg;
use crate::bxl::starlark_defs::providers_expr::ProvidersExpr;
Expand Down Expand Up @@ -122,6 +124,7 @@ enum UnpackActionNodes<'v> {
ActionQueryNodesSet(&'v StarlarkTargetSet<ActionQueryNode>),
ConfiguredProviders(AnyProvidersExprArg<'v>),
ConfiguredTargets(ConfiguredTargetListExprArg<'v>),
StarlarkActions(UnpackList<StarlarkAction>),
}

// Aquery operates on `ActionQueryNode`s. Under the hood, the target set of action query nodes is obtained
Expand All @@ -140,6 +143,14 @@ async fn unpack_action_nodes<'v>(
return Ok(action_nodes.into_iter().map(|v| v.0).collect());
}
UnpackActionNodes::ActionQueryNodesSet(action_nodes) => return Ok(action_nodes.0.clone()),
UnpackActionNodes::StarlarkActions(actions) => {
let action_keys: Vec<ActionKey> = actions
.into_iter()
.map(|starlark_action| starlark_action.0.key().dupe())
.collect();

return aquery_env.get_action_nodes(dice, action_keys).await;
}
UnpackActionNodes::ConfiguredProviders(arg) => {
ProvidersExpr::<ConfiguredProvidersLabel>::unpack(
arg,
Expand Down Expand Up @@ -183,6 +194,11 @@ async fn unpack_action_nodes<'v>(
///
/// Query results are `target_set`s of `action_query_node`s, which supports iteration,
/// indexing, `len()`, set addition/subtraction, and `equals()`.
///
/// Actions can be specified as:
/// - Target expressions (configured targets/providers)
/// - Existing action query nodes or target sets
/// - `bxl.Action` objects (obtained from `ctx.audit().output()`)
#[starlark_module]
fn aquery_methods(builder: &mut MethodsBuilder) {
/// The deps query for finding the transitive closure of dependencies.
Expand Down
26 changes: 26 additions & 0 deletions app/buck2_bxl/src/bxl/starlark_defs/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use std::time::Instant;

use buck2_build_api::actions::query::ActionQueryNode;
use buck2_build_api::interpreter::rule_defs::artifact::starlark_artifact_like::ValueAsInputArtifactLikeUnpack;
use buck2_build_api::interpreter::rule_defs::cmd_args::value_as::ValueAsCommandLineLike;
use buck2_core::cells::CellAliasResolver;
Expand Down Expand Up @@ -42,6 +43,7 @@ use super::context::output::get_cmd_line_inputs;
use super::nodes::unconfigured::StarlarkTargetNode;
use crate::bxl::starlark_defs::context::BxlContext;
use crate::bxl::starlark_defs::eval_extra::BxlEvalExtra;
use crate::bxl::starlark_defs::nodes::action::StarlarkActionQueryNode;
use crate::bxl::starlark_defs::nodes::configured::StarlarkConfiguredTargetNode;
use crate::bxl::starlark_defs::targetset::StarlarkTargetSet;
use crate::bxl::starlark_defs::time::StarlarkInstant;
Expand Down Expand Up @@ -92,6 +94,30 @@ pub(crate) fn register_target_function(builder: &mut GlobalsBuilder) {
.map(|node| node.0),
))
}

/// Creates a target set from a list of action query nodes.
///
/// Sample usage:
/// ```python
/// def _impl_atarget_set(ctx):
/// actions = ctx.aquery().all_actions("//target")
/// action_a = actions[0]
/// action_b = actions[1]
/// action_set = bxl.atarget_set([action_a, action_b])
/// # Now can use in further queries
/// deps = ctx.aquery().deps(action_set)
/// ```
fn atarget_set(
nodes: Option<UnpackList<StarlarkActionQueryNode>>,
) -> starlark::Result<StarlarkTargetSet<ActionQueryNode>> {
Ok(StarlarkTargetSet::from_iter(
nodes
.unwrap_or(UnpackList::default())
.items
.into_iter()
.map(|node| node.0),
))
}
}

#[derive(Debug, buck2_error::Error, Clone)]
Expand Down
12 changes: 12 additions & 0 deletions app/buck2_cli_proto/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,18 @@ message TestRequest {
// Whether `RunInfo` providers for targets matching `target_patterns`
// should be built instead of only `ExternalTestInfo` providers.
bool build_run_info = 16;

enum TestOutputMode {
// Show output from all tests (default).
ALL = 0;
// Only show output from failed tests.
ERRORS = 1;
// Show no test output, only the summary.
NONE = 2;
}

// Controls how much test output is displayed.
TestOutputMode test_output_mode = 17;
}

message BxlRequest {
Expand Down
Loading
Loading