Revert "Switch to Bazel 5 (#12935)" (#12974)

This reverts commit 4c0118df4d.

This breaks passing -p to bazel test for Haskell tests, e.g.,

bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p
--test_arg InterfaceEq

which breaks with something horrifying like

moritz@adjunction ~/daml (main)> bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p --test_arg InterfaceEq
[dev-env] Building tools.bazel...
[dev-env] Built tools.bazel in /nix/store/m7gzlmr0pqjpl01ihgvazxgfs3sfwl61-bazel and linked to /home/moritz/daml/dev-env/var/gc-roots/bazel
[dev-env] Building tools.find...
[dev-env] Built tools.find in /nix/store/645v3545lcbx77wq7355rgdrgbhn5wx7-findutils-4.8.0 and linked to /home/moritz/daml/dev-env/var/gc-roots/find
INFO: Invocation ID: 034b3e45-851f-472e-ab71-b7f718829582
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/rules_haskell/haskell/private/versions.bzl:60:10: WARNING: bazel version is too recent. Supported versions range from 4.0.0 to 4.2.1, but found: 5.0.0- (@non-git)
/nix/store/dadkhf8vch2i2kvig962ilfr5j3chshr-go-1.17.6
/nix/store/pzh24n543i6jqa01hdmgqknlyf294bn1-bazel-nixpkgs-posix-toolchain
/nix/store/2hfwndk47wpvaib06qyhcdp83b423xvh-jq-1.6-bin
/nix/store/hjggs9s82qh7r5j8sgapn389hf24wdx8-bazel-nixpkgs-cc-toolchain
/nix/store/yxgg3bn4v288sc00kf09svrwz2r461c9-ghc-native-bignum-9.0.2
/nix/store/2hwx0jhcdsx3wfvmb50ih19jkh2ra4jh-glibc-locales-2.33-108
/nix/store/8wpmx049z8m0ffhy3jyi41qb6pbxwvy8-bazel-nixpkgs-java-runtime
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 3d79fe1470dcb842d5944c98dfe7a62715db6d86fdb12d3ff60af3bdf41b7996
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 9f46e824944add9e9951ef51ddb6cb4b744bc97f90b5749132179d1d1699dfa1
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: com.google.devtools.build.lib.skyframe.ArtifactConflictFinder$ConflictException: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o, previous action: action 'Compiling src/tools/launcher/dummy.cc', attempted action: action 'Compiling src/tools/launcher/dummy.cc'

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2022-02-16 19:24:00 +01:00 committed by GitHub
parent bdfbb0d928
commit e40f62f88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 190 additions and 126 deletions

View File

@ -1,7 +1,7 @@
# Bazel distributed cache, can be temporarily disabled by passing the following
# flag: --noremote_accept_cached
build:darwin --remote_cache=https://bazel-cache.da-ext.net
build:linux --remote_cache=https://bazel-cache.da-ext.net/ubuntu_20_04
build:darwin --remote_http_cache=https://bazel-cache.da-ext.net
build:linux --remote_http_cache=https://bazel-cache.da-ext.net/ubuntu_20_04
# Don't push local build results to the remote cache.
build --remote_upload_local_results=false
# Do still push local build results to the local disk cache.
@ -62,8 +62,20 @@ test --strategy=Scalac=worker
# https://github.com/grpc/grpc/pull/13929/files
build --copt -DGRPC_BAZEL_BUILD
build --java_language_version=11
build --java_runtime_version=11
# Bazel defaults to JDK9. This makes sure we run Nix provided JDK, and
# avoid dreaded "Unrecognized VM option 'CompactStrings'" error
build:linux --javabase=@nixpkgs_java_runtime//:runtime
build:linux --host_javabase=@nixpkgs_java_runtime//:runtime
build:linux --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:linux --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:darwin --javabase=@nixpkgs_java_runtime//:runtime
build:darwin --host_javabase=@nixpkgs_java_runtime//:runtime
build:darwin --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:darwin --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:windows --javabase=@dadew_java_runtime//:runtime
build:windows --host_javabase=@dadew_java_runtime//:runtime
build:windows --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:windows --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
# Do not use a distinct configuration for "host", that is, binaries used
# at build time should be the same as release binaries.

View File

@ -901,7 +901,7 @@ be defined using `da_scala_test`. It is preferable to always use
Scala benchmarks based on the JMH toolkit can be defined using the
`scala_benchmark_jmh` macro provided by `rules_scala`. It supports a restricted
subset of the attributes of `da_scala_binary`, namely: `name`, `deps`, `srcs`,
`scalacopts` and `resources`.
`scalacopts`, `resources` and `resource_jars`.
The end result of building the benchmark is a Scala binary of the same name,
which can be executed with `bazel run`.

View File

@ -37,7 +37,6 @@ load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew", "dev_env_tool")
load(
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure",
"nixpkgs_java_configure",
"nixpkgs_local_repository",
"nixpkgs_package",
"nixpkgs_python_configure",
@ -575,7 +574,7 @@ load("@rules_haskell//tools:repositories.bzl", "rules_haskell_worker_dependencie
# Call this after `daml_haskell_deps` to ensure that the right `stack` is used.
rules_haskell_worker_dependencies()
load("//bazel_tools:java.bzl", "dadew_java_configure")
load("//bazel_tools:java.bzl", "dadew_java_configure", "nixpkgs_java_configure")
dadew_java_configure(
name = "dadew_java_runtime",

View File

@ -8,6 +8,125 @@ load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_package")
load("//bazel_tools:pkg.bzl", "pkg_empty_zip")
load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_tool_home", "dadew_where")
_java_nix_file_content = """
let
pkgs = import <nixpkgs> { config = {}; overlays = []; };
in
{ attrPath
, attrSet
, filePath
}:
let
javaHome =
if attrSet == null then
pkgs.lib.attrByPath (pkgs.lib.splitString "." attrPath) null pkgs
else
pkgs.lib.attrByPath (pkgs.lib.splitString "." attrPath) null attrSet
;
javaHomePath =
if filePath == "" then
"${javaHome}"
else
"${javaHome}/${filePath}"
;
in
assert javaHome != null;
pkgs.runCommand "bazel-nixpkgs-java-runtime"
{ executable = false;
# Pointless to do this on a remote machine.
preferLocalBuild = true;
allowSubstitutes = false;
}
''
n=$out/BUILD.bazel
mkdir -p "$(dirname "$n")"
cat >>$n <<EOF
load("@rules_java//java:defs.bzl", "java_runtime")
java_runtime(
name = "runtime",
java_home = r"${javaHomePath}",
visibility = ["//visibility:public"],
)
EOF
''
"""
def nixpkgs_java_configure(
name = "nixpkgs_java_runtime",
attribute_path = None,
java_home_path = "",
repository = None,
repositories = {},
nix_file = None,
nix_file_content = "",
nix_file_deps = None,
nixopts = [],
fail_not_supported = True,
quiet = False):
"""Define a Java runtime provided by nixpkgs.
Creates a `nixpkgs_package` for a `java_runtime` instance.
Args:
name: The name-prefix for the created external repositories.
attribute_path: string, The nixpkgs attribute path for `jdk.home`.
java_home_path: optional, string, The path to `JAVA_HOME` within the package.
repository: See [`nixpkgs_package`](#nixpkgs_package-repository).
repositories: See [`nixpkgs_package`](#nixpkgs_package-repositories).
nix_file: optional, Label, Obtain the runtime from the Nix expression defined in this file. Specify only one of `nix_file` or `nix_file_content`.
nix_file_content: optional, string, Obtain the runtime from the given Nix expression. Specify only one of `nix_file` or `nix_file_content`.
nix_file_deps: See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps).
nixopts: See [`nixpkgs_package`](#nixpkgs_package-nixopts).
fail_not_supported: See [`nixpkgs_package`](#nixpkgs_package-fail_not_supported).
quiet: See [`nixpkgs_package`](#nixpkgs_package-quiet).
"""
if attribute_path == None:
fail("'attribute_path' is required.", "attribute_path")
nix_expr = None
if nix_file and nix_file_content:
fail("Cannot specify both 'nix_file' and 'nix_file_content'.")
elif nix_file:
nix_expr = "import $(location {}) {{}}".format(nix_file)
nix_file_deps = depset(direct = [nix_file] + nix_file_deps).to_list()
elif nix_file_content:
nix_expr = nix_file_content
else:
nix_expr = "null"
nixopts = list(nixopts)
nixopts.extend([
"--argstr",
"attrPath",
attribute_path,
"--arg",
"attrSet",
nix_expr,
"--argstr",
"filePath",
java_home_path,
])
kwargs = dict(
repository = repository,
repositories = repositories,
nix_file_deps = nix_file_deps,
nixopts = nixopts,
fail_not_supported = fail_not_supported,
quiet = quiet,
)
java_runtime = "@%s//:runtime" % name
nixpkgs_package(
name = name,
nix_file_content = _java_nix_file_content,
**kwargs
)
def _dadew_java_configure_impl(repository_ctx):
ps = repository_ctx.which("powershell")
dadew = dadew_where(repository_ctx, ps)
@ -19,24 +138,11 @@ java_runtime(
java_home = r"{java_home}",
visibility = ["//visibility:public"],
)
toolchain(
name = "toolchain",
toolchain = ":runtime",
toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
],
)
""".format(
java_home = java_home.replace("\\", "/"),
))
_dadew_java_configure = repository_rule(
dadew_java_configure = repository_rule(
implementation = _dadew_java_configure_impl,
attrs = {
"dadew_path": attr.string(
@ -53,19 +159,13 @@ Creates a `java_runtime` that uses the JDK installed by dadew.
""",
)
def dadew_java_configure(name, dadew_path):
_dadew_java_configure(
name = name,
dadew_path = dadew_path,
)
native.register_toolchains("@{}//:toolchain".format(name))
def da_java_library(
name,
deps,
srcs,
data = [],
resources = [],
resource_jars = [],
resource_strip_prefix = None,
tags = [],
visibility = None,
@ -82,6 +182,7 @@ def da_java_library(
srcs = srcs,
data = data,
resources = resources,
resource_jars = resource_jars,
resource_strip_prefix = resource_strip_prefix,
tags = tags,
visibility = visibility,

View File

@ -1,57 +0,0 @@
diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl
index 061170e..10dcac6 100644
--- a/nixpkgs/nixpkgs.bzl
+++ b/nixpkgs/nixpkgs.bzl
@@ -925,6 +925,40 @@ pkgs.runCommand "bazel-nixpkgs-java-runtime"
''
"""
+def _nixpkgs_java_toolchain_impl(repository_ctx):
+ cpu = get_cpu_value(repository_ctx)
+ exec_constraints, target_constraints = ensure_constraints(repository_ctx)
+
+ repository_ctx.file(
+ "BUILD.bazel",
+ executable = False,
+ content = """\
+package(default_visibility = ["//visibility:public"])
+
+toolchain(
+ name = "java-toolchain-{cpu}",
+ toolchain = "@{runtime}//:runtime",
+ toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type",
+ exec_compatible_with = {exec_constraints},
+ target_compatible_with = {target_constraints},
+)
+""".format(
+ runtime = repository_ctx.attr.runtime,
+ cpu = cpu,
+ exec_constraints = exec_constraints,
+ target_constraints = target_constraints,
+ ),
+ )
+
+_nixpkgs_java_toolchain = repository_rule(
+ _nixpkgs_java_toolchain_impl,
+ attrs = {
+ "runtime": attr.string(),
+ "exec_constraints": attr.string_list(),
+ "target_constraints": attr.string_list(),
+ },
+)
+
def nixpkgs_java_configure(
name = "nixpkgs_java_runtime",
attribute_path = None,
@@ -1014,6 +1048,11 @@ def nixpkgs_java_configure(
fail_not_supported = fail_not_supported,
quiet = quiet,
)
+ _nixpkgs_java_toolchain(
+ name = "{}_toolchain".format(name),
+ runtime = name,
+ )
+ native.register_toolchains("@{}_toolchain//:all".format(name))
def _nixpkgs_python_toolchain_impl(repository_ctx):
exec_constraints, target_constraints = ensure_constraints(repository_ctx)

View File

@ -76,7 +76,7 @@ if is_windows; then
# We include an extra version at the end that we can bump manually.
CACHE_SUFFIX="$SUFFIX-v11"
CACHE_URL="$CACHE_URL/$CACHE_SUFFIX"
echo "build:windows-ci --remote_cache=https://bazel-cache.da-ext.net/$CACHE_SUFFIX" >> .bazelrc.local
echo "build:windows-ci --remote_http_cache=https://bazel-cache.da-ext.net/$CACHE_SUFFIX" >> .bazelrc.local
fi
# sets up write access to the shared remote cache if the branch is not a fork
@ -86,5 +86,5 @@ if [[ "${IS_FORK}" = False ]]; then
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > "$GOOGLE_APPLICATION_CREDENTIALS"
unset GOOGLE_APPLICATION_CREDENTIALS_CONTENT
export GOOGLE_APPLICATION_CREDENTIALS
echo "build --remote_cache=$CACHE_URL --remote_upload_local_results=true --google_credentials=${GOOGLE_APPLICATION_CREDENTIALS}" >> .bazelrc.local
echo "build --remote_http_cache=$CACHE_URL --remote_upload_local_results=true --google_credentials=${GOOGLE_APPLICATION_CREDENTIALS}" >> .bazelrc.local
fi

View File

@ -42,9 +42,9 @@ jobs:
variables:
cache_key: $[ dependencies.patch_bazel_pre_check.outputs['out.cache_key'] ]
should_run: $[ dependencies.patch_bazel_pre_check.outputs['out.should_run'] ]
bazel_base_version: 5.0.0
bazel_base_version: 4.2.1
pool:
vmImage: windows-2022
vmImage: windows-2019
steps:
- checkout: self
condition: eq(variables.should_run, 'true')
@ -65,7 +65,7 @@ jobs:
BAZEL=$(mktemp)
curl -sL https://github.com/bazelbuild/bazel/releases/download/$(bazel_base_version)/bazel-$(bazel_base_version)-windows-x86_64.exe > $BAZEL
cd bazel
$BAZEL build --java_language_version=11 --java_runtime_version=11 src/main/cpp:client src:package-zip_jdk_minimal -c opt --stamp --embed_label $(bazel_base_version)-patched-$(cache_key)
$BAZEL build src/main/cpp:client src:package-zip_jdk_minimal -c opt --stamp --embed_label $(bazel_base_version)-patched-$(cache_key)
# Note (MK) For some reason, the `zip` from chocolatey seems to result in
# a “zip file structure invalid” error. Ive tried adding msys to PATH so the Bazel
# rules pick up `zip` from msys but that broke other things. So for now

View File

@ -1,7 +1,7 @@
# Bazel distributed cache, can be temporarily disabled by passing the following
# flag: --noremote_accept_cached
build:darwin --remote_cache=https://bazel-cache.da-ext.net
build:linux --remote_cache=https://bazel-cache.da-ext.net/ubuntu_20_04
build:darwin --remote_http_cache=https://bazel-cache.da-ext.net
build:linux --remote_http_cache=https://bazel-cache.da-ext.net/ubuntu_20_04
# Don't push local build results to the remote cache.
build --remote_upload_local_results=false
# Do still push local build results to the local disk cache.
@ -62,8 +62,20 @@ test --strategy=Scalac=worker
# https://github.com/grpc/grpc/pull/13929/files
build --copt -DGRPC_BAZEL_BUILD
build --java_language_version=11
build --java_runtime_version=11
# Bazel defaults to JDK9. This makes sure we run Nix provided JDK, and
# avoid dreaded "Unrecognized VM option 'CompactStrings'" error
build:linux --javabase=@nixpkgs_java_runtime//:runtime
build:linux --host_javabase=@nixpkgs_java_runtime//:runtime
build:linux --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:linux --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:darwin --javabase=@nixpkgs_java_runtime//:runtime
build:darwin --host_javabase=@nixpkgs_java_runtime//:runtime
build:darwin --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:darwin --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:windows --javabase=@dadew_java_runtime//:runtime
build:windows --host_javabase=@dadew_java_runtime//:runtime
build:windows --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build:windows --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
# Do not use a distinct configuration for "host", that is, binaries used
# at build time should be the same as release binaries.

View File

@ -57,7 +57,6 @@ load(
load(
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure",
"nixpkgs_java_configure",
"nixpkgs_local_repository",
"nixpkgs_package",
"nixpkgs_python_configure",
@ -306,7 +305,7 @@ daml_sdk_head(
if ver != "0.0.0"
]
load("@daml//bazel_tools:java.bzl", "dadew_java_configure")
load("@daml//bazel_tools:java.bzl", "dadew_java_configure", "nixpkgs_java_configure")
dadew_java_configure(
name = "dadew_java_runtime",

View File

@ -46,8 +46,8 @@ rules_haskell_patches = [
# This should be upstreamed
"@com_github_digital_asset_daml//bazel_tools:haskell-ghc-includes.patch",
]
rules_nixpkgs_version = "de066d554de5bb5fd16270aebb04c99d07d7ed38"
rules_nixpkgs_sha256 = "bb5bd56a0784cb46419190ceb743ad713c6e00ab5b603a9cba9bbe51ef5063b6"
rules_nixpkgs_version = "81f61c4b5afcf50665b7073f7fce4c1755b4b9a3"
rules_nixpkgs_sha256 = "33fd540d0283cf9956d0a5a640acb1430c81539a84069114beaf9640c96d221a"
rules_nixpkgs_patches = [
# On CI and locally we observe occasional segmantation faults
# of nix. A known issue since Nix 2.2.2 is that HTTP2 support
@ -56,8 +56,6 @@ rules_nixpkgs_patches = [
# reportedly solves the issue. See
# https://github.com/NixOS/nix/issues/2733#issuecomment-518324335
"@com_github_digital_asset_daml//bazel_tools:nixpkgs-disable-http2.patch",
# This should be upstreamed.
"@com_github_digital_asset_daml//bazel_tools:nixpkgs-java-toolchain.patch",
]
buildifier_version = "4.0.0"

View File

@ -5,8 +5,8 @@
"bin": "bazel.exe",
"architecture": {
"64bit": {
"url": "https://daml-binaries.da-ext.net/patch_bazel_windows/bazel-cd25d0f3eaa288d276cc8db26be071de.zip",
"hash": "f8edd1b9a4f33dcf6085d82b5643baf398ea65ab3b188418fe4aa31d29ceab15"
"url": "https://daml-binaries.da-ext.net/patch_bazel_windows/bazel-be46798f67a4437875bfe23efb51935a.zip",
"hash": "670afb47f1b1a50747e90b570780ca54cfd29d9e5bf338a711c7f7d4758c9029"
}
},
"depends": [

View File

@ -67,10 +67,10 @@ index 57741a8f28..6673149a20 100644
workingDirectory,
diskCachePath,
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
index 0e165d1521..ff33a84afb 100644
index 350e1afa51..db81481b60 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
@@ -64,9 +64,11 @@ import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
@@ -59,9 +59,11 @@ import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
import com.google.devtools.build.lib.exec.SpawnStrategyRegistry;
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.remote.RemoteServerCapabilities.ServerCapabilitiesRequirement;
@ -82,15 +82,15 @@ index 0e165d1521..ff33a84afb 100644
import com.google.devtools.build.lib.remote.logging.LoggingInterceptor;
import com.google.devtools.build.lib.remote.options.RemoteOptions;
import com.google.devtools.build.lib.remote.options.RemoteOutputsMode;
@@ -103,6 +105,7 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins;
@@ -95,6 +97,7 @@ import io.grpc.ClientInterceptor;
import io.grpc.ManagedChannel;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.channels.ClosedChannelException;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -232,7 +235,31 @@ public final class RemoteModule extends BlazeModule {
@@ -213,7 +216,31 @@ public final class RemoteModule extends BlazeModule {
remoteOptions,
creds,
Preconditions.checkNotNull(env.getWorkingDirectory(), "workingDirectory"),
@ -167,10 +167,10 @@ index a2e4abf9d8..93843a91dc 100644
+ public long offset() { return offset; }
}
diff --git a/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java
index 3cbf6cf47f..4453d5fcc6 100644
index 1efecd3bb1..3f360dda14 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java
@@ -24,6 +24,7 @@ import com.google.common.util.concurrent.Futures;
@@ -25,6 +25,7 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
@ -178,15 +178,15 @@ index 3cbf6cf47f..4453d5fcc6 100644
import com.google.devtools.build.lib.remote.common.CacheNotFoundException;
import com.google.devtools.build.lib.remote.common.RemoteActionExecutionContext;
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
@@ -82,6 +83,7 @@ import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
@@ -84,6 +85,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
@@ -130,6 +132,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -132,6 +134,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
private final boolean useTls;
private final boolean verifyDownloads;
private final DigestUtil digestUtil;
@ -194,7 +194,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
private final Object closeLock = new Object();
@@ -151,6 +154,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -153,6 +156,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
boolean verifyDownloads,
ImmutableList<Entry<String, String>> extraHttpHeaders,
DigestUtil digestUtil,
@ -202,7 +202,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
@Nullable final Credentials creds)
throws Exception {
return new HttpCacheClient(
@@ -162,6 +166,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -164,6 +168,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
verifyDownloads,
extraHttpHeaders,
digestUtil,
@ -210,7 +210,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
creds,
null);
}
@@ -174,6 +179,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -176,6 +181,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
boolean verifyDownloads,
ImmutableList<Entry<String, String>> extraHttpHeaders,
DigestUtil digestUtil,
@ -218,7 +218,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
@Nullable final Credentials creds)
throws Exception {
@@ -187,6 +193,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -189,6 +195,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
verifyDownloads,
extraHttpHeaders,
digestUtil,
@ -226,7 +226,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
creds,
domainSocketAddress);
} else if (Epoll.isAvailable()) {
@@ -199,6 +206,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -201,6 +208,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
verifyDownloads,
extraHttpHeaders,
digestUtil,
@ -234,7 +234,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
creds,
domainSocketAddress);
} else {
@@ -215,6 +223,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -217,6 +225,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
boolean verifyDownloads,
ImmutableList<Entry<String, String>> extraHttpHeaders,
DigestUtil digestUtil,
@ -242,7 +242,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
@Nullable final Credentials creds,
@Nullable SocketAddress socketAddress)
throws Exception {
@@ -283,6 +292,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -285,6 +294,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
this.extraHttpHeaders = extraHttpHeaders;
this.verifyDownloads = verifyDownloads;
this.digestUtil = digestUtil;
@ -250,7 +250,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
}
@SuppressWarnings("FutureReturnValueIgnored")
@@ -459,6 +469,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -461,6 +471,7 @@ public final class HttpCacheClient implements RemoteCacheClient {
@SuppressWarnings("FutureReturnValueIgnored")
private ListenableFuture<Void> get(Digest digest, final OutputStream out, boolean casDownload) {
final AtomicBoolean dataWritten = new AtomicBoolean();
@ -258,7 +258,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
OutputStream wrappedOut =
new OutputStream() {
// OutputStream.close() does nothing, which is what we want to ensure that the
@@ -468,12 +479,14 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -470,12 +481,14 @@ public final class HttpCacheClient implements RemoteCacheClient {
@Override
public void write(byte[] b, int offset, int length) throws IOException {
dataWritten.set(true);
@ -273,7 +273,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
out.write(b);
}
@@ -482,57 +495,59 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -484,57 +497,59 @@ public final class HttpCacheClient implements RemoteCacheClient {
out.flush();
}
};
@ -378,7 +378,7 @@ index 3cbf6cf47f..4453d5fcc6 100644
}
@SuppressWarnings("FutureReturnValueIgnored")
@@ -674,20 +689,21 @@ public final class HttpCacheClient implements RemoteCacheClient {
@@ -673,20 +688,21 @@ public final class HttpCacheClient implements RemoteCacheClient {
@Override
public ListenableFuture<Void> uploadFile(
RemoteActionExecutionContext context, Digest digest, Path file) {

View File

@ -152,7 +152,7 @@ in rec {
'' + pkgs.lib.optionalString (pkgs.buildPlatform.libc == "glibc") ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
'' + ''
exec ${pkgs.bazel_5}/bin/bazel --bazelrc "${bazelrc}" "$@"
exec ${pkgs.bazel_4}/bin/bazel --bazelrc "${bazelrc}" "$@"
'');
# System tools

View File

@ -27,7 +27,7 @@ let
};
});
bazel_5 = pkgs.bazel_5.overrideAttrs(oldAttrs: {
bazel_4 = pkgs.bazel_4.overrideAttrs(oldAttrs: {
patches = oldAttrs.patches ++ [
# This should be upstreamed. Bazel is too aggressive
# in treating arguments starting with @ as response files.