Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
name: ${{ matrix.test-name }}
strategy:
matrix:
test-name: [buildstream, mongo]
test-name: [buildstream, mongo, rbe-toolchain]
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ rust-project.json
darwin.bazelrc
nativelink.bazelrc
integration_tests/**/*.log
toolchain-examples/*.log
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module(
compatibility_level = 0,
)

bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.5")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_python", version = "1.3.0") # TODO(palfrey): Bump.
bazel_dep(name = "rules_shell", version = "0.4.1")
Expand Down
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
mongo-with-nativelink-test = pkgs.callPackage integration_tests/mongo/mongo-with-nativelink-test.nix {
inherit nativelink mongodb wait4x bazelisk;
};
rbe-toolchain-with-nativelink-test = pkgs.callPackage toolchain-examples/rbe-toolchain-test.nix {
inherit nativelink bazelisk;
};
}
// (
# It's not possible to crosscompile to darwin, not even between
Expand Down
4 changes: 2 additions & 2 deletions local-remote-execution/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module(
compatibility_level = 0,
)

bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "platforms", version = "1.0.0")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various upgrades were done for improved Nix compatibility, plus things that transitively depended on those.


# Use the starlark implementation of C++ rules instead of the builtin ones.
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_cc", version = "0.1.5")

# Use the starlark implementation of Java rules instead of the builtin ones.
bazel_dep(name = "rules_java", version = "8.11.0")
Expand Down
2 changes: 1 addition & 1 deletion nativelink-util/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn otlp_filter() -> EnvFilter {

// Create a tracing layer intended for stdout printing.
//
// The output of this layer is configurable via the `NL_LOG_FMT` environment
// The output of this layer is configurable via the `NL_LOG` environment
// variable.
fn tracing_stdout_layer() -> impl Layer<Registry> {
let nl_log_fmt = env::var("NL_LOG").unwrap_or_else(|_| "pretty".to_string());
Expand Down
8 changes: 0 additions & 8 deletions toolchain-examples/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Don't use the host's default PATH and LD_LIBRARY_PATH.
build --incompatible_strict_action_env

Copy link
Member Author

@palfrey palfrey Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes env: 'bash': No such file or directory in the Java, Go and Python examples, even with bazel-contrib/rules_go#4465 to improve bash paths.

# Use rules_python's builtin script to emulate a bootstrap python.
build --@rules_python//python/config_settings:bootstrap_impl=script

# Toolchain to verify remote execution with zig-cc.
build:zig-cc --platforms @zig_sdk//platform:linux_amd64
build:zig-cc --platforms @zig_sdk//platform:linux_amd64

# These toolchains map out everything in
# https://github.com/uber/hermetic_cc_toolchain/blob/bfc407599e503a44928a3cefad27421c9341eff0/MODULE.bazel#L44
#
Expand Down Expand Up @@ -75,7 +68,6 @@ build:zig-cc --extra_toolchains @zig_sdk-macos-amd64//libc_aware/toolchain:linux
build:zig-cc --extra_toolchains @zig_sdk-macos-amd64//toolchain:wasip1_wasm

# Toolchain to verify remote execution with contrib/toolchains_llvm.
build:llvm --platforms=@toolchains_llvm//platforms:linux-x86_64
build:llvm --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

# Java runtime to ensure hermeticity on the remote.
Expand Down
18 changes: 12 additions & 6 deletions toolchain-examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module(
compatibility_level = 0,
)

bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "platforms", version = "1.0.0")

# C++
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_cc", version = "0.1.5")

# Java
bazel_dep(name = "rules_java", version = "8.11.0")
Expand All @@ -34,7 +34,16 @@ python.toolchain(
use_repo(pip, "pip")

# Go
bazel_dep(name = "rules_go", version = "0.53.0")
bazel_dep(name = "rules_go", version = "0.57.0")

# Adds https://github.com/bazel-contrib/rules_go/commit/74199c92e20399b6ef46684b2c6fdd94b50a7892
# to fix bash issues with Nix
archive_override(
module_name = "rules_go",
integrity = "sha256-ukyyC80j4VhRCD7DOaenkk41Vvnmsp7uAfHr4lxdXtQ=",
strip_prefix = "rules_go-74199c92e20399b6ef46684b2c6fdd94b50a7892",
urls = ["https://github.com/bazel-contrib/rules_go/archive/74199c92e20399b6ef46684b2c6fdd94b50a7892.zip"],
)

# Rust
bazel_dep(name = "rules_rust", version = "0.61.0")
Expand Down Expand Up @@ -89,8 +98,5 @@ bazel_dep(name = "abseil-cpp", version = "20250127.0")
# Abseil for python
bazel_dep(name = "abseil-py", version = "2.1.0")

# GRPC
bazel_dep(name = "grpc", version = "1.71.0")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping this as we don't test it and it's not in the docs

# Circl (Go, C++)
bazel_dep(name = "circl", version = "1.3.8")
31 changes: 16 additions & 15 deletions toolchain-examples/nativelink-config.json5
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
stores: {
AC_MAIN_STORE: {
stores: [
{
name: "AC_MAIN_STORE",
filesystem: {
content_path: "/tmp/nativelink/data-worker-test/content_path-ac",
temp_path: "/tmp/nativelink/data-worker-test/tmp_path-ac",
eviction_policy: {
// 1gb.
max_bytes: 1000000000,
max_bytes: "1gb",
},
},
},
WORKER_FAST_SLOW_STORE: {
{
name: "WORKER_FAST_SLOW_STORE",
fast_slow: {
// "fast" must be a "filesystem" store because the worker uses it to make
// hardlinks on disk to a directory where the jobs are running.
Expand All @@ -19,8 +20,7 @@
content_path: "/tmp/nativelink/data-worker-test/content_path-cas",
temp_path: "/tmp/nativelink/data-worker-test/tmp_path-cas",
eviction_policy: {
// 10gb.
max_bytes: 10000000000,
max_bytes: "10gb",
},
},
},
Expand All @@ -34,9 +34,10 @@
},
},
},
},
schedulers: {
MAIN_SCHEDULER: {
],
schedulers: [
{
name: "MAIN_SCHEDULER",
simple: {
supported_platform_properties: {
cpu_count: "minimum",
Expand All @@ -48,7 +49,7 @@
},
},
},
},
],
workers: [
{
local: {
Expand Down Expand Up @@ -127,11 +128,11 @@
},
},
],
bytestream: {
cas_stores: {
"": "WORKER_FAST_SLOW_STORE",
bytestream: [
{
cas_store: "WORKER_FAST_SLOW_STORE",
},
},
],
},
},
{
Expand Down
75 changes: 75 additions & 0 deletions toolchain-examples/rbe-toolchain-test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
nativelink,
writeShellScriptBin,
bazelisk,
}:
writeShellScriptBin "rbe-toolchain-test" ''
set -uo pipefail

cleanup() {
local pids=$(jobs -pr)
[ -n "$pids" ] && kill $pids
}
trap "cleanup" INT QUIT TERM EXIT

NO_COLOR=true ${nativelink}/bin/nativelink -- toolchain-examples/nativelink-config.json5 | tee -i toolchain-examples/nativelink.log &

CORE_BAZEL_ARGS="--check_direct_dependencies=error --remote_cache=grpc://localhost:50051 --remote_executor=grpc://localhost:50051"

CPU_TYPE=$(uname -m)

if [[ "$CPU_TYPE" == 'x86_64' ]]; then
PLATFORM='amd64'
else
PLATFORM='arm64'
fi

LLVM_PLATFORM="--platforms=@toolchains_llvm//platforms:linux-''${CPU_TYPE}"
ZIG_PLATFORM="--platforms @zig_sdk//platform:linux_''${PLATFORM}"

# As per https://nativelink.com/docs/rbe/remote-execution-examples#minimal-example-targets
COMMANDS=("test //cpp $ZIG_PLATFORM"
"test //cpp --config=llvm $LLVM_PLATFORM"
"test //python"
"test //go $ZIG_PLATFORM"
# "test //rust $ZIG_PLATFORM" # rules_rust isn't RBE-compatible
"test //java:HelloWorld --config=java"
"build @curl//... $ZIG_PLATFORM"
"build @zstd//... $ZIG_PLATFORM"
# "test @abseil-cpp//... $ZIG_PLATFORM" # Buggy build due to google_benchmark errors
"test @abseil-py//..."
"test @circl//... $ZIG_PLATFORM"
)

echo "" > toolchain-examples/cmd.log
for cmd in "''${COMMANDS[@]}"
do
FULL_CMD="${bazelisk}/bin/bazelisk $cmd $CORE_BAZEL_ARGS"
echo $FULL_CMD
echo -e \\n$FULL_CMD\\n >> toolchain-examples/cmd.log
cmd_output=$(cd toolchain-examples && eval "$FULL_CMD" 2>&1 | tee -ai cmd.log)
cmd_exit_code=$?
case $cmd_exit_code in
0 )
echo "Saw a successful $cmd build"
;;
*)
echo "Failed $cmd build:"
echo $cmd_output
exit 1
;;
esac
done

nativelink_output=$(cat toolchain-examples/nativelink.log)

case $nativelink_output in
*"ERROR "* )
echo "Error in nativelink build"
exit 1
;;
*)
echo 'Successful nativelink build'
;;
esac
''
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ directory for details. Here are your options:

| Config | Hermetic | Size | Description |
| - | - | - | - |
| `zig-cc` | yes | ~100Mb | Hermetic, but slow. The intended use for this toolchain are projects that need a baseline C++ toolchain, but aren't "real" C++ projects, such as Go projects with a limited number of C FFIs. |
| `zig-cc` | yes | ~100Mb | Hermetic, but slow. The intended use for this toolchain are projects that need a baseline C++ toolchain, but aren't "real" C++ projects, such as Go projects with a limited number of C FFIs. Note you will also need to specify your platform. For example `--platforms @zig_sdk//platform:linux_amd64`|
| `llvm` | no | ~1.5Gb | Not hermetic, but fast and standardized. This toolchain tends to be safe to use for C++ projects as long as you don't require full hermeticity. Your remote execution image needs to bundle `glibc <= 2.34` for this toolchain to work. |
| `java` | yes | ? | This sets the JDK to use a remote JDK. Use this one for Java. |

Expand Down Expand Up @@ -184,6 +184,7 @@ nonexistent artifact hashes.
```bash
bazel build //cpp \
--config=zig-cc \
--platforms @zig_sdk//platform:linux_amd64 \
--remote_cache=grpc://localhost:50051 \
--remote_executor=grpc://localhost:50051
```
Expand All @@ -192,6 +193,7 @@ nonexistent artifact hashes.
```bash
bazel build //cpp \
--config=llvm \
--platforms=@toolchains_llvm//platforms:linux-x86_64 \
--remote_cache=grpc://localhost:50051 \
--remote_executor=grpc://localhost:50051
```
Expand Down
Loading