From a0afcc150965fdb60a61b184c5d4d70d544f8795 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Wed, 1 Mar 2023 17:26:20 -0600 Subject: [PATCH 1/9] Regenerate cross-toolchain configs --- WORKSPACE | 14 - build/bazelrc/cross.bazelrc | 12 +- tools/cross-toolchain/Dockerfile | 18 +- tools/cross-toolchain/README.md | 53 ++- tools/cross-toolchain/configs/.latest.bazelrc | 33 -- tools/cross-toolchain/configs/LICENSE | 202 ++++++++++++ .../configs/{clang/bazel_5.3.0 => }/cc/BUILD | 137 ++++---- tools/cross-toolchain/configs/cc/WORKSPACE | 2 + .../cc/armeabi_cc_toolchain_config.bzl | 0 .../cc/builtin_include_directory_paths | 0 .../cc/cc_toolchain_config.bzl | 0 .../{clang/bazel_5.3.0 => }/cc/cc_wrapper.sh | 0 .../bazel_5.3.0 => }/cc/module.modulemap | 0 .../configs/cc/tools/cpp/empty.cc | 1 + .../bazel_5.3.0/prysm_toolchains/BUILD.bazel | 195 ----------- .../bazel_5.3.0/prysm_toolchains/WORKSPACE | 2 - .../cc_toolchain_config_linux_arm64.bzl | 305 ------------------ .../cc_toolchain_config_osx.bzl | 260 --------------- .../cc_toolchain_config_windows.bzl | 217 ------------- .../{clang/bazel_5.3.0 => }/config/BUILD | 23 +- .../{clang/bazel_5.3.0 => }/java/BUILD | 19 +- tools/cross-toolchain/configs/versions.bzl | 16 - tools/cross-toolchain/cpp_env_clang.json | 9 + tools/cross-toolchain/empty.bzl | 18 -- .../cross-toolchain/rbe_toolchains_config.bzl | 102 ------ tools/cross-toolchain/regenerate.sh | 11 - 26 files changed, 347 insertions(+), 1302 deletions(-) delete mode 100644 tools/cross-toolchain/configs/.latest.bazelrc create mode 100755 tools/cross-toolchain/configs/LICENSE rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/BUILD (65%) mode change 100755 => 100644 create mode 100644 tools/cross-toolchain/configs/cc/WORKSPACE rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/armeabi_cc_toolchain_config.bzl (100%) mode change 100755 => 100644 rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/builtin_include_directory_paths (100%) mode change 100755 => 100644 rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/cc_toolchain_config.bzl (100%) mode change 100755 => 100644 rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/cc_wrapper.sh (100%) mode change 100755 => 100644 rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/cc/module.modulemap (100%) mode change 100755 => 100644 create mode 100644 tools/cross-toolchain/configs/cc/tools/cpp/empty.cc delete mode 100755 tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/BUILD.bazel delete mode 100644 tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/WORKSPACE delete mode 100755 tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_linux_arm64.bzl delete mode 100755 tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_osx.bzl delete mode 100755 tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_windows.bzl rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/config/BUILD (65%) mode change 100644 => 100755 rename tools/cross-toolchain/configs/{clang/bazel_5.3.0 => }/java/BUILD (63%) mode change 100644 => 100755 delete mode 100644 tools/cross-toolchain/configs/versions.bzl create mode 100644 tools/cross-toolchain/cpp_env_clang.json delete mode 100644 tools/cross-toolchain/empty.bzl delete mode 100644 tools/cross-toolchain/rbe_toolchains_config.bzl delete mode 100755 tools/cross-toolchain/regenerate.sh diff --git a/WORKSPACE b/WORKSPACE index 5b0d43c81bf2..9b1d45776917 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,16 +3,6 @@ workspace(name = "prysm") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -http_archive( - name = "bazel_toolchains", - sha256 = "8e0633dfb59f704594f19ae996a35650747adc621ada5e8b9fb588f808c89cb0", - strip_prefix = "bazel-toolchains-3.7.0", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/3.7.0/bazel-toolchains-3.7.0.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/releases/download/3.7.0/bazel-toolchains-3.7.0.tar.gz", - ], -) - http_archive( name = "com_grail_bazel_toolchain", sha256 = "b210fc8e58782ef171f428bfc850ed7179bdd805543ebd1aa144b9c93489134f", @@ -39,10 +29,6 @@ load("@prysm//tools/cross-toolchain:prysm_toolchains.bzl", "configure_prysm_tool configure_prysm_toolchains() -load("@prysm//tools/cross-toolchain:rbe_toolchains_config.bzl", "rbe_toolchains_config") - -rbe_toolchains_config() - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( diff --git a/build/bazelrc/cross.bazelrc b/build/bazelrc/cross.bazelrc index b712ba5f9e42..7e84d3df4e95 100644 --- a/build/bazelrc/cross.bazelrc +++ b/build/bazelrc/cross.bazelrc @@ -43,14 +43,10 @@ build:docker-sandbox --spawn_strategy=docker --strategy=Javac=docker --genrule_s build:docker-sandbox --define=EXECUTOR=remote build:docker-sandbox --experimental_docker_verbose build:docker-sandbox --experimental_enable_docker_sandbox -build:docker-sandbox --crosstool_top=@rbe_ubuntu_clang//cc:toolchain -build:docker-sandbox --host_javabase=@rbe_ubuntu_clang//java:jdk -build:docker-sandbox --javabase=@rbe_ubuntu_clang//java:jdk -build:docker-sandbox --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 -build:docker-sandbox --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 -build:docker-sandbox --extra_execution_platforms=@rbe_ubuntu_clang//config:platform -build:docker-sandbox --host_platform=@rbe_ubuntu_clang//config:platform -build:docker-sandbox --platforms=@rbe_ubuntu_clang//config:platform +build:docker-sandbox --crosstool_top=@//tools/cross-toolchain/configs/cc:toolchain +build:docker-sandbox --extra_execution_platforms=@//tools/cross-toolchain/configs/config:platform +build:docker-sandbox --host_platform=@//tools/cross-toolchain/configs/config:platform +build:docker-sandbox --platforms=@//tools/cross-toolchain/configs/config:platform build:docker-sandbox --extra_toolchains=@prysm_toolchains//:cc-toolchain-multiarch # windows_amd64 docker sandbox build config diff --git a/tools/cross-toolchain/Dockerfile b/tools/cross-toolchain/Dockerfile index 4d65b4885b8a..c783812df942 100644 --- a/tools/cross-toolchain/Dockerfile +++ b/tools/cross-toolchain/Dockerfile @@ -1,15 +1,6 @@ # Prysmatic Labs Remote Build Execution Image with Cross Compile Support. # -# Update instructions. -# - Build the docker image. -# - Push to gcr.io. -# - Update _PRYSM_BUILD_IMAGE_DIGEST in //tools/cross-toolchain/rbe_toolchains_config.bzl -# - Run ./tools/cross-toolchain/regenerate.sh -# - Add and commit the newly generated configs. -# - Done! -# -# docker build -t gcr.io/prysmaticlabs/rbe-worker:latest . -# gcloud docker -- push gcr.io/prysmaticlabs/rbe-worker:latest +# See README.md for update instructions. FROM debian:bullseye-slim as build @@ -22,7 +13,7 @@ RUN apt-get update && \ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ cmake libssl-dev libxml2-dev vim apt-transport-https \ zip unzip libtinfo5 patch zlib1g-dev autoconf libtool \ - pkg-config make docker.io gnupg2 libgmp-dev python + pkg-config make docker.io gnupg2 libgmp-dev python openjdk-17-jdk-headless # install llvm/clang cross-build toolchains ENV INSTALL_LLVM_VERSION=12.0.0 @@ -38,6 +29,7 @@ RUN /tmp/link_osxcross.sh # containerized development environment FROM build as devel -RUN mkdir /workdir -WORKDIR /workdir + +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ + RUN echo 'PS1="\[$(tput setaf 3)$(tput bold)[\]devel@\\h:\\W]#\[$(tput sgr0) \]"' >> /root/.bashrc diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 2f88f3f4000d..13b3ab3672bc 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -11,13 +11,52 @@ This package declares a c++ toolchain suite with cross compilers for targeting f This toolchain suite describes cross compile configuration with a Dockerfile with the appropriate host dependencies. These toolchains can be used locally (see [caveats](#caveats)), [Remote Build Execution (RBE)](https://docs.bazel.build/versions/master/remote-execution.html), and in a docker sandbox (like RBE, but local). +### Updating the toolchain suite + +1 Build and push the worker docker image, if necessary. + +```bash +docker build -t gcr.io/prysmaticlabs/rbe-worker:latest tools/cross-toolchain/. +gcloud docker -- push gcr.io/prysmaticlabs/rbe-worker:latest +``` + +2 Note the docker image sha256 digest from the recently pushed image or use the latest one available. + +3 Download and run [rbe_configs_gen](https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs) CLI tool. + +```bash +# Run from the root of the Prysm repo. +rbe_configs_gen \ + --bazel_version=$(cat .bazelversion) \ + --target_os=linux \ + --exec_os=linux \ + --output_src_root=tools/cross-toolchain/configs \ + --generate_cpp_configs=true \ + --generate_java_configs=true \ + --cpp_env_json=tools/cross-toolchain/cpp_env_clang.json \ + --toolchain_container=gcr.io/prysmaticlabs/rbe-worker@sha256:9a30c5ff7dcd1fbc5cb5b5f320782dec755a31cd2f6811e238a8584d94b04e78 # The sha256 digest from step 2. +``` + +4 Test the builds work locally for all supported platforms. + +```bash + bazel build --config=release --config=linux_amd64 --config=llvm //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl + bazel build --config=release --config=linux_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl + bazel build --config=release --config=osx_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl + bazel build --config=release --config=osx_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl + bazel build --config=release --config=windows_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +``` + +5 Add and commit the newly generated configs. + +6 Done! ### Cross compile target support -| target | linux_amd64 | linux_arm64 | osx_amd64 | osx_arm64 | windows_amd64 | -|------------------|-------------------|------------------|-----------------|-----------------|-----------------------------------| +| target | linux_amd64 | linux_arm64 | osx_amd64 | osx_arm64 | windows_amd64 | +|------------------|--------------------------------------------------------------------|--------------------------------------------|------------------------------------|------------------------------------|------------------------------------| | `//beacon-chain` | :heavy_check_mark: docker-sandbox and RBE, supported locally only | :heavy_check_mark: docker-sandbox and RBE | :heavy_check_mark: docker-sandbox | :heavy_check_mark: docker-sandbox | :heavy_check_mark: docker-sandbox | -| `//validator` | :heavy_check_mark: docker-sandbox and RBE | :heavy_check_mark: docker-sandbox and RBE | :heavy_check_mark: docker-sandbox | :heavy_check_mark: docker-sandbox | :heavy_check_mark: | +| `//validator` | :heavy_check_mark: docker-sandbox and RBE | :heavy_check_mark: docker-sandbox and RBE | :heavy_check_mark: docker-sandbox | :heavy_check_mark: docker-sandbox | :heavy_check_mark: | The configurations above are enforced via pull request presubmit checks. @@ -25,10 +64,10 @@ The configurations above are enforced via pull request presubmit checks. Use these values with `--config=`, multiple times if more than one value is defined in the table. Example: `bazel build //beacon-chain --config=windows_amd64_docker` to build windows binary in a docker sandbox. -| Config | linux_amd64 | linux_arm64 | osx_amd64 | osx_arm64 | windows_amd64 | -|-------------------------------|-------------------|------------------|---------------------------|---------------------------|------------------------------| -| Local run | `linux_amd64` | `linux_arm64` | `osx_amd64` | `osx_arm64` | `windows_amd64` | -| Docker sandbox | `linux_amd64_docker` | `linux_arm64_docker` | `osx_amd64_docker` | `osx_arm64_docker` | `windows_amd64_docker ` | +| Config | linux_amd64 | linux_arm64 | osx_amd64 | osx_arm64 | windows_amd64 | +|-------------------------------|----------------------------|-----------------------------|---------------------------|---------------------------|-------------------------------| +| Local run | `linux_amd64` | `linux_arm64` | `osx_amd64` | `osx_arm64` | `windows_amd64` | +| Docker sandbox | `linux_amd64_docker` | `linux_arm64_docker` | `osx_amd64_docker` | `osx_arm64_docker` | `windows_amd64_docker ` | | RBE (See [Caveats](#caveats)) | `linux_amd64` and `remote` | `linux_arm64` and `remote` | `osx_amd64` and `remote` | `osx_arm64` and `remote` | `windows_amd64` and `remote` | ### Caveats diff --git a/tools/cross-toolchain/configs/.latest.bazelrc b/tools/cross-toolchain/configs/.latest.bazelrc deleted file mode 100644 index 44e6c707d55d..000000000000 --- a/tools/cross-toolchain/configs/.latest.bazelrc +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2016 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This .bazelrc file is generated by rbe_autoconfig -# when the output_base attr is used. -# It contains some of the flags required for the provided -# toolchain with Remote Build Execution. -# Specifically, it includes all toolchain/platform flags -# This file is used for testing purposes. - -build:remote --host_javabase=//tools/cross-toolchain/configs/clang/bazel_5.3.0/java:jdk -build:remote --javabase=//tools/cross-toolchain/configs/clang/bazel_5.3.0/java:jdk -build:remote --crosstool_top=//tools/cross-toolchain/configs/clang/bazel_5.3.0/cc:toolchain -build:remote --extra_toolchains=//tools/cross-toolchain/configs/clang/bazel_5.3.0/config:cc-toolchain -build:remote --extra_execution_platforms=//tools/cross-toolchain/configs/clang/bazel_5.3.0/config:platform -build:remote --host_platform=//tools/cross-toolchain/configs/clang/bazel_5.3.0/config:platform -build:remote --platforms=//tools/cross-toolchain/configs/clang/bazel_5.3.0/config:platform - -# Import the default bazelrc file in bazel-toolchains repo. -# This will only work for tests executed from bazel-toolchains -# repo. -try-import %workspace%/bazelrc/.bazelrc.notoolchain diff --git a/tools/cross-toolchain/configs/LICENSE b/tools/cross-toolchain/configs/LICENSE new file mode 100755 index 000000000000..f0a1f59a3c8f --- /dev/null +++ b/tools/cross-toolchain/configs/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 Google LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/BUILD b/tools/cross-toolchain/configs/cc/BUILD old mode 100755 new mode 100644 similarity index 65% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/BUILD rename to tools/cross-toolchain/configs/cc/BUILD index c58ce8725ef4..b0fcffc15e39 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/BUILD +++ b/tools/cross-toolchain/configs/cc/BUILD @@ -24,28 +24,21 @@ licenses(["notice"]) # Apache 2.0 cc_library( name = "malloc", - tags = ["manual"], ) filegroup( name = "empty", srcs = [], - tags = ["manual"], ) filegroup( name = "cc_wrapper", srcs = ["cc_wrapper.sh"], - tags = ["manual"], ) filegroup( name = "compiler_deps", - srcs = glob( - ["extra_tools/**"], - allow_empty = True, - ) + [":builtin_include_directory_paths"], - tags = ["manual"], + srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths"], ) # This is the entry point for --crosstool_top. Toolchains are found @@ -53,7 +46,6 @@ filegroup( # the "${CPU}" entry in the toolchains attribute. cc_toolchain_suite( name = "toolchain", - tags = ["manual"], toolchains = { "k8|clang": ":cc-compiler-k8", "k8": ":cc-compiler-k8", @@ -64,79 +56,40 @@ cc_toolchain_suite( cc_toolchain( name = "cc-compiler-k8", + toolchain_identifier = "local", + toolchain_config = ":local", all_files = ":compiler_deps", ar_files = ":compiler_deps", as_files = ":compiler_deps", compiler_files = ":compiler_deps", dwp_files = ":empty", linker_files = ":compiler_deps", - module_map = ":module.modulemap", objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":local", - toolchain_identifier = "local", + module_map = ":module.modulemap", ) cc_toolchain_config( name = "local", - abi_libc_version = "local", - abi_version = "local", - compile_flags = [ - "-fstack-protector", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-Wno-free-nonheap-object", - "-fcolor-diagnostics", - "-fno-omit-frame-pointer", - ], - compiler = "clang", - coverage_compile_flags = [ - "-fprofile-instr-generate", - "-fcoverage-mapping", - ], - coverage_link_flags = ["-fprofile-instr-generate"], cpu = "k8", - cxx_builtin_include_directories = [ - "/usr/local/include", - "/usr/lib/clang/12.0.0/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "/usr/lib/clang/12.0.0/share", - "/usr/include/c++/10", - "/usr/include/x86_64-linux-gnu/c++/10", - "/usr/include/c++/10/backward", - "/usr/include/c++/v1", - ], - cxx_flags = ["-std=c++0x"], - dbg_compile_flags = ["-g"], + compiler = "clang", + toolchain_identifier = "local", host_system_name = "local", - link_flags = [ - "-fuse-ld=/usr/bin/ld.lld", - "-Wl,-no-as-needed", - "-Wl,-z,relro,-z,now", - "-B/usr/bin", - "-lm", - "-static-libgcc", - ], - link_libs = ["-l:libstdc++.a"], - opt_compile_flags = [ - "-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - opt_link_flags = ["-Wl,--gc-sections"], - supports_start_end_lib = True, - tags = ["manual"], - target_libc = "local", target_system_name = "local", - tool_paths = { - "ar": "/usr/bin/ar", + target_libc = "local", + abi_version = "local", + abi_libc_version = "local", + cxx_builtin_include_directories = ["/usr/local/include", + "/usr/lib/clang/12.0.0/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "/usr/lib/clang/12.0.0/share", + "/usr/include/c++/10", + "/usr/include/x86_64-linux-gnu/c++/10", + "/usr/include/c++/10/backward", + "/usr/include/c++/v1"], + tool_paths = {"ar": "/usr/bin/ar", "ld": "/usr/bin/ld", "llvm-cov": "/usr/bin/llvm-cov", "cpp": "/usr/bin/cpp", @@ -146,21 +99,45 @@ cc_toolchain_config( "nm": "/usr/bin/nm", "objcopy": "/usr/bin/objcopy", "objdump": "/usr/bin/objdump", - "strip": "/usr/bin/strip", - }, - toolchain_identifier = "local", - unfiltered_compile_flags = [ - "-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], + "strip": "/usr/bin/strip"}, + compile_flags = ["-fstack-protector", + "-Wall", + "-Wthread-safety", + "-Wself-assign", + "-Wno-free-nonheap-object", + "-fcolor-diagnostics", + "-fno-omit-frame-pointer"], + opt_compile_flags = ["-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections"], + dbg_compile_flags = ["-g"], + cxx_flags = ["-std=c++0x"], + link_flags = ["-fuse-ld=/usr/bin/ld.lld", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-B/usr/bin", + "-lm", + "-static-libgcc"], + link_libs = ["-l:libstdc++.a"], + opt_link_flags = ["-Wl,--gc-sections"], + unfiltered_compile_flags = ["-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\""], + coverage_compile_flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], + coverage_link_flags = ["-fprofile-instr-generate"], + supports_start_end_lib = True, ) # Android tooling requires a default toolchain for the armeabi-v7a cpu. cc_toolchain( name = "cc-compiler-armeabi-v7a", + toolchain_identifier = "stub_armeabi-v7a", + toolchain_config = ":stub_armeabi-v7a", all_files = ":empty", ar_files = ":empty", as_files = ":empty", @@ -170,12 +147,6 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":stub_armeabi-v7a", - toolchain_identifier = "stub_armeabi-v7a", ) -armeabi_cc_toolchain_config( - name = "stub_armeabi-v7a", - tags = ["manual"], -) +armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") diff --git a/tools/cross-toolchain/configs/cc/WORKSPACE b/tools/cross-toolchain/configs/cc/WORKSPACE new file mode 100644 index 000000000000..bc05b4c36ff4 --- /dev/null +++ b/tools/cross-toolchain/configs/cc/WORKSPACE @@ -0,0 +1,2 @@ +# DO NOT EDIT: automatically generated WORKSPACE file for cc_autoconf rule +workspace(name = "local_config_cc") diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/armeabi_cc_toolchain_config.bzl b/tools/cross-toolchain/configs/cc/armeabi_cc_toolchain_config.bzl old mode 100755 new mode 100644 similarity index 100% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/armeabi_cc_toolchain_config.bzl rename to tools/cross-toolchain/configs/cc/armeabi_cc_toolchain_config.bzl diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/builtin_include_directory_paths b/tools/cross-toolchain/configs/cc/builtin_include_directory_paths old mode 100755 new mode 100644 similarity index 100% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/builtin_include_directory_paths rename to tools/cross-toolchain/configs/cc/builtin_include_directory_paths diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/cc_toolchain_config.bzl b/tools/cross-toolchain/configs/cc/cc_toolchain_config.bzl old mode 100755 new mode 100644 similarity index 100% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/cc_toolchain_config.bzl rename to tools/cross-toolchain/configs/cc/cc_toolchain_config.bzl diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/cc_wrapper.sh b/tools/cross-toolchain/configs/cc/cc_wrapper.sh old mode 100755 new mode 100644 similarity index 100% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/cc_wrapper.sh rename to tools/cross-toolchain/configs/cc/cc_wrapper.sh diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/module.modulemap b/tools/cross-toolchain/configs/cc/module.modulemap old mode 100755 new mode 100644 similarity index 100% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/cc/module.modulemap rename to tools/cross-toolchain/configs/cc/module.modulemap diff --git a/tools/cross-toolchain/configs/cc/tools/cpp/empty.cc b/tools/cross-toolchain/configs/cc/tools/cpp/empty.cc new file mode 100644 index 000000000000..c272dabaeb68 --- /dev/null +++ b/tools/cross-toolchain/configs/cc/tools/cpp/empty.cc @@ -0,0 +1 @@ +int main() {} \ No newline at end of file diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/BUILD.bazel b/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/BUILD.bazel deleted file mode 100755 index 960a01dd635c..000000000000 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/BUILD.bazel +++ /dev/null @@ -1,195 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load(":cc_toolchain_config_osx.bzl", "osx_cc_toolchain_config") -load(":cc_toolchain_config_linux_arm64.bzl", "arm64_cc_toolchain_config") -load(":cc_toolchain_config_windows.bzl", "windows_cc_toolchain_config") - -cc_toolchain_suite( - name = "multiarch_toolchain", - tags = ["manual"], - toolchains = { - "k8|osxcross": ":cc-clang-osx-amd64", - "aarch64|osxcross": ":cc-clang-osx-arm64", - "k8|clang": "cc-clang-amd64", - "aarch64|clang": ":cc-clang-arm64", - "k8": "cc-clang-amd64", - "aarch64": ":cc-clang-arm64", - "k8|mingw-w64": ":cc-mingw-amd64", - }, -) - -cc_toolchain_suite( - name = "hostonly_toolchain", - tags = ["manual"], - toolchains = { - "k8": "cc-clang-amd64", - }, -) - -filegroup( - name = "empty", - srcs = [], - tags = ["manual"], -) - -config_setting( - name = "osx_amd64", - constraint_values = [ - "@platforms//os:osx", - "@platforms//cpu:x86_64", - ], - tags = ["manual"], -) - -config_setting( - name = "osx_arm64", - constraint_values = [ - "@platforms//os:osx", - "@platforms//cpu:arm64", - ], - tags = ["manual"], -) - -config_setting( - name = "linux_arm64", - constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:aarch64", - ], - tags = ["manual"], -) - -config_setting( - name = "linux_amd64", - constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", - ], - tags = ["manual"], -) - -config_setting( - name = "windows_amd64", - constraint_values = [ - "@platforms//os:windows", - "@platforms//cpu:x86_64", - ], - tags = ["manual"], -) - -arm64_cc_toolchain_config( - name = "local-arm64", - tags = ["manual"], - target = "aarch64-linux-gnu", -) - -arm64_cc_toolchain_config( - name = "local-amd64", - tags = ["manual"], - target = "x86_64-unknown-linux-gnu", -) - -osx_cc_toolchain_config( - name = "local-osxcross-amd64", - tags = ["manual"], - target = "darwin_x86_64", - target_cpu = "x86_64", -) - -osx_cc_toolchain_config( - name = "local-osxcross-arm64", - tags = ["manual"], - target = "darwin_aarch64", - target_cpu = "aarch64", -) - -windows_cc_toolchain_config( - name = "local-windows", - tags = ["manual"], - target = "x86_64-w64", -) - -cc_toolchain( - name = "cc-mingw-amd64", - all_files = ":empty", - ar_files = ":empty", - as_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, - tags = ["manual"], - toolchain_config = ":local-windows", -) - -cc_toolchain( - name = "cc-clang-arm64", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":local-arm64", -) - -cc_toolchain( - name = "cc-clang-osx-amd64", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":local-osxcross-amd64", -) - -cc_toolchain( - name = "cc-clang-osx-arm64", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":local-osxcross-arm64", -) - -cc_toolchain( - name = "cc-clang-amd64", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - tags = ["manual"], - toolchain_config = ":local-amd64", -) - -toolchain( - name = "cc-toolchain-multiarch", - exec_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", - ], - tags = ["manual"], - target_compatible_with = [], - toolchain = select({ - ":linux_arm64": ":cc-clang-arm64", - ":linux_amd64": ":cc-clang-amd64", - ":osx_amd64": ":cc-clang-osx-amd64", - ":osx_arm64": ":cc-clang-osx-arm64", - ":windows_amd64": ":cc-mingw-amd64", - }), - toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", -) diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/WORKSPACE b/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/WORKSPACE deleted file mode 100644 index 34eee82882a3..000000000000 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/WORKSPACE +++ /dev/null @@ -1,2 +0,0 @@ -# DO NOT EDIT: automatically generated WORKSPACE file for prysm_toolchains rule -workspace(name = "prysm_toolchains") diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_linux_arm64.bzl b/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_linux_arm64.bzl deleted file mode 100755 index 9500d33d7745..000000000000 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_linux_arm64.bzl +++ /dev/null @@ -1,305 +0,0 @@ -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "feature", - "feature_set", - "flag_group", - "flag_set", - "make_variable", - "tool", - "tool_path", - "with_feature_set", -) - -load( - "@bazel_tools//tools/cpp:cc_toolchain_config.bzl", - ALL_COMPILE_ACTIONS = "all_compile_actions", - ALL_CPP_COMPILE_ACTIONS = "all_cpp_compile_actions", - ALL_LINK_ACTIONS = "all_link_actions", -) - -def _impl(ctx): - toolchain_identifier = "clang-linux-cross" - compiler = "clang" - abi_version = "clang" - abi_libc_version = "glibc_unknown" - target_libc = "glibc_unknown" - target_cpu = ctx.attr.target.split("-")[0] - - if (target_cpu == "aarch64"): - sysroot = "/usr/aarch64-linux-gnu" - include_path_prefix = sysroot - elif (target_cpu == "x86_64"): - sysroot = "/" - include_path_prefix = "/usr" - else: - fail("Unreachable") - - if (target_cpu == "aarch64"): - cross_system_include_dirs = [ - include_path_prefix + "/include/c++/v1", - include_path_prefix + "/lib/clang/12.0.0/include", - ] - else: - cross_system_include_dirs = [ - include_path_prefix + "/include/c++/v1", - include_path_prefix + "/lib/clang/12.0.0/include", - include_path_prefix + "/include/x86_64-linux-gnu", - ] - - cross_system_include_dirs += [ - include_path_prefix + "/include/", - include_path_prefix + "/include/linux", - include_path_prefix + "/include/asm", - include_path_prefix + "/include/asm-generic", - ] - - if (target_cpu == "aarch64"): - cross_system_lib_dirs = [ - "/usr/" + ctx.attr.target + "/lib", - ] - else: - cross_system_lib_dirs = [ - "/usr/lib/x86_64-linux-gnu/", - ] - - cross_system_lib_dirs += [ - "/usr/lib/gcc/x86_64-linux-gnu/8", - ] - - opt_feature = feature(name = "opt") - dbg_feature = feature(name = "dbg") - fastbuild_feature = feature(name = "fastbuild") - random_seed_feature = feature(name = "random_seed", enabled = True) - supports_pic_feature = feature(name = "supports_pic", enabled = True) - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], - ), - ], - ), - ], - ) - - # explicit arch specific system includes - system_include_flags = [] - for d in cross_system_include_dirs: - system_include_flags += ["-idirafter", d] - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "--target=" + ctx.attr.target, - "-nostdinc", - "-U_FORTIFY_SOURCE", - "-fstack-protector", - "-fno-omit-frame-pointer", - "-fcolor-diagnostics", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - ] + system_include_flags, - ), - ], - ), - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [flag_group(flags = ["-g", "-fstandalone-debug"])], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = ALL_CPP_COMPILE_ACTIONS, - flag_groups = [flag_group(flags = ["-std=c++17", "-nostdinc++"])], - ), - ], - ) - - additional_link_flags = [ - "-l:libc++.a", - "-l:libc++abi.a", - "-l:libunwind.a", - "-lpthread", - "-ldl", - "-rtlib=compiler-rt", - ] - - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = [ - flag_group( - flags = additional_link_flags + [ - "--target=" + ctx.attr.target, - "-lm", - "-no-canonical-prefixes", - "-fuse-ld=lld", - "-Wl,--build-id=md5", - "-Wl,--hash-style=gnu", - "-Wl,-z,relro,-z,now", - ] + ["-L" + d for d in cross_system_lib_dirs], - ), - ], - ), - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], - with_features = [with_feature_set(features = ["opt"])], - ), - ], - ) - - objcopy_embed_flags_feature = feature( - name = "objcopy_embed_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ["objcopy_embed_data"], - flag_groups = [flag_group(flags = ["-I", "binary"])], - ), - ], - ) - - user_compile_flags_feature = feature( - name = "user_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - expand_if_available = "user_compile_flags", - flags = ["%{user_compile_flags}"], - iterate_over = "user_compile_flags", - ), - ], - ), - ], - ) - - sysroot_feature = feature( - name = "sysroot", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS + ALL_LINK_ACTIONS, - flag_groups = [ - flag_group( - expand_if_available = "sysroot", - flags = ["--sysroot=%{sysroot}"], - ), - ], - ), - ], - ) - - coverage_feature = feature( - name = "coverage", - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], - ), - ], - ), - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = [flag_group(flags = ["-fprofile-instr-generate"])], - ), - ], - provides = ["profile"], - ) - - features = [ - opt_feature, - fastbuild_feature, - dbg_feature, - random_seed_feature, - supports_pic_feature, - supports_dynamic_linker_feature, - unfiltered_compile_flags_feature, - default_link_flags_feature, - default_compile_flags_feature, - objcopy_embed_flags_feature, - user_compile_flags_feature, - sysroot_feature, - coverage_feature, - ] - - tool_paths = [ - tool_path(name = "ld", path = "/usr/bin/ld.lld"), - tool_path(name = "cpp", path = "/usr/bin/clang-cpp"), - tool_path(name = "dwp", path = "/usr/bin/llvm-dwp"), - tool_path(name = "gcov", path = "/usr/bin/llvm-profdata"), - tool_path(name = "nm", path = "/usr/bin/llvm-nm"), - tool_path(name = "objcopy", path = "/usr/bin/llvm-objcopy"), - tool_path(name = "objdump", path = "/usr/bin/llvm-objdump"), - tool_path(name = "strip", path = "/usr/bin/strip"), - tool_path(name = "gcc", path = "/usr/bin/clang"), - tool_path(name = "ar", path = "/usr/bin/llvm-ar"), - ] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, - abi_version = abi_version, - abi_libc_version = abi_libc_version, - builtin_sysroot = sysroot, - compiler = compiler, - cxx_builtin_include_directories = cross_system_include_dirs, - host_system_name = "x86_64-unknown-linux-gnu", - target_cpu = target_cpu, - target_libc = target_libc, - target_system_name = ctx.attr.target, - tool_paths = tool_paths, - toolchain_identifier = toolchain_identifier, - ) - -arm64_cc_toolchain_config = rule( - implementation = _impl, - attrs = { - "target": attr.string(mandatory = True), - "stdlib": attr.string(), - }, - provides = [CcToolchainConfigInfo], -) diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_osx.bzl b/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_osx.bzl deleted file mode 100755 index ff619ef476a6..000000000000 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_osx.bzl +++ /dev/null @@ -1,260 +0,0 @@ -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "feature", - "feature_set", - "flag_group", - "flag_set", - "make_variable", - "tool", - "tool_path", - "with_feature_set", -) - -load( - "@bazel_tools//tools/cpp:cc_toolchain_config.bzl", - ALL_COMPILE_ACTIONS = "all_compile_actions", - ALL_CPP_COMPILE_ACTIONS = "all_cpp_compile_actions", - ALL_LINK_ACTIONS = "all_link_actions", -) - -def _impl(ctx): - toolchain_identifier = "osxcross" - compiler = "clang" - clang_version = "12.0.0" - target_libc = "macosx" - - target_cpu = ctx.attr.target_cpu - - osxcross = "/usr/osxcross/" - sdkroot = osxcross + "SDK/MacOSX12.3.sdk/" - - if (target_cpu == "aarch64"): - abi_version = "darwin_aarch64" - abi_libc_version = "darwin_aarch64" - osxcross_binprefix = osxcross + "bin/aarch64-apple-darwin21.4-" - tool_cpp = osxcross + "bin/oa64-clang++" - tool_gcc = osxcross + "bin/oa64-clang" - elif (target_cpu == "x86_64"): - abi_version = "darwin_x86_64" - abi_libc_version = "darwin_x86_64" - osxcross_binprefix = osxcross + "bin/x86_64-apple-darwin21.4-" - tool_cpp = osxcross + "bin/o64-clang++" - tool_gcc = osxcross + "bin/o64-clang" - else: - fail("Unreachable") - - cross_system_include_dirs = [ - "/usr/lib/clang/12.0.0/include", - osxcross + "include", - sdkroot + "usr/include", - ] - - opt_feature = feature(name = "opt") - dbg_feature = feature(name = "dbg") - fastbuild_feature = feature(name = "fastbuild") - random_seed_feature = feature(name = "random_seed", enabled = True) - supports_pic_feature = feature(name = "supports_pic", enabled = True) - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-stdlib=libc++", - "-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], - ), - ], - ), - ], - ) - - # explicit arch specific system includes - system_include_flags = [] - for d in cross_system_include_dirs: - system_include_flags += ["-idirafter", d] - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-mlinker-version=400", - "-B " + osxcross + "bin", - "-nostdinc", - "-U_FORTIFY_SOURCE", - "-fstack-protector", - "-fno-omit-frame-pointer", - "-fcolor-diagnostics", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - ] + system_include_flags, - ), - ], - ), - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [flag_group(flags = ["-g", "-fstandalone-debug"])], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = ALL_CPP_COMPILE_ACTIONS, - flag_groups = [flag_group(flags = ["-std=c++17", "-nostdinc++"])], - ), - ], - ) - - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = [ - flag_group( - flags = [ - "-v", - "-lm", - "-no-canonical-prefixes", - "-lc++", - "-lc++abi", - "-F" + sdkroot + "System/Library/Frameworks/", - "-L"+ sdkroot + "usr/lib", - "-undefined", - "dynamic_lookup", - ], - ), - ], - ), - ], - ) - - objcopy_embed_flags_feature = feature( - name = "objcopy_embed_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ["objcopy_embed_data"], - flag_groups = [flag_group(flags = ["-I", "binary"])], - ), - ], - ) - - user_compile_flags_feature = feature( - name = "user_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - expand_if_available = "user_compile_flags", - flags = ["%{user_compile_flags}"], - iterate_over = "user_compile_flags", - ), - ], - ), - ], - ) - - coverage_feature = feature( - name = "coverage", - flag_sets = [ - flag_set( - actions = ALL_COMPILE_ACTIONS, - flag_groups = [ - flag_group( - flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], - ), - ], - ), - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = [flag_group(flags = ["-fprofile-instr-generate"])], - ), - ], - provides = ["profile"], - ) - - features = [ - opt_feature, - fastbuild_feature, - dbg_feature, - random_seed_feature, - supports_pic_feature, - supports_dynamic_linker_feature, - unfiltered_compile_flags_feature, - default_link_flags_feature, - default_compile_flags_feature, - objcopy_embed_flags_feature, - user_compile_flags_feature, - coverage_feature, - ] - - tool_paths = [ - tool_path(name = "ld", path = osxcross_binprefix + "ld"), - tool_path(name = "cpp", path = tool_cpp), - tool_path(name = "dwp", path = "/usr/bin/dwp"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "nm", path = osxcross_binprefix + "nm"), - tool_path(name = "objdump", path = osxcross_binprefix + "ObjectDump"), - tool_path(name = "strip", path = osxcross_binprefix + "strip"), - tool_path(name = "gcc", path = tool_gcc), - tool_path(name = "ar", path = osxcross_binprefix + "libtool"), - ] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, - abi_version = abi_version, - abi_libc_version = abi_libc_version, - compiler = compiler, - cxx_builtin_include_directories = cross_system_include_dirs, - host_system_name = "x86_64-unknown-linux-gnu", - target_cpu = target_cpu, - target_libc = target_libc, - target_system_name = ctx.attr.target, - tool_paths = tool_paths, - toolchain_identifier = toolchain_identifier, - ) - -osx_cc_toolchain_config = rule( - implementation = _impl, - attrs = { - "target": attr.string(mandatory = True), - "target_cpu": attr.string(mandatory = True), - "stdlib": attr.string(), - }, - provides = [CcToolchainConfigInfo], -) diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_windows.bzl b/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_windows.bzl deleted file mode 100755 index 06ad0344c880..000000000000 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/prysm_toolchains/cc_toolchain_config_windows.bzl +++ /dev/null @@ -1,217 +0,0 @@ -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "feature", - "feature_set", - "flag_group", - "flag_set", - "make_variable", - "tool", - "tool_path", - "with_feature_set", - "artifact_name_pattern", - "env_set", - "env_entry", -) - -load( - "@bazel_tools//tools/cpp:cc_toolchain_config.bzl", - ALL_COMPILE_ACTIONS = "all_compile_actions", - ALL_CPP_COMPILE_ACTIONS = "all_cpp_compile_actions", - ALL_LINK_ACTIONS = "all_link_actions", -) - -load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") - -def _impl(ctx): - toolchain_identifier = "msys_x64_mingw" - host_system_name = "local" - target_system_name = "local" - target_cpu = "x64_windows" - target_libc = "mingw" - compiler = "mingw-gcc" - abi_version = "local" - abi_libc_version = "local" - cc_target_os = None - builtin_sysroot = None - action_configs = [] - - install = "/usr/x86_64-w64-mingw32/" - gcc_libpath = "/usr/lib/gcc/x86_64-w64-mingw32/10-win32/" - bin_prefix = "/usr/bin/x86_64-w64-mingw32-" - - - targets_windows_feature = feature( - name = "targets_windows", - implies = ["copy_dynamic_libraries_to_binary"], - enabled = True, - ) - - copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") - - gcc_env_feature = feature( - name = "gcc_env", - enabled = True, - env_sets = [ - env_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ACTION_NAMES.cpp_link_static_library, - ], - env_entries = [ - env_entry(key = "PATH", value = "NOT_USED"), - ], - ), - ], - ) - - msys_mingw_flags = [ - "-B " + install + "bin", - "-nostdinc", - "-U_FORTIFY_SOURCE", - "-fstack-protector", - "-fno-omit-frame-pointer", - "-fcolor-diagnostics", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-x c++", - "-lstdc++", - "-lpthread" - ] - - msys_mingw_link_flags = [ - "-l:libstdc++.a", - "-L" + install + "lib", - "-L/usr/lib/gcc/x86_64-w64-mingw32/8.3-w32", - "-v", - "-lm", - "-no-canonical-prefixes", - ] - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.lto_backend, - ACTION_NAMES.clif_match, - ], - ), - flag_set( - actions = [ - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.lto_backend, - ACTION_NAMES.clif_match, - ], - flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []), - ), - ], - ) - - compiler_param_file_feature = feature( - name = "compiler_param_file", - ) - - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ALL_LINK_ACTIONS, - flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []), - ), - ], - ) - - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - - features = [ - targets_windows_feature, - copy_dynamic_libraries_to_binary_feature, - gcc_env_feature, - default_compile_flags_feature, - compiler_param_file_feature, - default_link_flags_feature, - supports_dynamic_linker_feature, - ] - - cxx_builtin_include_directories = [ - install +"include", - gcc_libpath +"include", - gcc_libpath +"include-fixed", - "/usr/share/mingw-w64/include/" - ] - - artifact_name_patterns = [ - artifact_name_pattern( - category_name = "executable", - prefix = "", - extension = ".exe", - ), - ] - - make_variables = [] - tool_paths = [ - tool_path(name = "ld", path = bin_prefix + "ld"), - tool_path(name = "cpp", path = bin_prefix + "cpp"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "nm", path = bin_prefix + "nm"), - tool_path(name = "objcopy", path = bin_prefix + "objcopy"), - tool_path(name = "objdump", path = bin_prefix + "objdump"), - tool_path(name = "strip", path = bin_prefix + "strip"), - tool_path(name = "gcc", path = bin_prefix + "gcc"), - tool_path(name = "ar", path = bin_prefix + "ar"), - ] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, - action_configs = action_configs, - artifact_name_patterns = artifact_name_patterns, - cxx_builtin_include_directories = cxx_builtin_include_directories, - toolchain_identifier = toolchain_identifier, - host_system_name = host_system_name, - target_system_name = target_system_name, - target_cpu = target_cpu, - target_libc = target_libc, - compiler = compiler, - abi_version = abi_version, - abi_libc_version = abi_libc_version, - tool_paths = tool_paths, - make_variables = make_variables, - builtin_sysroot = builtin_sysroot, - cc_target_os = cc_target_os, - ) - -windows_cc_toolchain_config = rule( - implementation = _impl, - attrs = { - "target": attr.string(mandatory = True), - "stdlib": attr.string(), - }, - provides = [CcToolchainConfigInfo], -) - diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/config/BUILD b/tools/cross-toolchain/configs/config/BUILD old mode 100644 new mode 100755 similarity index 65% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/config/BUILD rename to tools/cross-toolchain/configs/config/BUILD index f5fde854de2e..b7494c959397 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/config/BUILD +++ b/tools/cross-toolchain/configs/config/BUILD @@ -1,4 +1,4 @@ -# Copyright 2016 The Bazel Authors. All rights reserved. +# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,36 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This file is auto-generated by an rbe_autoconfig repository rule +# This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen # and should not be modified directly. -# See @bazel_toolchains//rules:rbe_repo.bzl package(default_visibility = ["//visibility:public"]) + toolchain( name = "cc-toolchain", exec_compatible_with = [ - "@bazel_tools//platforms:x86_64", - "@bazel_tools//platforms:linux", + "@platforms//os:linux", + "@platforms//cpu:x86_64", "@bazel_tools//tools/cpp:clang", ], target_compatible_with = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", + "@platforms//os:linux", + "@platforms//cpu:x86_64", ], - toolchain = "//tools/cross-toolchain/configs/clang/bazel_5.3.0/cc:cc-compiler-k8", + toolchain = "//cc:cc-compiler-k8", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) platform( name = "platform", + parents = ["@local_config_platform//:host"], constraint_values = [ - "@bazel_tools//platforms:x86_64", - "@bazel_tools//platforms:linux", + "@platforms//os:linux", + "@platforms//cpu:x86_64", "@bazel_tools//tools/cpp:clang", ], exec_properties = { - "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:9e04c71268adeb4028b4016ca8cc02d134c2e5d7e3a53fdc68154d1797bb3d70", + "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:9a30c5ff7dcd1fbc5cb5b5f320782dec755a31cd2f6811e238a8584d94b04e78", "OSFamily": "Linux", }, ) diff --git a/tools/cross-toolchain/configs/clang/bazel_5.3.0/java/BUILD b/tools/cross-toolchain/configs/java/BUILD old mode 100644 new mode 100755 similarity index 63% rename from tools/cross-toolchain/configs/clang/bazel_5.3.0/java/BUILD rename to tools/cross-toolchain/configs/java/BUILD index ba80390fb6b3..97c3396f29f4 --- a/tools/cross-toolchain/configs/clang/bazel_5.3.0/java/BUILD +++ b/tools/cross-toolchain/configs/java/BUILD @@ -1,4 +1,4 @@ -# Copyright 2016 The Bazel Authors. All rights reserved. +# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,15 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This file is auto-generated by an rbe_autoconfig repository rule +# This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen # and should not be modified directly. -# See @bazel_toolchains//rules:rbe_repo.bzl + +load("@bazel_tools//tools/jdk:local_java_repository.bzl", "local_java_runtime") package(default_visibility = ["//visibility:public"]) -java_runtime( +alias( name = "jdk", - srcs = [], - java_home = "/usr/lib/jvm/java-8-openjdk-amd64", - tags = ["manual"], + actual = "rbe_jdk", +) + +local_java_runtime( + name = "rbe_jdk", + java_home = "/usr/lib/jvm/java-17-openjdk-amd64/", + version = "17.0.6", ) diff --git a/tools/cross-toolchain/configs/versions.bzl b/tools/cross-toolchain/configs/versions.bzl deleted file mode 100644 index 8b628468c94f..000000000000 --- a/tools/cross-toolchain/configs/versions.bzl +++ /dev/null @@ -1,16 +0,0 @@ -# Generated file, do not modify by hand -# Generated by 'rbe_ubuntu_clang_gen' rbe_autoconfig rule -"""Definitions to be used in rbe_repo attr of an rbe_autoconf rule """ -toolchain_config_spec0 = struct(config_repos = ["prysm_toolchains"], create_cc_configs = True, create_java_configs = True, env = {"BAZEL_COMPILER": "clang", "BAZEL_LINKLIBS": "-l%:libstdc++.a", "BAZEL_LINKOPTS": "-lm:-static-libgcc", "BAZEL_USE_LLVM_NATIVE_COVERAGE": "1", "GCOV": "llvm-profdata", "CC": "clang", "CXX": "clang++"}, java_home = "/usr/lib/jvm/java-8-openjdk-amd64", name = "clang") -_TOOLCHAIN_CONFIG_SPECS = [toolchain_config_spec0] -_BAZEL_TO_CONFIG_SPEC_NAMES = {"5.3.0": ["clang"]} -LATEST = "sha256:9e04c71268adeb4028b4016ca8cc02d134c2e5d7e3a53fdc68154d1797bb3d70" -CONTAINER_TO_CONFIG_SPEC_NAMES = {"sha256:9e04c71268adeb4028b4016ca8cc02d134c2e5d7e3a53fdc68154d1797bb3d70": ["clang"]} -_DEFAULT_TOOLCHAIN_CONFIG_SPEC = toolchain_config_spec0 -TOOLCHAIN_CONFIG_AUTOGEN_SPEC = struct( - bazel_to_config_spec_names_map = _BAZEL_TO_CONFIG_SPEC_NAMES, - container_to_config_spec_names_map = CONTAINER_TO_CONFIG_SPEC_NAMES, - default_toolchain_config_spec = _DEFAULT_TOOLCHAIN_CONFIG_SPEC, - latest_container = LATEST, - toolchain_config_specs = _TOOLCHAIN_CONFIG_SPECS, - ) \ No newline at end of file diff --git a/tools/cross-toolchain/cpp_env_clang.json b/tools/cross-toolchain/cpp_env_clang.json new file mode 100644 index 000000000000..be48c7c4b435 --- /dev/null +++ b/tools/cross-toolchain/cpp_env_clang.json @@ -0,0 +1,9 @@ +{ + "BAZEL_COMPILER": "clang", + "BAZEL_LINKLIBS": "-l%:libstdc++.a", + "BAZEL_LINKOPTS": "-lm:-static-libgcc", + "BAZEL_USE_LLVM_NATIVE_COVERAGE": "1", + "GCOV": "llvm-profdata", + "CC": "clang", + "CXX": "clang++" +} \ No newline at end of file diff --git a/tools/cross-toolchain/empty.bzl b/tools/cross-toolchain/empty.bzl deleted file mode 100644 index 3fc95e435327..000000000000 --- a/tools/cross-toolchain/empty.bzl +++ /dev/null @@ -1,18 +0,0 @@ -_BAZEL_TO_CONFIG_SPEC_NAMES = {} - -# sha256 digest of the latest version of the toolchain container. -LATEST = "" - -_CONTAINER_TO_CONFIG_SPEC_NAMES = {} - -_DEFAULT_TOOLCHAIN_CONFIG_SPEC = "" - -_TOOLCHAIN_CONFIG_SPECS = [] - -TOOLCHAIN_CONFIG_AUTOGEN_SPEC = struct( - bazel_to_config_spec_names_map = _BAZEL_TO_CONFIG_SPEC_NAMES, - container_to_config_spec_names_map = _CONTAINER_TO_CONFIG_SPEC_NAMES, - default_toolchain_config_spec = _DEFAULT_TOOLCHAIN_CONFIG_SPEC, - latest_container = LATEST, - toolchain_config_specs = _TOOLCHAIN_CONFIG_SPECS, -) diff --git a/tools/cross-toolchain/rbe_toolchains_config.bzl b/tools/cross-toolchain/rbe_toolchains_config.bzl deleted file mode 100644 index 5040b396e722..000000000000 --- a/tools/cross-toolchain/rbe_toolchains_config.bzl +++ /dev/null @@ -1,102 +0,0 @@ -load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") -load("@prysm//tools/cross-toolchain:configs/versions.bzl", _generated_toolchain_config_suite_autogen_spec = "TOOLCHAIN_CONFIG_AUTOGEN_SPEC") - -_PRYSM_BUILD_IMAGE_REGISTRY = "gcr.io" -_PRYSM_BUILD_IMAGE_REPOSITORY = "prysmaticlabs/rbe-worker" -_PRYSM_BUILD_IMAGE_DIGEST = "sha256:9e04c71268adeb4028b4016ca8cc02d134c2e5d7e3a53fdc68154d1797bb3d70" -_PRYSM_BUILD_IMAGE_JAVA_HOME = "/usr/lib/jvm/java-8-openjdk-amd64" -_CONFIGS_OUTPUT_BASE = "tools/cross-toolchain/configs" - -_CLANG_ENV = { - "BAZEL_COMPILER": "clang", - "BAZEL_LINKLIBS": "-l%:libstdc++.a", - "BAZEL_LINKOPTS": "-lm:-static-libgcc", - "BAZEL_USE_LLVM_NATIVE_COVERAGE": "1", - "GCOV": "llvm-profdata", - "CC": "clang", - "CXX": "clang++", -} - -_GCC_ENV = { - "BAZEL_COMPILER": "gcc", - "BAZEL_LINKLIBS": "-l%:libstdc++.a", - "BAZEL_LINKOPTS": "-lm:-static-libgcc", - "CC": "gcc", - "CXX": "g++", -} - -_TOOLCHAIN_CONFIG_SUITE_SPEC = { - "container_registry": _PRYSM_BUILD_IMAGE_REGISTRY, - "container_repo": _PRYSM_BUILD_IMAGE_REPOSITORY, - "output_base": _CONFIGS_OUTPUT_BASE, - "repo_name": "prysm", - "toolchain_config_suite_autogen_spec": _generated_toolchain_config_suite_autogen_spec, -} - -def _rbe_toolchains_generator(): - rbe_autoconfig( - name = "rbe_ubuntu_clang_gen", - digest = _PRYSM_BUILD_IMAGE_DIGEST, - export_configs = True, - java_home = _PRYSM_BUILD_IMAGE_JAVA_HOME, - registry = _PRYSM_BUILD_IMAGE_REGISTRY, - repository = _PRYSM_BUILD_IMAGE_REPOSITORY, - env = _CLANG_ENV, - toolchain_config_spec_name = "clang", - toolchain_config_suite_spec = _TOOLCHAIN_CONFIG_SUITE_SPEC, - use_checked_in_confs = "False", - config_repos = [ - "prysm_toolchains", - ], - use_legacy_platform_definition = False, - exec_compatible_with = [ - "@bazel_tools//platforms:x86_64", - "@bazel_tools//platforms:linux", - "@bazel_tools//tools/cpp:clang", - ], - ) - - rbe_autoconfig( - name = "rbe_ubuntu_gcc_gen", - digest = _PRYSM_BUILD_IMAGE_DIGEST, - export_configs = True, - java_home = _PRYSM_BUILD_IMAGE_JAVA_HOME, - registry = _PRYSM_BUILD_IMAGE_REGISTRY, - repository = _PRYSM_BUILD_IMAGE_REPOSITORY, - env = _GCC_ENV, - toolchain_config_spec_name = "gcc", - toolchain_config_suite_spec = _TOOLCHAIN_CONFIG_SUITE_SPEC, - use_checked_in_confs = "False", - config_repos = [ - "prysm_toolchains", - ], - use_legacy_platform_definition = False, - exec_compatible_with = [ - "@bazel_tools//platforms:x86_64", - "@bazel_tools//platforms:linux", - "@bazel_tools//tools/cpp:gcc", - ], - ) - -def _generated_rbe_toolchains(): - rbe_autoconfig( - name = "rbe_ubuntu_clang", - digest = _PRYSM_BUILD_IMAGE_DIGEST, - export_configs = True, - java_home = _PRYSM_BUILD_IMAGE_JAVA_HOME, - registry = _PRYSM_BUILD_IMAGE_REGISTRY, - repository = _PRYSM_BUILD_IMAGE_REPOSITORY, - toolchain_config_spec_name = "clang", - toolchain_config_suite_spec = _TOOLCHAIN_CONFIG_SUITE_SPEC, - use_checked_in_confs = "Force", - use_legacy_platform_definition = False, - exec_compatible_with = [ - "@bazel_tools//platforms:x86_64", - "@bazel_tools//platforms:linux", - "@bazel_tools//tools/cpp:clang", - ], - ) - -def rbe_toolchains_config(): - _rbe_toolchains_generator() - _generated_rbe_toolchains() diff --git a/tools/cross-toolchain/regenerate.sh b/tools/cross-toolchain/regenerate.sh deleted file mode 100755 index 6611489c663c..000000000000 --- a/tools/cross-toolchain/regenerate.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e - -export RBE_AUTOCONF_ROOT=$(bazel info workspace) - -rm -rf "${RBE_AUTOCONF_ROOT}/tools/cross-toolchain/configs/*" -cp -vf "${RBE_AUTOCONF_ROOT}/tools/cross-toolchain/empty.bzl" "${RBE_AUTOCONF_ROOT}/tools/cross-toolchain/configs/versions.bzl" - -# Bazel query is the right command so bazel won't fail itself. -bazel query "@rbe_ubuntu_clang_gen//..." From 3e4da860627fa9dbc50f666216f0bb6f29fe2798 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Wed, 1 Mar 2023 17:26:47 -0600 Subject: [PATCH 2/9] Remove some extra whitespaces --- tools/cross-toolchain/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 13b3ab3672bc..8fee4bad5133 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -40,11 +40,11 @@ rbe_configs_gen \ 4 Test the builds work locally for all supported platforms. ```bash - bazel build --config=release --config=linux_amd64 --config=llvm //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl - bazel build --config=release --config=linux_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl - bazel build --config=release --config=osx_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl - bazel build --config=release --config=osx_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl - bazel build --config=release --config=windows_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +bazel build --config=release --config=linux_amd64 --config=llvm //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +bazel build --config=release --config=linux_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +bazel build --config=release --config=osx_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +bazel build --config=release --config=osx_arm64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl +bazel build --config=release --config=windows_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl ``` 5 Add and commit the newly generated configs. From d99efd77125aa0889e7f3a88cf307fadfe786c14 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Wed, 1 Mar 2023 18:54:36 -0600 Subject: [PATCH 3/9] Run gazelle and add that note to the README --- tools/cross-toolchain/README.md | 10 +- tools/cross-toolchain/configs/cc/BUILD | 124 ++++++++++++--------- tools/cross-toolchain/configs/config/BUILD | 3 +- 3 files changed, 80 insertions(+), 57 deletions(-) diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 8fee4bad5133..6b462975dc0d 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -47,9 +47,15 @@ bazel build --config=release --config=osx_arm64_docker //cmd/beacon-chain //cmd/ bazel build --config=release --config=windows_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl ``` -5 Add and commit the newly generated configs. +5 Run gazelle. -6 Done! +```bash +bazel run //:gazelle +``` + +6 Add and commit the newly generated configs. + +7 Done! ### Cross compile target support diff --git a/tools/cross-toolchain/configs/cc/BUILD b/tools/cross-toolchain/configs/cc/BUILD index b0fcffc15e39..59437278b457 100644 --- a/tools/cross-toolchain/configs/cc/BUILD +++ b/tools/cross-toolchain/configs/cc/BUILD @@ -38,7 +38,10 @@ filegroup( filegroup( name = "compiler_deps", - srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths"], + srcs = glob( + ["extra_tools/**"], + allow_empty = True, + ) + [":builtin_include_directory_paths"], ) # This is the entry point for --crosstool_top. Toolchains are found @@ -56,40 +59,77 @@ cc_toolchain_suite( cc_toolchain( name = "cc-compiler-k8", - toolchain_identifier = "local", - toolchain_config = ":local", all_files = ":compiler_deps", ar_files = ":compiler_deps", as_files = ":compiler_deps", compiler_files = ":compiler_deps", dwp_files = ":empty", linker_files = ":compiler_deps", + module_map = ":module.modulemap", objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - module_map = ":module.modulemap", + toolchain_config = ":local", + toolchain_identifier = "local", ) cc_toolchain_config( name = "local", - cpu = "k8", + abi_libc_version = "local", + abi_version = "local", + compile_flags = [ + "-fstack-protector", + "-Wall", + "-Wthread-safety", + "-Wself-assign", + "-Wno-free-nonheap-object", + "-fcolor-diagnostics", + "-fno-omit-frame-pointer", + ], compiler = "clang", - toolchain_identifier = "local", + coverage_compile_flags = [ + "-fprofile-instr-generate", + "-fcoverage-mapping", + ], + coverage_link_flags = ["-fprofile-instr-generate"], + cpu = "k8", + cxx_builtin_include_directories = [ + "/usr/local/include", + "/usr/lib/clang/12.0.0/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "/usr/lib/clang/12.0.0/share", + "/usr/include/c++/10", + "/usr/include/x86_64-linux-gnu/c++/10", + "/usr/include/c++/10/backward", + "/usr/include/c++/v1", + ], + cxx_flags = ["-std=c++0x"], + dbg_compile_flags = ["-g"], host_system_name = "local", - target_system_name = "local", + link_flags = [ + "-fuse-ld=/usr/bin/ld.lld", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-B/usr/bin", + "-lm", + "-static-libgcc", + ], + link_libs = ["-l:libstdc++.a"], + opt_compile_flags = [ + "-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + ], + opt_link_flags = ["-Wl,--gc-sections"], + supports_start_end_lib = True, target_libc = "local", - abi_version = "local", - abi_libc_version = "local", - cxx_builtin_include_directories = ["/usr/local/include", - "/usr/lib/clang/12.0.0/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "/usr/lib/clang/12.0.0/share", - "/usr/include/c++/10", - "/usr/include/x86_64-linux-gnu/c++/10", - "/usr/include/c++/10/backward", - "/usr/include/c++/v1"], - tool_paths = {"ar": "/usr/bin/ar", + target_system_name = "local", + tool_paths = { + "ar": "/usr/bin/ar", "ld": "/usr/bin/ld", "llvm-cov": "/usr/bin/llvm-cov", "cpp": "/usr/bin/cpp", @@ -99,45 +139,21 @@ cc_toolchain_config( "nm": "/usr/bin/nm", "objcopy": "/usr/bin/objcopy", "objdump": "/usr/bin/objdump", - "strip": "/usr/bin/strip"}, - compile_flags = ["-fstack-protector", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-Wno-free-nonheap-object", - "-fcolor-diagnostics", - "-fno-omit-frame-pointer"], - opt_compile_flags = ["-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections"], - dbg_compile_flags = ["-g"], - cxx_flags = ["-std=c++0x"], - link_flags = ["-fuse-ld=/usr/bin/ld.lld", - "-Wl,-no-as-needed", - "-Wl,-z,relro,-z,now", - "-B/usr/bin", - "-lm", - "-static-libgcc"], - link_libs = ["-l:libstdc++.a"], - opt_link_flags = ["-Wl,--gc-sections"], - unfiltered_compile_flags = ["-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\""], - coverage_compile_flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], - coverage_link_flags = ["-fprofile-instr-generate"], - supports_start_end_lib = True, + "strip": "/usr/bin/strip", + }, + toolchain_identifier = "local", + unfiltered_compile_flags = [ + "-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + ], ) # Android tooling requires a default toolchain for the armeabi-v7a cpu. cc_toolchain( name = "cc-compiler-armeabi-v7a", - toolchain_identifier = "stub_armeabi-v7a", - toolchain_config = ":stub_armeabi-v7a", all_files = ":empty", ar_files = ":empty", as_files = ":empty", @@ -147,6 +163,8 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, + toolchain_config = ":stub_armeabi-v7a", + toolchain_identifier = "stub_armeabi-v7a", ) armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") diff --git a/tools/cross-toolchain/configs/config/BUILD b/tools/cross-toolchain/configs/config/BUILD index b7494c959397..4d095db65d18 100755 --- a/tools/cross-toolchain/configs/config/BUILD +++ b/tools/cross-toolchain/configs/config/BUILD @@ -17,7 +17,6 @@ package(default_visibility = ["//visibility:public"]) - toolchain( name = "cc-toolchain", exec_compatible_with = [ @@ -35,7 +34,6 @@ toolchain( platform( name = "platform", - parents = ["@local_config_platform//:host"], constraint_values = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -45,4 +43,5 @@ platform( "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:9a30c5ff7dcd1fbc5cb5b5f320782dec755a31cd2f6811e238a8584d94b04e78", "OSFamily": "Linux", }, + parents = ["@local_config_platform//:host"], ) From ee2dde0380fbff0335207b4538b986369e6d78c6 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Thu, 2 Mar 2023 09:51:17 -0600 Subject: [PATCH 4/9] Format numbered lists better in markdown --- tools/cross-toolchain/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 6b462975dc0d..4b48290fbce4 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -13,16 +13,16 @@ This toolchain suite describes cross compile configuration with a Dockerfile wit ### Updating the toolchain suite -1 Build and push the worker docker image, if necessary. +1) Build and push the worker docker image, if necessary. ```bash docker build -t gcr.io/prysmaticlabs/rbe-worker:latest tools/cross-toolchain/. gcloud docker -- push gcr.io/prysmaticlabs/rbe-worker:latest ``` -2 Note the docker image sha256 digest from the recently pushed image or use the latest one available. +2) Note the docker image sha256 digest from the recently pushed image or use the latest one available. -3 Download and run [rbe_configs_gen](https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs) CLI tool. +3) Download and run [rbe_configs_gen](https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs) CLI tool. ```bash # Run from the root of the Prysm repo. @@ -37,7 +37,7 @@ rbe_configs_gen \ --toolchain_container=gcr.io/prysmaticlabs/rbe-worker@sha256:9a30c5ff7dcd1fbc5cb5b5f320782dec755a31cd2f6811e238a8584d94b04e78 # The sha256 digest from step 2. ``` -4 Test the builds work locally for all supported platforms. +4) Test the builds work locally for all supported platforms. ```bash bazel build --config=release --config=linux_amd64 --config=llvm //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl @@ -47,15 +47,15 @@ bazel build --config=release --config=osx_arm64_docker //cmd/beacon-chain //cmd/ bazel build --config=release --config=windows_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats //cmd/prysmctl ``` -5 Run gazelle. +5) Run gazelle. ```bash bazel run //:gazelle ``` -6 Add and commit the newly generated configs. +6) Add and commit the newly generated configs. -7 Done! +7) Done! ### Cross compile target support From 01d49e7cf71df8b69250d75f0d3d766db5dbb423 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Thu, 2 Mar 2023 09:52:10 -0600 Subject: [PATCH 5/9] gcloud docker command is deprecated, just use docker --- tools/cross-toolchain/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 4b48290fbce4..005c3d929183 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -17,7 +17,7 @@ This toolchain suite describes cross compile configuration with a Dockerfile wit ```bash docker build -t gcr.io/prysmaticlabs/rbe-worker:latest tools/cross-toolchain/. -gcloud docker -- push gcr.io/prysmaticlabs/rbe-worker:latest +docker push gcr.io/prysmaticlabs/rbe-worker:latest ``` 2) Note the docker image sha256 digest from the recently pushed image or use the latest one available. From 7ec5eb02d0400ad8b7088c545c5338257879a4f2 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Thu, 2 Mar 2023 09:53:42 -0600 Subject: [PATCH 6/9] Add comment about docker credentials for gcr.io --- tools/cross-toolchain/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/cross-toolchain/README.md b/tools/cross-toolchain/README.md index 005c3d929183..4054cd2aa3cd 100644 --- a/tools/cross-toolchain/README.md +++ b/tools/cross-toolchain/README.md @@ -20,6 +20,8 @@ docker build -t gcr.io/prysmaticlabs/rbe-worker:latest tools/cross-toolchain/. docker push gcr.io/prysmaticlabs/rbe-worker:latest ``` +Note: You must configured your gcr access credentials to push to gcr.io/prysmaticlabs. Run `gcloud auth configure-docker` or contact SRE team for push access. + 2) Note the docker image sha256 digest from the recently pushed image or use the latest one available. 3) Download and run [rbe_configs_gen](https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs) CLI tool. From 317eb00c8829ab7360dea3b52d3ca6bae062a5d1 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Fri, 3 Mar 2023 04:04:33 -0600 Subject: [PATCH 7/9] Update dockerfile, some remote executor config work --- beacon-chain/package/BUILD.bazel | 1 + build/bazelrc/cross.bazelrc | 23 ++-- tools/cross-toolchain/Dockerfile | 2 +- tools/cross-toolchain/configs/cc/BUILD | 124 +++++++++------------ tools/cross-toolchain/configs/config/BUILD | 5 +- validator/package/BUILD.bazel | 1 + 6 files changed, 73 insertions(+), 83 deletions(-) diff --git a/beacon-chain/package/BUILD.bazel b/beacon-chain/package/BUILD.bazel index 7d2621b0cb04..6311564f1c17 100644 --- a/beacon-chain/package/BUILD.bazel +++ b/beacon-chain/package/BUILD.bazel @@ -48,4 +48,5 @@ pkg_deb( preinst = "preinst.sh", version_file = "//runtime:version_file", visibility = ["//beacon-chain:__pkg__"], + tags = ["no-remote"], ) diff --git a/build/bazelrc/cross.bazelrc b/build/bazelrc/cross.bazelrc index 7e84d3df4e95..dd73c47f0efd 100644 --- a/build/bazelrc/cross.bazelrc +++ b/build/bazelrc/cross.bazelrc @@ -1,9 +1,13 @@ # multi-arch cross-compiling toolchain configs ----------------------------------------------- +#build:cross --crosstool_top=@//tools/cross-toolchain/configs/cc:toolchain build:cross --crosstool_top=@prysm_toolchains//:multiarch_toolchain -build:cross --host_platform=@io_bazel_rules_go//go/toolchain:linux_amd64 +build:cross --extra_execution_platforms=@//tools/cross-toolchain/configs/config:platform +build:cross --extra_toolchains=@prysm_toolchains//:cc-toolchain-multiarch build:cross --host_crosstool_top=@prysm_toolchains//:hostonly_toolchain +#build:cross --host_platform=@//tools/cross-toolchain/configs/config:platform +build:cross --platforms=@//tools/cross-toolchain/configs/config:platform # linux_amd64 config for cross compiler toolchain, not strictly necessary since host/exec env is amd64 build:linux_amd64 --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo @@ -21,10 +25,10 @@ build:osx_arm64 --cpu=aarch64 # windows build:windows_amd64 --config=cross -build:windows_amd64 --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64_cgo +build:windows_amd64 --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64_cgo build:windows_amd64 --compiler=mingw-w64 -# linux_arm64 conifg for cross compiler toolchain +# linux_arm64 config for cross compiler toolchain build:linux_arm64 --config=cross build:linux_arm64 --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64_cgo build:linux_arm64 --copt=-funsafe-math-optimizations @@ -38,16 +42,17 @@ build:linux_arm64 --copt=-march=armv8-a # Docker Sandbox Configs #----------------------- # Note all docker sandbox configs must run from a linux x86_64 host -# build:docker-sandbox --experimental_docker_image=gcr.io/prysmaticlabs/rbe-worker:latest +build:docker-sandbox --unconditional_warning="⚠️ Docker sandbox is extremely slow! Consider a remote executor, if possible. See tools/cross-toolchain/README.md#Caveats ⚠️" build:docker-sandbox --spawn_strategy=docker --strategy=Javac=docker --genrule_strategy=docker build:docker-sandbox --define=EXECUTOR=remote build:docker-sandbox --experimental_docker_verbose build:docker-sandbox --experimental_enable_docker_sandbox -build:docker-sandbox --crosstool_top=@//tools/cross-toolchain/configs/cc:toolchain -build:docker-sandbox --extra_execution_platforms=@//tools/cross-toolchain/configs/config:platform -build:docker-sandbox --host_platform=@//tools/cross-toolchain/configs/config:platform -build:docker-sandbox --platforms=@//tools/cross-toolchain/configs/config:platform -build:docker-sandbox --extra_toolchains=@prysm_toolchains//:cc-toolchain-multiarch + +# Remote with docker sandbox fallback +build:remote --spawn_strategy=remote,docker,linux-sandbox --strategy=Javac=remote,docker,linux-sandbox --genrule_strategy=remote,docker,linux-sandbox +build:remote --define=EXECUTOR=remote +build:remote --experimental_docker_verbose +build:remote --experimental_enable_docker_sandbox # windows_amd64 docker sandbox build config build:windows_amd64_docker --config=docker-sandbox --config=windows_amd64 diff --git a/tools/cross-toolchain/Dockerfile b/tools/cross-toolchain/Dockerfile index c783812df942..d1b79887654e 100644 --- a/tools/cross-toolchain/Dockerfile +++ b/tools/cross-toolchain/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update && \ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ cmake libssl-dev libxml2-dev vim apt-transport-https \ zip unzip libtinfo5 patch zlib1g-dev autoconf libtool \ - pkg-config make docker.io gnupg2 libgmp-dev python openjdk-17-jdk-headless + pkg-config make docker.io gnupg2 libgmp-dev python3 openjdk-17-jdk-headless # install llvm/clang cross-build toolchains ENV INSTALL_LLVM_VERSION=12.0.0 diff --git a/tools/cross-toolchain/configs/cc/BUILD b/tools/cross-toolchain/configs/cc/BUILD index 59437278b457..b0fcffc15e39 100644 --- a/tools/cross-toolchain/configs/cc/BUILD +++ b/tools/cross-toolchain/configs/cc/BUILD @@ -38,10 +38,7 @@ filegroup( filegroup( name = "compiler_deps", - srcs = glob( - ["extra_tools/**"], - allow_empty = True, - ) + [":builtin_include_directory_paths"], + srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths"], ) # This is the entry point for --crosstool_top. Toolchains are found @@ -59,77 +56,40 @@ cc_toolchain_suite( cc_toolchain( name = "cc-compiler-k8", + toolchain_identifier = "local", + toolchain_config = ":local", all_files = ":compiler_deps", ar_files = ":compiler_deps", as_files = ":compiler_deps", compiler_files = ":compiler_deps", dwp_files = ":empty", linker_files = ":compiler_deps", - module_map = ":module.modulemap", objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - toolchain_config = ":local", - toolchain_identifier = "local", + module_map = ":module.modulemap", ) cc_toolchain_config( name = "local", - abi_libc_version = "local", - abi_version = "local", - compile_flags = [ - "-fstack-protector", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-Wno-free-nonheap-object", - "-fcolor-diagnostics", - "-fno-omit-frame-pointer", - ], - compiler = "clang", - coverage_compile_flags = [ - "-fprofile-instr-generate", - "-fcoverage-mapping", - ], - coverage_link_flags = ["-fprofile-instr-generate"], cpu = "k8", - cxx_builtin_include_directories = [ - "/usr/local/include", - "/usr/lib/clang/12.0.0/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "/usr/lib/clang/12.0.0/share", - "/usr/include/c++/10", - "/usr/include/x86_64-linux-gnu/c++/10", - "/usr/include/c++/10/backward", - "/usr/include/c++/v1", - ], - cxx_flags = ["-std=c++0x"], - dbg_compile_flags = ["-g"], + compiler = "clang", + toolchain_identifier = "local", host_system_name = "local", - link_flags = [ - "-fuse-ld=/usr/bin/ld.lld", - "-Wl,-no-as-needed", - "-Wl,-z,relro,-z,now", - "-B/usr/bin", - "-lm", - "-static-libgcc", - ], - link_libs = ["-l:libstdc++.a"], - opt_compile_flags = [ - "-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - opt_link_flags = ["-Wl,--gc-sections"], - supports_start_end_lib = True, - target_libc = "local", target_system_name = "local", - tool_paths = { - "ar": "/usr/bin/ar", + target_libc = "local", + abi_version = "local", + abi_libc_version = "local", + cxx_builtin_include_directories = ["/usr/local/include", + "/usr/lib/clang/12.0.0/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "/usr/lib/clang/12.0.0/share", + "/usr/include/c++/10", + "/usr/include/x86_64-linux-gnu/c++/10", + "/usr/include/c++/10/backward", + "/usr/include/c++/v1"], + tool_paths = {"ar": "/usr/bin/ar", "ld": "/usr/bin/ld", "llvm-cov": "/usr/bin/llvm-cov", "cpp": "/usr/bin/cpp", @@ -139,21 +99,45 @@ cc_toolchain_config( "nm": "/usr/bin/nm", "objcopy": "/usr/bin/objcopy", "objdump": "/usr/bin/objdump", - "strip": "/usr/bin/strip", - }, - toolchain_identifier = "local", - unfiltered_compile_flags = [ - "-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], + "strip": "/usr/bin/strip"}, + compile_flags = ["-fstack-protector", + "-Wall", + "-Wthread-safety", + "-Wself-assign", + "-Wno-free-nonheap-object", + "-fcolor-diagnostics", + "-fno-omit-frame-pointer"], + opt_compile_flags = ["-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections"], + dbg_compile_flags = ["-g"], + cxx_flags = ["-std=c++0x"], + link_flags = ["-fuse-ld=/usr/bin/ld.lld", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-B/usr/bin", + "-lm", + "-static-libgcc"], + link_libs = ["-l:libstdc++.a"], + opt_link_flags = ["-Wl,--gc-sections"], + unfiltered_compile_flags = ["-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\""], + coverage_compile_flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], + coverage_link_flags = ["-fprofile-instr-generate"], + supports_start_end_lib = True, ) # Android tooling requires a default toolchain for the armeabi-v7a cpu. cc_toolchain( name = "cc-compiler-armeabi-v7a", + toolchain_identifier = "stub_armeabi-v7a", + toolchain_config = ":stub_armeabi-v7a", all_files = ":empty", ar_files = ":empty", as_files = ":empty", @@ -163,8 +147,6 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - toolchain_config = ":stub_armeabi-v7a", - toolchain_identifier = "stub_armeabi-v7a", ) armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") diff --git a/tools/cross-toolchain/configs/config/BUILD b/tools/cross-toolchain/configs/config/BUILD index 4d095db65d18..d00c5cf47189 100755 --- a/tools/cross-toolchain/configs/config/BUILD +++ b/tools/cross-toolchain/configs/config/BUILD @@ -17,6 +17,7 @@ package(default_visibility = ["//visibility:public"]) + toolchain( name = "cc-toolchain", exec_compatible_with = [ @@ -34,14 +35,14 @@ toolchain( platform( name = "platform", + parents = ["@local_config_platform//:host"], constraint_values = [ "@platforms//os:linux", "@platforms//cpu:x86_64", "@bazel_tools//tools/cpp:clang", ], exec_properties = { - "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:9a30c5ff7dcd1fbc5cb5b5f320782dec755a31cd2f6811e238a8584d94b04e78", + "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:90d490709a0fb0c817569f37408823a0490e5502cbecc36415caabfc36a0c2e8", "OSFamily": "Linux", }, - parents = ["@local_config_platform//:host"], ) diff --git a/validator/package/BUILD.bazel b/validator/package/BUILD.bazel index 52e66cb60dd9..09373bae38ef 100644 --- a/validator/package/BUILD.bazel +++ b/validator/package/BUILD.bazel @@ -48,4 +48,5 @@ pkg_deb( preinst = "preinst.sh", version_file = "//runtime:version_file", visibility = ["//validator:__pkg__"], + tags = ["no-remote"], ) From 170f4998fb9a32dc37dafa05485a847f9cb57af2 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 6 Mar 2023 10:18:30 -0600 Subject: [PATCH 8/9] gazelle --- beacon-chain/package/BUILD.bazel | 2 +- tools/cross-toolchain/configs/cc/BUILD | 124 ++++++++++++--------- tools/cross-toolchain/configs/config/BUILD | 3 +- validator/package/BUILD.bazel | 2 +- 4 files changed, 74 insertions(+), 57 deletions(-) diff --git a/beacon-chain/package/BUILD.bazel b/beacon-chain/package/BUILD.bazel index 6311564f1c17..fc30c9b5683d 100644 --- a/beacon-chain/package/BUILD.bazel +++ b/beacon-chain/package/BUILD.bazel @@ -46,7 +46,7 @@ pkg_deb( package = "prysm-beacon-chain", postinst = "postinst.sh", preinst = "preinst.sh", + tags = ["no-remote"], version_file = "//runtime:version_file", visibility = ["//beacon-chain:__pkg__"], - tags = ["no-remote"], ) diff --git a/tools/cross-toolchain/configs/cc/BUILD b/tools/cross-toolchain/configs/cc/BUILD index b0fcffc15e39..59437278b457 100644 --- a/tools/cross-toolchain/configs/cc/BUILD +++ b/tools/cross-toolchain/configs/cc/BUILD @@ -38,7 +38,10 @@ filegroup( filegroup( name = "compiler_deps", - srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths"], + srcs = glob( + ["extra_tools/**"], + allow_empty = True, + ) + [":builtin_include_directory_paths"], ) # This is the entry point for --crosstool_top. Toolchains are found @@ -56,40 +59,77 @@ cc_toolchain_suite( cc_toolchain( name = "cc-compiler-k8", - toolchain_identifier = "local", - toolchain_config = ":local", all_files = ":compiler_deps", ar_files = ":compiler_deps", as_files = ":compiler_deps", compiler_files = ":compiler_deps", dwp_files = ":empty", linker_files = ":compiler_deps", + module_map = ":module.modulemap", objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - module_map = ":module.modulemap", + toolchain_config = ":local", + toolchain_identifier = "local", ) cc_toolchain_config( name = "local", - cpu = "k8", + abi_libc_version = "local", + abi_version = "local", + compile_flags = [ + "-fstack-protector", + "-Wall", + "-Wthread-safety", + "-Wself-assign", + "-Wno-free-nonheap-object", + "-fcolor-diagnostics", + "-fno-omit-frame-pointer", + ], compiler = "clang", - toolchain_identifier = "local", + coverage_compile_flags = [ + "-fprofile-instr-generate", + "-fcoverage-mapping", + ], + coverage_link_flags = ["-fprofile-instr-generate"], + cpu = "k8", + cxx_builtin_include_directories = [ + "/usr/local/include", + "/usr/lib/clang/12.0.0/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "/usr/lib/clang/12.0.0/share", + "/usr/include/c++/10", + "/usr/include/x86_64-linux-gnu/c++/10", + "/usr/include/c++/10/backward", + "/usr/include/c++/v1", + ], + cxx_flags = ["-std=c++0x"], + dbg_compile_flags = ["-g"], host_system_name = "local", - target_system_name = "local", + link_flags = [ + "-fuse-ld=/usr/bin/ld.lld", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-B/usr/bin", + "-lm", + "-static-libgcc", + ], + link_libs = ["-l:libstdc++.a"], + opt_compile_flags = [ + "-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + ], + opt_link_flags = ["-Wl,--gc-sections"], + supports_start_end_lib = True, target_libc = "local", - abi_version = "local", - abi_libc_version = "local", - cxx_builtin_include_directories = ["/usr/local/include", - "/usr/lib/clang/12.0.0/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "/usr/lib/clang/12.0.0/share", - "/usr/include/c++/10", - "/usr/include/x86_64-linux-gnu/c++/10", - "/usr/include/c++/10/backward", - "/usr/include/c++/v1"], - tool_paths = {"ar": "/usr/bin/ar", + target_system_name = "local", + tool_paths = { + "ar": "/usr/bin/ar", "ld": "/usr/bin/ld", "llvm-cov": "/usr/bin/llvm-cov", "cpp": "/usr/bin/cpp", @@ -99,45 +139,21 @@ cc_toolchain_config( "nm": "/usr/bin/nm", "objcopy": "/usr/bin/objcopy", "objdump": "/usr/bin/objdump", - "strip": "/usr/bin/strip"}, - compile_flags = ["-fstack-protector", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-Wno-free-nonheap-object", - "-fcolor-diagnostics", - "-fno-omit-frame-pointer"], - opt_compile_flags = ["-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections"], - dbg_compile_flags = ["-g"], - cxx_flags = ["-std=c++0x"], - link_flags = ["-fuse-ld=/usr/bin/ld.lld", - "-Wl,-no-as-needed", - "-Wl,-z,relro,-z,now", - "-B/usr/bin", - "-lm", - "-static-libgcc"], - link_libs = ["-l:libstdc++.a"], - opt_link_flags = ["-Wl,--gc-sections"], - unfiltered_compile_flags = ["-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\""], - coverage_compile_flags = ["-fprofile-instr-generate", "-fcoverage-mapping"], - coverage_link_flags = ["-fprofile-instr-generate"], - supports_start_end_lib = True, + "strip": "/usr/bin/strip", + }, + toolchain_identifier = "local", + unfiltered_compile_flags = [ + "-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + ], ) # Android tooling requires a default toolchain for the armeabi-v7a cpu. cc_toolchain( name = "cc-compiler-armeabi-v7a", - toolchain_identifier = "stub_armeabi-v7a", - toolchain_config = ":stub_armeabi-v7a", all_files = ":empty", ar_files = ":empty", as_files = ":empty", @@ -147,6 +163,8 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, + toolchain_config = ":stub_armeabi-v7a", + toolchain_identifier = "stub_armeabi-v7a", ) armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") diff --git a/tools/cross-toolchain/configs/config/BUILD b/tools/cross-toolchain/configs/config/BUILD index d00c5cf47189..2601c11b7395 100755 --- a/tools/cross-toolchain/configs/config/BUILD +++ b/tools/cross-toolchain/configs/config/BUILD @@ -17,7 +17,6 @@ package(default_visibility = ["//visibility:public"]) - toolchain( name = "cc-toolchain", exec_compatible_with = [ @@ -35,7 +34,6 @@ toolchain( platform( name = "platform", - parents = ["@local_config_platform//:host"], constraint_values = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -45,4 +43,5 @@ platform( "container-image": "docker://gcr.io/prysmaticlabs/rbe-worker@sha256:90d490709a0fb0c817569f37408823a0490e5502cbecc36415caabfc36a0c2e8", "OSFamily": "Linux", }, + parents = ["@local_config_platform//:host"], ) diff --git a/validator/package/BUILD.bazel b/validator/package/BUILD.bazel index 09373bae38ef..d86da5942a8b 100644 --- a/validator/package/BUILD.bazel +++ b/validator/package/BUILD.bazel @@ -46,7 +46,7 @@ pkg_deb( package = "prysm-validator", postinst = "postinst.sh", preinst = "preinst.sh", + tags = ["no-remote"], version_file = "//runtime:version_file", visibility = ["//validator:__pkg__"], - tags = ["no-remote"], ) From 83ed2c00e1808bd2fd28b7f678d8f4d0cbfeda12 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Tue, 7 Mar 2023 12:33:25 -0600 Subject: [PATCH 9/9] Remove commented lines --- build/bazelrc/cross.bazelrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/bazelrc/cross.bazelrc b/build/bazelrc/cross.bazelrc index dd73c47f0efd..84e46b69d9de 100644 --- a/build/bazelrc/cross.bazelrc +++ b/build/bazelrc/cross.bazelrc @@ -1,12 +1,10 @@ # multi-arch cross-compiling toolchain configs ----------------------------------------------- -#build:cross --crosstool_top=@//tools/cross-toolchain/configs/cc:toolchain build:cross --crosstool_top=@prysm_toolchains//:multiarch_toolchain build:cross --extra_execution_platforms=@//tools/cross-toolchain/configs/config:platform build:cross --extra_toolchains=@prysm_toolchains//:cc-toolchain-multiarch build:cross --host_crosstool_top=@prysm_toolchains//:hostonly_toolchain -#build:cross --host_platform=@//tools/cross-toolchain/configs/config:platform build:cross --platforms=@//tools/cross-toolchain/configs/config:platform # linux_amd64 config for cross compiler toolchain, not strictly necessary since host/exec env is amd64