Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ common --incompatible_config_setting_private_default_visibility

common:bootstrap --@toolchains_llvm_bootstrapped//toolchain:source=bootstrapped

# Workaround lack of cgo support for now
common:rules_cc --@rules_go//go/config:pure

# Bootstrap Go compilers from source with our patch.
common:wasm --@rules_go//go/toolchain:source=bootstrapped
common:wasm --@rules_go//go/toolchain:sdk_name=go_bootstrap_sdk_patched
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ jobs:
if [[ "${{ matrix.folder }}" == *"wasm"* ]]; then
EXTRA_ARGS="--config=wasm"
fi
if [[ "${{ matrix.folder }}" == *"rules_cc"* ]]; then
EXTRA_ARGS="--config=rules_cc"
fi

echo "common --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> "${HOME}/.bazelrc"

bazel \
--bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc \
--bazelrc=.bazelrc \
test \
--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY \
$EXTRA_ARGS \
//...

Expand Down Expand Up @@ -120,14 +124,15 @@ jobs:
EXTRA_ARGS="--config=wasm"
fi

echo "common --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> "${HOME}/.bazelrc"

bazel \
--bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc \
--bazelrc=.bazelrc \
--experimental_remote_repo_contents_cache \
test \
--repository_cache= \
--repo_contents_cache= \
--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY \
--jobs=100 \
$EXTRA_ARGS \
//...
10 changes: 10 additions & 0 deletions e2e/rules_cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,21 @@ cc_static_library(
deps = [":comm_symbol_defs"],
)

alias(
name = "bazelisk",
actual = "@com_github_bazelbuild_bazelisk//:bazelisk",
)

sh_test(
name = "duplicate_static_library_validator_test",
srcs = ["duplicate_static_library_failure_test.sh"],
args = ["$(rlocationpath :bazelisk)"],
data = [
"@bazel_tools//tools/bash/runfiles",
":bazelisk",
"BUILD.bazel",
"go.mod",
"go.sum",
"duplicate_symbol_a.cc",
"duplicate_symbol_b.cc",
],
Expand Down
20 changes: 20 additions & 0 deletions e2e/rules_cc/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
bazel_dep(name = "bazel_lib", version = "3.0.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_go", version = "0.60.0")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "gazelle", version = "0.46.0")
bazel_dep(name = "with_cfg.bzl", version = "0.12.0")
bazel_dep(name = "toolchains_llvm_bootstrapped", version = "")
local_path_override(
Expand All @@ -15,5 +17,23 @@ use_repo(llvm_toolchains, "llvm_toolchains")

register_toolchains("@llvm_toolchains//:all")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.from_file(
name = "go_prebuilt_sdk_local",
go_mod = "//:go.mod",
)
use_repo(go_sdk, "go_prebuilt_sdk_local")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
go_deps.gazelle_override(
build_file_generation = "clean",
path = "github.com/bazelbuild/bazelisk",
)
use_repo(
go_deps,
"com_github_bazelbuild_bazelisk",
)

# Bump transitive zlib version to avoid genrules.
bazel_dep(name = "zlib", version = "1.3.1.bcr.8")
355 changes: 352 additions & 3 deletions e2e/rules_cc/MODULE.bazel.lock

Large diffs are not rendered by default.

36 changes: 31 additions & 5 deletions e2e/rules_cc/duplicate_static_library_failure_test.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
#!/usr/bin/env bash

# --- begin runfiles.bash initialization v3 ---
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo >&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

set -euo pipefail

WORKSPACE_ROOT="$(dirname $(realpath "$0"))"
WORKSPACE_ROOT="$(dirname "$(realpath "$0")")"
LOG="${TEST_TMPDIR:?}/duplicate_static_library.log"
BAZEL_BIN="${BAZEL_BIN:-bazel}"
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 BAZELISK_RLOCATION_PATH"
exit 1
fi
BAZEL_BIN="$(rlocation "$1")"
if [[ ! -x "${BAZEL_BIN}" ]]; then
echo "Bazel launcher is missing or not executable: ${BAZEL_BIN}"
exit 1
fi

cd "${WORKSPACE_ROOT}"
# Bazelisk fails early if neither HOME nor XDG_CACHE_HOME are exported.
USER_HOME="${HOME:-}"
export HOME="${TEST_TMPDIR}"
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-${TEST_TMPDIR}/.cache}"

BAZELRC_FLAGS=(--bazelrc=.bazelrc)
if [[ -n "${USER_HOME}" && -f "${USER_HOME}/.bazelrc" ]]; then
BAZELRC_FLAGS=(--bazelrc="${USER_HOME}/.bazelrc" "${BAZELRC_FLAGS[@]}")
fi

if "${BAZEL_BIN}" \
--bazelrc=.bazelrc \
"${BAZELRC_FLAGS[@]}" \
build \
--color=yes \
--curses=yes \
--remote_cache= \
--bes_backend= \
--config=remote \
--config=bootstrap \
//:duplicate_symbol_lib 2>&1 | tee "${LOG}"; then
echo "Expected duplicate_symbol_lib to fail duplicate symbol validation, but build succeeded."
exit 1
Expand Down
15 changes: 15 additions & 0 deletions e2e/rules_cc/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module rules_cc

go 1.26.0

tool github.com/bazelbuild/bazelisk

require (
github.com/bazelbuild/bazelisk v1.28.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/gofrs/flock v0.13.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
)
22 changes: 22 additions & 0 deletions e2e/rules_cc/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
github.com/bazelbuild/bazelisk v1.28.1 h1:p+U4By+b8cnPabjFCubA7qi/GURU24J/Tn3NXOwGLog=
github.com/bazelbuild/bazelisk v1.28.1/go.mod h1:hpvsc/YkfAFoNwTKk8LaprQHUd/l+MClrEs4e+EzdnM=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading