Skip to content

Commit

Permalink
bazel: require setting cockroach_cross=y to opt into cross toolchains
Browse files Browse the repository at this point in the history
With `--incompatible_enable_cc_toolchain_resolution` set in cockroachdb#73819, now
Bazel selects the appropriate toolchain for you. Bazel was selecting the
`cross_linux_toolchain` when building for the host platform on Linux,
resulting in link errors when trying to compile `stress` under `race`.
We update the toolchains to instead require opting into the cross
toolchains by defining `cockroach_cross=y`.

Closes cockroachdb#73997.

Release note: None
  • Loading branch information
rickystewart committed Dec 20, 2021
1 parent 0d07a2d commit 59f8eaa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions build/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ toolchain(
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_x86_64-unknown-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
Expand All @@ -30,6 +33,9 @@ toolchain(
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_x86_64-w64-mingw32//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
Expand All @@ -52,6 +58,9 @@ toolchain(
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_x86_64-apple-darwin19//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
Expand All @@ -74,6 +83,9 @@ toolchain(
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_aarch64-unknown-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
Expand Down Expand Up @@ -138,6 +150,13 @@ config_setting(
},
)

config_setting(
name = "cross",
define_values = {
"cockroach_cross": "y",
},
)

config_setting(
name = "is_cross_macos",
constraint_values = [
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/github-pull-request-make/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ func main() {
}
}
args = append(args, "--")
if target == "stressrace" {
args = append(args, "--config=race")
} else {
args = append(args, "--test_sharding_strategy=disabled")
}
var filters []string
for _, test := range pkg.tests {
filters = append(filters, "^"+test+"$")
Expand All @@ -304,11 +309,6 @@ func main() {
// Give the entire test 1 more minute than the duration to wrap up.
args = append(args, fmt.Sprintf("--test_timeout=%d", int((duration+1*time.Minute).Seconds())))
args = append(args, "--run_under", fmt.Sprintf("%s -stderr -maxfails 1 -maxtime %s -p %d", bazelStressTarget, duration, parallelism))
if target == "stressrace" {
args = append(args, "--config=race")
} else {
args = append(args, "--test_sharding_strategy=disabled")
}
// NB: bazci is expected to be put in `PATH` by the caller.
cmd := exec.Command("bazci", args...)
cmd.Stdout = os.Stdout
Expand Down

0 comments on commit 59f8eaa

Please sign in to comment.