Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
77960: build: integrate new cross toolchains w/ Bazel r=mari-crl a=rickystewart

1. Add new toolchains that run on ARM hosts.
2. Add new toolchains that target M1 Mac's.

Release note: None

Jira issue: CRDB-14852

79257: roachtest: update ORMs under test r=otan a=rafiss

fixes #79208

- typeorm: also fixes permission issues
- sqlalchemy
- pgx
- lib/pq
- pgjdbc
  -  also use secure mode for pgjdbc test. this lets us test SCRAM functionality.
  - includes a small error code change: pgwire: use InvalidPassword error code when appropriate

Release note: None

79455: dev: add support for `dev generate cgo` r=mari-crl a=rickystewart

The contents of these files here is basically cargo-culted from the
`Makefile`. I have verified that I can get a build working via the
following steps:

    ./dev generate go cgo
    ./dev go -- build ./pkg/cmd/cockroach-short

We don't exactly mirror the previous contents of the `zcgo_flags.go`
files that `make` would create. One difference is that we don't populate
the `zcgo_flags` files in `go-libedit` to configure how the C sources
are built and linked, so we get the default behavior, which is fine, but
means the `go build`-built binary and the Bazel-built binary will be
using a different compiled archive (maybe compiled with different flags/
a different configuration/etc.) for the `libedit` sources.

With `make`, we address this by putting a `zcgo_flags_extra.go` file in
the sources for `go-libedit` right in `vendor`. Post-Bazel we have no
reason for `vendor` and have no plans to keep it in the long-term so
this is not really suitable. I'm punting on this for now -- the default
behavior will probably be "good enough" for most people.

Closes #77170.

Release note: None

Co-authored-by: Ricky Stewart <[email protected]>
Co-authored-by: Rafi Shamim <[email protected]>
  • Loading branch information
3 people committed Apr 6, 2022
4 parents 301a424 + 68355af + fc0c874 + 0ea8283 commit e54a36c
Show file tree
Hide file tree
Showing 34 changed files with 659 additions and 174 deletions.
6 changes: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ build:crosswindows '--workspace_status_command=./build/bazelutil/stamp.sh x86_64
build:crosswindows --config=crosswindowsbase
build:crosswindowsbase --platforms=//build/toolchains:cross_windows
build:crosswindowsbase --config=cross
build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin19'
build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin21.2'
build:crossmacos --config=crossmacosbase
build:crossmacosbase --platforms=//build/toolchains:cross_macos
build:crossmacosbase --config=cross
build:crossmacosarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-apple-darwin21.2'
build:crossmacosarm --config=crossmacosarmbase
build:crossmacosarmbase --platforms=//build/toolchains:cross_macos_arm
build:crossmacosarmbase --config=cross
build:crosslinuxarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu'
build:crosslinuxarm --config=crosslinuxarmbase
build:crosslinuxarmbase --platforms=//build/toolchains:cross_linux_arm
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ native-tag := $(subst -,_,$(TARGET_TRIPLE))$(if $(use-stdmalloc),_stdmalloc)
# encounters a given native tag or when the build signature changes (see
# build/defs.mk.sig). These tags are unset when building with the Go toolchain
# directly, so these files are only compiled when building with Make.
#
# NB: If you update the zcgo_flags.go generation below, make sure to make the
# corresponding changes to `dev generate cgo`.
CGO_PKGS := \
pkg/cli \
pkg/cli/clisqlshell \
Expand Down
14 changes: 10 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,16 @@ load("//build/toolchains:REPOSITORIES.bzl", "toolchain_dependencies")
toolchain_dependencies()

register_toolchains(
"//build/toolchains:cross_linux_toolchain",
"//build/toolchains:cross_linux_arm_toolchain",
"//build/toolchains:cross_macos_toolchain",
"//build/toolchains:cross_windows_toolchain",
"//build/toolchains:cross_x86_64_linux_toolchain",
"//build/toolchains:cross_x86_64_linux_arm_toolchain",
"//build/toolchains:cross_x86_64_macos_toolchain",
"//build/toolchains:cross_x86_64_macos_arm_toolchain",
"//build/toolchains:cross_x86_64_windows_toolchain",
"//build/toolchains:cross_arm64_linux_toolchain",
"//build/toolchains:cross_arm64_linux_arm_toolchain",
"//build/toolchains:cross_arm64_windows_toolchain",
"//build/toolchains:cross_arm64_macos_toolchain",
"//build/toolchains:cross_arm64_macos_arm_toolchain",
"//build/toolchains:dev_darwin_x86_64_toolchain",
)

Expand Down
197 changes: 192 additions & 5 deletions build/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

# We define a number of toolchains, each of which has a name of the form:
# cross_HOST_TARGET_toolchain
# The "HOST" is either x86_64 or arm64. The TARGET is either linux, windows,
# macos, s390x, linux_arm, or macos_arm. (As you might expect, the targets
# are x86_64 in general unless they end with "_arm".) You can enable any of
# these toolchains with `--config crossTARGET` (see .bazelrc).

toolchain(
name = "cross_linux_toolchain",
name = "cross_x86_64_linux_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
Expand All @@ -26,7 +33,7 @@ platform(
)

toolchain(
name = "cross_windows_toolchain",
name = "cross_x86_64_windows_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
Expand All @@ -51,7 +58,7 @@ platform(
)

toolchain(
name = "cross_macos_toolchain",
name = "cross_x86_64_macos_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
Expand All @@ -63,7 +70,7 @@ toolchain(
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_x86_64-apple-darwin19//:toolchain",
toolchain = "@cross_x86_64_macos_toolchain//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

Expand All @@ -76,7 +83,32 @@ platform(
)

toolchain(
name = "cross_linux_arm_toolchain",
name = "cross_x86_64_macos_arm_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
target_settings = [
":cross",
],
toolchain = "@cross_x86_64_macos_arm_toolchain//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

platform(
name = "cross_macos_arm",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
)

toolchain(
name = "cross_x86_64_linux_arm_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
Expand All @@ -100,6 +132,136 @@ platform(
],
)

platform(
name = "cross_linux_s390x",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:s390x",
],
)

toolchain(
name = "cross_x86_64_s390x_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:s390x",
],
target_settings = [
":cross",
],
toolchain = "@toolchain_cross_s390x-ibm-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_linux_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@armtoolchain_cross_x86_64-unknown-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_windows_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@armtoolchain_cross_x86_64-w64-mingw32//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_linux_arm_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_settings = [
":cross",
],
toolchain = "@armtoolchain_cross_aarch64-unknown-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_s390x_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:s390x",
],
target_settings = [
":cross",
],
toolchain = "@armtoolchain_cross_s390x-ibm-linux-gnu//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_macos_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
target_settings = [
":cross",
],
toolchain = "@cross_arm64_macos_toolchain//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cross_arm64_macos_arm_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
target_settings = [
":cross",
],
toolchain = "@cross_arm64_macos_arm_toolchain//:toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

# This is the dev macOS toolchain which uses the same version of Clang that we
# use in CI. We don't have a dev macOS toolchain for ARM yet because Clang
# doesn't publish compilers that run on M1 Macs.
toolchain(
name = "dev_darwin_x86_64_toolchain",
exec_compatible_with = [
Expand All @@ -125,6 +287,9 @@ platform(
],
)

# There are aliases for each of these flags defined in .bazelrc; for example,
# --crdb_test instead of --//build/toolchains:crdb_test_flag.

bool_flag(
name = "crdb_test_flag",
build_setting_default = False,
Expand Down Expand Up @@ -185,6 +350,28 @@ config_setting(
},
)

config_setting(
name = "is_cross_macos_x86_64",
constraint_values = [
"@io_bazel_rules_go//go/toolchain:darwin",
"@platforms//cpu:x86_64",
],
flag_values = {
":cross_flag": "true",
},
)

config_setting(
name = "is_cross_macos_arm64",
constraint_values = [
"@io_bazel_rules_go//go/toolchain:darwin",
"@platforms//cpu:arm64",
],
flag_values = {
":cross_flag": "true",
},
)

config_setting(
name = "is_cross_linux",
constraint_values = [
Expand Down
42 changes: 35 additions & 7 deletions build/toolchains/REPOSITORIES.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,58 @@ load(
_crosstool_toolchain_repo = "crosstool_toolchain_repo",
)
load(
"//build/toolchains:darwin-x86_64/toolchain.bzl",
_macos_toolchain_repo = "macos_toolchain_repo",
"//build/toolchains:darwin/toolchain.bzl",
_macos_toolchain_repos = "macos_toolchain_repos",
)

def toolchain_dependencies():
_dev_darwin_x86_repo(name = "toolchain_dev_darwin_x86-64")
_crosstool_toolchain_repo(
name = "toolchain_cross_aarch64-unknown-linux-gnu",
host = "x86_64",
target = "aarch64-unknown-linux-gnu",
tarball_sha256 = "ed7ebe618794c0a64aec742d1bf9274302f86a8a81505758c97dc99dab5fd6ab",
tarball_sha256 = "76efd6ee539a0a358c03a6405c95c2f758935bbe70572e030fad86fb328b7d7b",
)
_crosstool_toolchain_repo(
name = "toolchain_cross_s390x-ibm-linux-gnu",
host = "x86_64",
target = "s390x-ibm-linux-gnu",
tarball_sha256 = "93c34d3111e38882fd88f38df33243c52466f703d78e7dd8ac0260c9e1ca35c6",
tarball_sha256 = "3917b7ba50b30d4907d05a3060e79e931e541cb7096913285e4fc0b06ccc98fe",
)
_crosstool_toolchain_repo(
name = "toolchain_cross_x86_64-unknown-linux-gnu",
host = "x86_64",
target = "x86_64-unknown-linux-gnu",
tarball_sha256 = "38f06a929fcc3d1405fe229aa8bc30e57ca78312f4e07e10a68cd3568a64412e",
tarball_sha256 = "267331e9c9cefdcb079a1487b346014f956e6b95332286fadb43d41b6cdd8ce0",
)
_crosstool_toolchain_repo(
name = "toolchain_cross_x86_64-w64-mingw32",
host = "x86_64",
target = "x86_64-w64-mingw32",
tarball_sha256 = "6900b96f7bbd86ba96c4c9704eab6fcb2241fdb5df0a8b9cb3416505a6ef19f7",
tarball_sha256 = "6b2a41d551f91d43b00ce086c60bb589e0ae95da2b14cc3fc6e2f2bf4494b21d",
)
_macos_toolchain_repo(name = "toolchain_cross_x86_64-apple-darwin19")
_crosstool_toolchain_repo(
name = "armtoolchain_cross_aarch64-unknown-linux-gnu",
host = "aarch64",
target = "aarch64-unknown-linux-gnu",
tarball_sha256 = "8e8455a9f5cec46aa6f8a7ffa53b6fb470f98ae169c49a8fe65ed2fbeb83e82f",
)
_crosstool_toolchain_repo(
name = "armtoolchain_cross_s390x-ibm-linux-gnu",
host = "aarch64",
target = "s390x-ibm-linux-gnu",
tarball_sha256 = "013e7ad3294b7f77b4937e988e0766bd0eb02186876c9e12f51314af38a43597",
)
_crosstool_toolchain_repo(
name = "armtoolchain_cross_x86_64-unknown-linux-gnu",
host = "aarch64",
target = "x86_64-unknown-linux-gnu",
tarball_sha256 = "a74aa2fb685b23e32a099f4c0bd32618640fc6f1070237edfd3f0c7f613ea983",
)
_crosstool_toolchain_repo(
name = "armtoolchain_cross_x86_64-w64-mingw32",
host = "aarch64",
target = "x86_64-w64-mingw32",
tarball_sha256 = "6baff5e7658215aabfbc6d37374f4fcdd1b62269828d55ebef841248a99373cc",
)
_macos_toolchain_repos()
2 changes: 1 addition & 1 deletion build/toolchains/crosstool-ng/BUILD.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load(":cc_toolchain_config.bzl", "cc_toolchain_config")
cc_toolchain_suite(
name = "suite",
toolchains = {
"k8": ":toolchain",
"%{host}": ":toolchain",
},
)

Expand Down
2 changes: 1 addition & 1 deletion build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _impl(ctx):
ctx = ctx,
features = features,
toolchain_identifier = "%{target}-cross-toolchain",
host_system_name = "%{target}",
host_system_name = "%{host}",
target_system_name = "%{target}",
target_cpu = "%{target}",
target_libc = "glibc-2.14",
Expand Down
Loading

0 comments on commit e54a36c

Please sign in to comment.