diff --git a/.bazelrc b/.bazelrc index 5fb5d1628c..e5da1791dd 100644 --- a/.bazelrc +++ b/.bazelrc @@ -47,3 +47,4 @@ build:aarch64 --cpu=aarch64 build:aarch64 --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 common --noenable_bzlmod +common --enable_workspace diff --git a/.bazelversion b/.bazelversion new file mode 120000 index 0000000000..3ac12331e1 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +images/default/bazelversion \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index 7eae69ead5..c8ea8aa7ac 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -65,10 +65,10 @@ http_archive( # Export .x files. "//tools:rules_go_export.patch", ], - sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0", + sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip", + "https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip", + "https://github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip", ], ) @@ -89,12 +89,32 @@ switched_rules_by_language( go = False, # Disable building proto Go libraries; use org_golang_google_genproto instead. ) +# rules_python needed by bazel_gazelle +http_archive( + name = "rules_python", + sha256 = "fa532d635f29c038a64c8062724af700c30cf6b31174dd4fac120bc561a1a560", + strip_prefix = "rules_python-1.5.1", + url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.1/rules_python-1.5.1.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + +# Load C++ rules. Needs to come early because something else pulls in an older +# version of rules_cc which is incompatible with Bazel 8. +http_archive( + name = "rules_cc", + sha256 = "0d3b4f984c4c2e1acfd1378e0148d35caf2ef1d9eb95b688f8e19ce0c41bdf5b", + strip_prefix = "rules_cc-0.1.4", + url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.4/rules_cc-0.1.4.tar.gz", +) + http_archive( name = "bazel_gazelle", - sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209", + sha256 = "49b14c691ceec841f445f8642d28336e99457d1db162092fd5082351ea302f1d", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz", + "https://github.com/bazel-contrib/bazel-gazelle/releases/download/v0.44.0/bazel-gazelle-v0.44.0.tar.gz" ], ) @@ -386,19 +406,14 @@ go_repository( version = "v1.67.1", ) -# Load C++ rules. -http_archive( - name = "rules_cc", - sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1", - strip_prefix = "rules_cc-0.0.17", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"], -) - -# Load C++ cross-compilation toolchains. +# # Load C++ cross-compilation toolchains. http_archive( name = "coral_crosstool", patch_args = ["-p1"], - patches = ["//tools:crosstool-arm-dirs.patch"], + patches = [ + "//tools:crosstool-arm-dirs.patch", + "//tools:remove_windows_deps.patch", + ], sha256 = "f86d488ca353c5ee99187579fe408adb73e9f2bb1d69c6e3a42ffb904ce3ba01", strip_prefix = "crosstool-8e885509123395299bed6a5f9529fdc1b9751599", urls = [ @@ -429,9 +444,9 @@ http_archive( ) # Load LLVM dependencies. -LLVM_COMMIT = "926f85db98aae66ab8f57b9981f47ddddb868c51" +LLVM_COMMIT = "cbcb48a88c3a6227cfc09f91880d5cb92a26f5f9" -LLVM_SHA256 = "c78c94b2a03b2cf6ef1ba035c31a6f1b0bb7913da8af5aa8d5c2061f6499d589" +LLVM_SHA256 = "356cb88e5975104628494bd02b8edef1889ea30a7dbe96b5abe6ad74ed8ba74b" http_archive( name = "llvm-raw", @@ -479,6 +494,15 @@ http_archive( ], ) +# rules_java needed for rules_proto and grpc both. +http_archive( + name = "rules_java", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/8.6.2/rules_java-8.6.2.tar.gz", + ], + sha256 = "a64ab04616e76a448c2c2d8165d836f0d2fb0906200d0b7c7376f46dd62e59cc", +) + http_archive( name = "com_google_protobuf", sha256 = "e7a50ac2a8ae3754c6f1ab6123424627920e4abddd894ee4bc47d6506e86aeb9", @@ -1759,10 +1783,6 @@ go_repository( version = "v56.0.0", ) -rules_proto_dependencies() - -rules_proto_toolchains() - http_archive( name = "rules_pkg", sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66", diff --git a/images/default/Dockerfile b/images/default/Dockerfile index 15fdfad526..5fe14d58a2 100644 --- a/images/default/Dockerfile +++ b/images/default/Dockerfile @@ -30,6 +30,7 @@ RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud ln -s /google-cloud-sdk/bin/gcloud /usr/bin/gcloud # Download the official bazel binary. The APT repository isn't used because there is not packages for arm64. -RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/7.5.0/release/bazel-7.5.0-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel' +COPY bazelversion . +RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/$(cat ./bazelversion)/release/bazel-$(cat ./bazelversion)-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel' WORKDIR /workspace ENTRYPOINT ["/usr/local/bin/bazel"] diff --git a/images/default/bazelversion b/images/default/bazelversion new file mode 100644 index 0000000000..905c243928 --- /dev/null +++ b/images/default/bazelversion @@ -0,0 +1 @@ +8.3.1 \ No newline at end of file diff --git a/tools/bazeldefs/cc.bzl b/tools/bazeldefs/cc.bzl index 4dbddc4eca..fa98ba81e2 100644 --- a/tools/bazeldefs/cc.bzl +++ b/tools/bazeldefs/cc.bzl @@ -1,7 +1,8 @@ """C++ rules.""" load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", _cc_grpc_library = "cc_grpc_library") -load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test") +load("@com_google_protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") +load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_test = "cc_test") cc_library = _cc_library cc_proto_library = _cc_proto_library @@ -11,7 +12,6 @@ gtest = "@com_google_googletest//:gtest" gbenchmark = "@com_google_benchmark//:benchmark" gbenchmark_internal = "@com_google_benchmark//:benchmark" grpcpp = "@com_github_grpc_grpc//:grpc++" -vdso_linker_option = "-fuse-ld=gold " def _cc_flags_supplier_impl(ctx): variables = platform_common.TemplateVariableInfo({ diff --git a/tools/bazeldefs/go.bzl b/tools/bazeldefs/go.bzl index d607637585..d94e13dfcd 100644 --- a/tools/bazeldefs/go.bzl +++ b/tools/bazeldefs/go.bzl @@ -173,7 +173,7 @@ def go_context(ctx, goos = None, goarch = None, std = False): goos = goos, gotags = go_ctx.tags, nogo_args = [], - runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs + go_ctx.sdk.tools + go_ctx.stdlib.libs), + runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs.to_list() + go_ctx.sdk.tools.to_list() + go_ctx.stdlib.libs.to_list()), stdlib_srcs = go_ctx.sdk.srcs, ) diff --git a/tools/bigquery/BUILD b/tools/bigquery/BUILD index b9ce0fe6a7..fb3e5be61c 100644 --- a/tools/bigquery/BUILD +++ b/tools/bigquery/BUILD @@ -14,7 +14,7 @@ go_library( "//:sandbox", ], deps = [ - "@com_google_cloud_go//bigquery:go_default_library", + "@com_google_cloud_go_bigquery//:go_default_library", "@org_golang_google_api//option:go_default_library", "@org_golang_x_oauth2//:go_default_library", ], diff --git a/tools/defs.bzl b/tools/defs.bzl index 56fc9fc649..f4c3d76654 100644 --- a/tools/defs.bzl +++ b/tools/defs.bzl @@ -5,7 +5,7 @@ automagically creating cc_ and go_ proto targets) and act as a single point of change for Google-internal and bazel-compatible rules. """ -load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier = "cc_flags_supplier", _cc_grpc_library = "cc_grpc_library", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test", _cc_toolchain = "cc_toolchain", _gbenchmark = "gbenchmark", _gbenchmark_internal = "gbenchmark_internal", _grpcpp = "grpcpp", _gtest = "gtest", _select_gtest = "select_gtest", _vdso_linker_option = "vdso_linker_option") +load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier = "cc_flags_supplier", _cc_grpc_library = "cc_grpc_library", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test", _cc_toolchain = "cc_toolchain", _gbenchmark = "gbenchmark", _gbenchmark_internal = "gbenchmark_internal", _grpcpp = "grpcpp", _gtest = "gtest", _select_gtest = "select_gtest") load("//tools/bazeldefs:defs.bzl", _BuildSettingInfo = "BuildSettingInfo", _bool_flag = "bool_flag", _bpf_program = "bpf_program", _build_test = "build_test", _bzl_library = "bzl_library", _coreutil = "coreutil", _default_net_util = "default_net_util", _more_shards = "more_shards", _most_shards = "most_shards", _proto_library = "proto_library", _select_system = "select_system", _short_path = "short_path", _version = "version") load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary", _go_grpc_and_proto_libraries = "go_grpc_and_proto_libraries", _go_library = "go_library", _go_path = "go_path", _go_proto_library = "go_proto_library", _go_test = "go_test", _gotsan_flag_values = "gotsan_flag_values", _gotsan_values = "gotsan_values", _select_goarch = "select_goarch", _select_goos = "select_goos") load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar") @@ -39,7 +39,6 @@ gbenchmark = _gbenchmark gbenchmark_internal = _gbenchmark_internal gtest = _gtest grpcpp = _grpcpp -vdso_linker_option = _vdso_linker_option select_gtest = _select_gtest # Go rules. diff --git a/tools/go_types_memoize.patch b/tools/go_types_memoize.patch index b8b809a769..0fc8f32e1e 100644 --- a/tools/go_types_memoize.patch +++ b/tools/go_types_memoize.patch @@ -1,8 +1,8 @@ diff --git a/src/go/types/scope.go b/src/go/types/scope.go -index 010727eb72..0f134b872e 100644 +index e3fb7b6eff..683f844b42 100644 --- a/src/go/types/scope.go +++ b/src/go/types/scope.go -@@ -25,6 +25,7 @@ type Scope struct { +@@ -27,6 +27,7 @@ type Scope struct { children []*Scope number int // parent.children[number-1] is this scope; 0 if there is no parent elems map[string]Object // lazily allocated @@ -10,7 +10,7 @@ index 010727eb72..0f134b872e 100644 pos, end token.Pos // scope extent; may be invalid comment string // for debugging only isFunc bool // set if this is a function scope (internal use only) -@@ -33,7 +34,7 @@ type Scope struct { +@@ -35,7 +36,7 @@ type Scope struct { // NewScope returns a new, empty scope contained in the given parent // scope, if any. The comment is for debugging only. func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope { @@ -19,7 +19,7 @@ index 010727eb72..0f134b872e 100644 // don't add children to Universe scope! if parent != nil && parent != Universe { parent.children = append(parent.children, s) -@@ -50,14 +51,16 @@ func (s *Scope) Len() int { return len(s.elems) } +@@ -52,14 +53,16 @@ func (s *Scope) Len() int { return len(s.elems) } // Names returns the scope's element names in sorted order. func (s *Scope) Names() []string { @@ -35,9 +35,9 @@ index 010727eb72..0f134b872e 100644 + s.sorted[i] = name + i++ + } -+ sort.Strings(s.sorted) ++ slices.Sort(s.sorted) } -- sort.Strings(names) +- slices.Sort(names) - return names + return s.sorted } diff --git a/tools/nogo/defs.bzl b/tools/nogo/defs.bzl index 0a4cd80f18..15ec91dcf6 100644 --- a/tools/nogo/defs.bzl +++ b/tools/nogo/defs.bzl @@ -70,10 +70,11 @@ def _nogo_stdlib_impl(ctx): # Build the analyzer command. facts_file = ctx.actions.declare_file(ctx.label.name + ".facts") findings_file = ctx.actions.declare_file(ctx.label.name + ".raw_findings") + stdlib_srcs = go_ctx.stdlib_srcs if type(go_ctx.stdlib_srcs) == "list" else go_ctx.stdlib_srcs.to_list() ctx.actions.run( # For the standard library, we need to include the full set of Go # sources in the inputs. - inputs = inputs + go_ctx.stdlib_srcs, + inputs = inputs + stdlib_srcs, outputs = [facts_file, findings_file], tools = depset(go_ctx.runfiles.to_list() + ctx.files._nogo), executable = ctx.files._nogo[0], @@ -90,7 +91,7 @@ def _nogo_stdlib_impl(ctx): "-findings=%s" % findings_file.path, "-facts=%s" % facts_file.path, "-root=.*?/src/", - ] + [f.path for f in go_ctx.stdlib_srcs], + ] + [f.path for f in stdlib_srcs], toolchain = None, ) diff --git a/tools/remove_windows_deps.patch b/tools/remove_windows_deps.patch new file mode 100644 index 0000000000..5d22f6becd --- /dev/null +++ b/tools/remove_windows_deps.patch @@ -0,0 +1,1778 @@ +diff --git a/BUILD.tpl b/BUILD.tpl +index 74522e3..46af16d 100644 +--- a/BUILD.tpl ++++ b/BUILD.tpl +@@ -17,7 +17,6 @@ package(default_visibility = ["//visibility:public"]) + licenses(["notice"]) + + load(":cc_toolchain_config.bzl", "cc_toolchain_config") +-load(":windows_cc_toolchain_config.bzl", "windows_cc_toolchain_config") + + filegroup(name = "empty") + +@@ -34,10 +33,6 @@ cc_toolchain_suite( + "k8|gcc" : ":cc-compiler-k8", + "riscv64" : ":cc-compiler-riscv64", + "riscv64|gcc": ":cc-compiler-riscv64", +- "x64_windows|msvc-cl": ":cc-compiler-x64_windows", +- "x64_windows|msvc-cl-x64": ":cc-compiler-x64_windows", +- "x64_windows|msvc-cl-arm64": "cc-compiler-arm64_windows", +- "x64_windows": ":cc-compiler-x64_windows", + } + ) + +@@ -97,21 +92,6 @@ cc_toolchain( + + cc_toolchain_config(name = "k8-config", cpu = "k8") + +-cc_toolchain( +- name = "cc-compiler-x64_windows", +- toolchain_identifier = "msvc_x64", +- toolchain_config = ":msvc_x64", +- 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 = 1, +-) +- + cc_toolchain( + name = "cc-compiler-riscv64", + toolchain_config = ":riscv64-config", +@@ -139,118 +119,3 @@ toolchain( + toolchain = ":cc-compiler-riscv64", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", + ) +- +-windows_cc_toolchain_config( +- name = "msvc_x64", +- cpu = "x64_windows", +- compiler = "msvc-cl", +- host_system_name = "local", +- target_system_name = "local", +- target_libc = "msvcrt", +- abi_version = "local", +- abi_libc_version = "local", +- toolchain_identifier = "msvc_x64", +- msvc_env_tmp = "%{msvc_env_tmp}", +- msvc_env_path = "%{msvc_x64_env_path}", +- msvc_env_include = "%{msvc_x64_env_include}", +- msvc_env_lib = "%{msvc_x64_env_lib}", +- msvc_cl_path = "%{msvc_x64_cl_path}", +- msvc_ml_path = "%{msvc_x64_ml_path}", +- msvc_link_path = "%{msvc_x64_link_path}", +- msvc_lib_path = "%{msvc_x64_lib_path}", +- cxx_builtin_include_directories = [%{msvc_cxx_builtin_include_directories}], +- tool_paths = { +- "ar": "%{msvc_x64_lib_path}", +- "ml": "%{msvc_x64_ml_path}", +- "cpp": "%{msvc_x64_cl_path}", +- "gcc": "%{msvc_x64_cl_path}", +- "gcov": "wrapper/bin/msvc_nop.bat", +- "ld": "%{msvc_x64_link_path}", +- "nm": "wrapper/bin/msvc_nop.bat", +- "objcopy": "wrapper/bin/msvc_nop.bat", +- "objdump": "wrapper/bin/msvc_nop.bat", +- "strip": "wrapper/bin/msvc_nop.bat", +- }, +- default_link_flags = ["/MACHINE:X64"], +- dbg_mode_debug_flag = "%{dbg_mode_debug_flag}", +- fastbuild_mode_debug_flag = "%{fastbuild_mode_debug_flag}", +-) +- +-toolchain( +- name = "cc-toolchain-x64_windows", +- exec_compatible_with = [ +- "@platforms//cpu:x86_64", +- "@platforms//os:windows", +- ], +- target_compatible_with = [ +- "@platforms//cpu:x86_64", +- "@platforms//os:windows", +- ], +- toolchain = ":cc-compiler-x64_windows", +- toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +-) +- +-cc_toolchain( +- name = "cc-compiler-arm64_windows", +- toolchain_identifier = "msvc_arm64", +- toolchain_config = ":msvc_arm64", +- 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 = 1, +-) +- +-windows_cc_toolchain_config( +- name = "msvc_arm64", +- cpu = "x64_windows", +- compiler = "msvc-cl", +- host_system_name = "local", +- target_system_name = "arm64_windows", +- target_libc = "msvcrt", +- abi_version = "local", +- abi_libc_version = "local", +- toolchain_identifier = "msvc_arm64", +- msvc_env_tmp = "%{msvc_env_tmp}", +- msvc_env_path = "%{msvc_arm64_env_path}", +- msvc_env_include = "%{msvc_arm64_env_include}", +- msvc_env_lib = "%{msvc_arm64_env_lib}", +- msvc_cl_path = "%{msvc_arm64_cl_path}", +- msvc_ml_path = "%{msvc_arm64_ml_path}", +- msvc_link_path = "%{msvc_arm64_link_path}", +- msvc_lib_path = "%{msvc_arm64_lib_path}", +- cxx_builtin_include_directories = [%{msvc_cxx_builtin_include_directories}], +- tool_paths = { +- "ar": "%{msvc_arm64_lib_path}", +- "ml": "%{msvc_arm64_ml_path}", +- "cpp": "%{msvc_arm64_cl_path}", +- "gcc": "%{msvc_arm64_cl_path}", +- "gcov": "wrapper/bin/msvc_nop.bat", +- "ld": "%{msvc_arm64_link_path}", +- "nm": "wrapper/bin/msvc_nop.bat", +- "objcopy": "wrapper/bin/msvc_nop.bat", +- "objdump": "wrapper/bin/msvc_nop.bat", +- "strip": "wrapper/bin/msvc_nop.bat", +- }, +- default_link_flags = ["/MACHINE:ARM64"], +- dbg_mode_debug_flag = "%{dbg_mode_debug_flag}", +- fastbuild_mode_debug_flag = "%{fastbuild_mode_debug_flag}", +-) +- +-toolchain( +- name = "cc-toolchain-arm64_windows", +- exec_compatible_with = [ +- "@platforms//cpu:aarch64", +- "@platforms//os:windows", +- ], +- target_compatible_with = [ +- "@platforms//cpu:aarch64", +- "@platforms//os:windows", +- ], +- toolchain = ":cc-compiler-arm64_windows", +- toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +-) +diff --git a/configure.bzl b/configure.bzl +index ff0a930..765e57a 100644 +--- a/configure.bzl ++++ b/configure.bzl +@@ -13,8 +13,6 @@ + # limitations under the License. + """Rules for configuring the C++ cross-toolchain.""" + +-load(":windows_cc_configure.bzl", "configure_windows_toolchain") +- + def _impl(repository_ctx): + dir_labels = repository_ctx.attr.additional_system_include_directories + additional_include_dirs = ", ".join([ +@@ -35,11 +33,9 @@ def _impl(repository_ctx): + "%{additional_system_include_directories}%": additional_include_dirs, + }, + ) +- template_vars = configure_windows_toolchain(repository_ctx) + repository_ctx.template( + "BUILD", + Label("//:BUILD.tpl"), +- template_vars, + ) + + cc_crosstool = repository_rule( +diff --git a/windows_cc_configure.bzl b/windows_cc_configure.bzl +deleted file mode 100644 +index 9801ad7..0000000 +--- a/windows_cc_configure.bzl ++++ /dev/null +@@ -1,441 +0,0 @@ +-# pylint: disable=g-bad-file-header +-# 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. +-"""Configuring the C++ toolchain on Windows.""" +- +-load( +- "@bazel_tools//tools/cpp:lib_cc_configure.bzl", +- "auto_configure_fail", +- "auto_configure_warning", +- "auto_configure_warning_maybe", +- "escape_string", +- "execute", +- "resolve_labels", +- "write_builtin_include_directory_paths", +-) +- +-def _get_path_env_var(repository_ctx, name): +- """Returns a path from an environment variable. +- +- Removes quotes, replaces '/' with '\', and strips trailing '\'s.""" +- if name in repository_ctx.os.environ: +- value = repository_ctx.os.environ[name] +- if value[0] == "\"": +- if len(value) == 1 or value[-1] != "\"": +- auto_configure_fail("'%s' environment variable has no trailing quote" % name) +- value = value[1:-1] +- if "/" in value: +- value = value.replace("/", "\\") +- if value[-1] == "\\": +- value = value.rstrip("\\") +- return value +- else: +- return None +- +-def _get_temp_env(repository_ctx): +- """Returns the value of TMP, or TEMP, or if both undefined then C:\\Windows.""" +- tmp = _get_path_env_var(repository_ctx, "TMP") +- if not tmp: +- tmp = _get_path_env_var(repository_ctx, "TEMP") +- if not tmp: +- tmp = "C:\\Windows\\Temp" +- auto_configure_warning( +- "neither 'TMP' nor 'TEMP' environment variables are set, using '%s' as default" % tmp, +- ) +- return tmp +- +-def _get_system_root(repository_ctx): +- """Get System root path on Windows, default is C:\\Windows. Doesn't %-escape the result.""" +- systemroot = _get_path_env_var(repository_ctx, "SYSTEMROOT") +- if not systemroot: +- systemroot = "C:\\Windows" +- auto_configure_warning_maybe( +- repository_ctx, +- "SYSTEMROOT is not set, using default SYSTEMROOT=C:\\Windows", +- ) +- return escape_string(systemroot) +- +-def _add_system_root(repository_ctx, env): +- """Running VCVARSALL.BAT and VCVARSQUERYREGISTRY.BAT need %SYSTEMROOT%\\\\system32 in PATH.""" +- if "PATH" not in env: +- env["PATH"] = "" +- env["PATH"] = env["PATH"] + ";" + _get_system_root(repository_ctx) + "\\system32" +- return env +- +-def find_vc_path(repository_ctx): +- """Find Visual C++ build tools install path. Doesn't %-escape the result.""" +- +- # 1. Check if BAZEL_VC or BAZEL_VS is already set by user. +- bazel_vc = _get_path_env_var(repository_ctx, "BAZEL_VC") +- if bazel_vc: +- if repository_ctx.path(bazel_vc).exists: +- return bazel_vc +- else: +- auto_configure_warning_maybe( +- repository_ctx, +- "%BAZEL_VC% is set to non-existent path, ignoring.", +- ) +- +- bazel_vs = _get_path_env_var(repository_ctx, "BAZEL_VS") +- if bazel_vs: +- if repository_ctx.path(bazel_vs).exists: +- bazel_vc = bazel_vs + "\\VC" +- if repository_ctx.path(bazel_vc).exists: +- return bazel_vc +- else: +- auto_configure_warning_maybe( +- repository_ctx, +- "No 'VC' directory found under %BAZEL_VS%, ignoring.", +- ) +- else: +- auto_configure_warning_maybe( +- repository_ctx, +- "%BAZEL_VS% is set to non-existent path, ignoring.", +- ) +- +- auto_configure_warning_maybe( +- repository_ctx, +- "Neither %BAZEL_VC% nor %BAZEL_VS% are set, start looking for the latest Visual C++" + +- " installed.", +- ) +- +- # 2. Check if VS%VS_VERSION%COMNTOOLS is set, if true then try to find and use +- # vcvarsqueryregistry.bat / VsDevCmd.bat to detect VC++. +- auto_configure_warning_maybe(repository_ctx, "Looking for VS%VERSION%COMNTOOLS environment variables, " + +- "eg. VS140COMNTOOLS") +- for vscommontools_env, script in [ +- ("VS160COMNTOOLS", "VsDevCmd.bat"), +- ("VS150COMNTOOLS", "VsDevCmd.bat"), +- ("VS140COMNTOOLS", "vcvarsqueryregistry.bat"), +- ("VS120COMNTOOLS", "vcvarsqueryregistry.bat"), +- ("VS110COMNTOOLS", "vcvarsqueryregistry.bat"), +- ("VS100COMNTOOLS", "vcvarsqueryregistry.bat"), +- ("VS90COMNTOOLS", "vcvarsqueryregistry.bat"), +- ]: +- if vscommontools_env not in repository_ctx.os.environ: +- continue +- script = _get_path_env_var(repository_ctx, vscommontools_env) + "\\" + script +- if not repository_ctx.path(script).exists: +- continue +- repository_ctx.file( +- "get_vc_dir.bat", +- "@echo off\n" + +- "call \"" + script + "\" > NUL\n" + +- "echo %VCINSTALLDIR%", +- True, +- ) +- env = _add_system_root(repository_ctx, repository_ctx.os.environ) +- vc_dir = execute(repository_ctx, ["./get_vc_dir.bat"], environment = env) +- +- auto_configure_warning_maybe(repository_ctx, "Visual C++ build tools found at %s" % vc_dir) +- return vc_dir +- +- # 3. User might have purged all environment variables. If so, look for Visual C++ in registry. +- # Works for Visual Studio 2017 and older. (Does not work for Visual Studio 2019 Preview.) +- auto_configure_warning_maybe(repository_ctx, "Looking for Visual C++ through registry") +- reg_binary = _get_system_root(repository_ctx) + "\\system32\\reg.exe" +- vc_dir = None +- for key, suffix in (("VC7", ""), ("VS7", "\\VC")): +- for version in ["15.0", "14.0", "12.0", "11.0", "10.0", "9.0", "8.0"]: +- if vc_dir: +- break +- result = repository_ctx.execute([reg_binary, "query", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\" + key, "/v", version]) +- auto_configure_warning_maybe(repository_ctx, "registry query result for VC %s:\n\nSTDOUT(start)\n%s\nSTDOUT(end)\nSTDERR(start):\n%s\nSTDERR(end)\n" % +- (version, result.stdout, result.stderr)) +- if not result.stderr: +- for line in result.stdout.split("\n"): +- line = line.strip() +- if line.startswith(version) and line.find("REG_SZ") != -1: +- vc_dir = line[line.find("REG_SZ") + len("REG_SZ"):].strip() + suffix +- if vc_dir: +- auto_configure_warning_maybe(repository_ctx, "Visual C++ build tools found at %s" % vc_dir) +- return vc_dir +- +- # 4. Check default directories for VC installation +- auto_configure_warning_maybe(repository_ctx, "Looking for default Visual C++ installation directory") +- program_files_dir = _get_path_env_var(repository_ctx, "PROGRAMFILES(X86)") +- if not program_files_dir: +- program_files_dir = "C:\\Program Files (x86)" +- auto_configure_warning_maybe( +- repository_ctx, +- "'PROGRAMFILES(X86)' environment variable is not set, using '%s' as default" % program_files_dir, +- ) +- for path in [ +- "Microsoft Visual Studio\\2019\\Preview\\VC", +- "Microsoft Visual Studio\\2019\\BuildTools\\VC", +- "Microsoft Visual Studio\\2019\\Community\\VC", +- "Microsoft Visual Studio\\2019\\Professional\\VC", +- "Microsoft Visual Studio\\2019\\Enterprise\\VC", +- "Microsoft Visual Studio\\2017\\BuildTools\\VC", +- "Microsoft Visual Studio\\2017\\Community\\VC", +- "Microsoft Visual Studio\\2017\\Professional\\VC", +- "Microsoft Visual Studio\\2017\\Enterprise\\VC", +- ]: +- path = program_files_dir + "\\" + path +- if repository_ctx.path(path).exists: +- vc_dir = path +- break +- +- if not vc_dir: +- auto_configure_warning_maybe(repository_ctx, "Visual C++ build tools not found.") +- return None +- auto_configure_warning_maybe(repository_ctx, "Visual C++ build tools found at %s" % vc_dir) +- return vc_dir +- +-def _find_vcvars_bat_script(repository_ctx, vc_path): +- """Find batch script to set up environment variables for VC. Doesn't %-escape the result.""" +- vcvars_script = vc_path + "\\Auxiliary\\Build\\VCVARSALL.BAT" +- +- if not repository_ctx.path(vcvars_script).exists: +- return None +- +- return vcvars_script +- +-def _is_support_vcvars_ver(vc_full_version): +- """-vcvars_ver option is supported from version 14.11.25503 (VS 2017 version 15.3).""" +- version = [int(i) for i in vc_full_version.split(".")] +- min_version = [14, 11, 25503] +- return version >= min_version +- +-def setup_vc_env_vars(repository_ctx, vc_path, arch, envvars = [], allow_empty = False, escape = True): +- """Get environment variables set by VCVARSALL.BAT script. Doesn't %-escape the result! +- +- Args: +- repository_ctx: the repository_ctx object +- vc_path: Visual C++ root directory +- envvars: list of envvars to retrieve; default is ["PATH", "INCLUDE", "LIB", "WINDOWSSDKDIR"] +- allow_empty: allow unset envvars; if False then report errors for those +- escape: if True, escape "\" as "\\" and "%" as "%%" in the envvar values +- +- Returns: +- dictionary of the envvars +- """ +- if not envvars: +- envvars = ["PATH", "INCLUDE", "LIB", "WINDOWSSDKDIR"] +- +- vcvars_script = _find_vcvars_bat_script(repository_ctx, vc_path) +- if not vcvars_script: +- auto_configure_fail("Cannot find VCVARSALL.BAT script under %s" % vc_path) +- +- # Getting Windows SDK version set by user. +- # Only supports VC 2017 & 2019. +- winsdk_version = _get_winsdk_full_version(repository_ctx) +- +- # Get VC version set by user. Only supports VC 2017 & 2019. +- vcvars_ver = "" +- full_version = _get_vc_full_version(repository_ctx, vc_path) +- +- # Because VCVARSALL.BAT is from the latest VC installed, so we check if the latest +- # version supports -vcvars_ver or not. +- if _is_support_vcvars_ver(_get_latest_subversion(repository_ctx, vc_path)): +- vcvars_ver = "-vcvars_ver=" + full_version +- +- cmd = "\"%s\" %s %s %s" % (vcvars_script, arch, winsdk_version, vcvars_ver) +- print_envvars = ",".join(["{k}=%{k}%".format(k = k) for k in envvars]) +- repository_ctx.file( +- "get_env.bat", +- "@echo off\n" + +- ("call %s > NUL \n" % cmd) + ("echo %s \n" % print_envvars), +- True, +- ) +- env = _add_system_root(repository_ctx, {k: "" for k in envvars}) +- envs = execute(repository_ctx, ["./get_env.bat"], environment = env).split(",") +- env_map = {} +- for env in envs: +- key, value = env.split("=", 1) +- env_map[key] = escape_string(value.replace("\\", "\\\\")) if escape else value +- if not allow_empty: +- _check_env_vars(env_map, cmd, expected = envvars) +- return env_map +- +-def _check_env_vars(env_map, cmd, expected): +- for env in expected: +- if not env_map.get(env): +- auto_configure_fail( +- "Setting up VC environment variables failed, %s is not set by the following command:\n %s" % (env, cmd), +- ) +- +-def _get_latest_subversion(repository_ctx, vc_path): +- """Get the latest subversion of a VS 2017/2019 installation. +- +- For VS 2017 & 2019, there could be multiple versions of VC build tools. +- The directories are like: +- \\Tools\\MSVC\\14.10.24930\\bin\\HostX64\\x64 +- \\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64 +- This function should return 14.16.27023 in this case.""" +- versions = [path.basename for path in repository_ctx.path(vc_path + "\\Tools\\MSVC").readdir()] +- if len(versions) < 1: +- auto_configure_warning_maybe(repository_ctx, "Cannot find any VC installation under BAZEL_VC(%s)" % vc_path) +- return None +- +- # Parse the version string into integers, then sort the integers to prevent textual sorting. +- version_list = [] +- for version in versions: +- parts = [int(i) for i in version.split(".")] +- version_list.append((parts, version)) +- +- version_list = sorted(version_list) +- latest_version = version_list[-1][1] +- +- auto_configure_warning_maybe(repository_ctx, "Found the following VC verisons:\n%s\n\nChoosing the latest version = %s" % ("\n".join(versions), latest_version)) +- return latest_version +- +-def _get_vc_full_version(repository_ctx, vc_path): +- """Return the value of BAZEL_VC_FULL_VERSION if defined, otherwise the latest version.""" +- if "BAZEL_VC_FULL_VERSION" in repository_ctx.os.environ: +- return repository_ctx.os.environ["BAZEL_VC_FULL_VERSION"] +- return _get_latest_subversion(repository_ctx, vc_path) +- +-def _get_winsdk_full_version(repository_ctx): +- """Return the value of BAZEL_WINSDK_FULL_VERSION if defined, otherwise an empty string.""" +- return repository_ctx.os.environ.get("BAZEL_WINSDK_FULL_VERSION", default = "") +- +-def find_msvc_tool(repository_ctx, vc_path, tool, arch): +- """Find the exact path of a specific build tool in MSVC. Doesn't %-escape the result.""" +- tool_path = None +- full_version = _get_vc_full_version(repository_ctx, vc_path) +- if full_version: +- tool_path = "%s\\Tools\\MSVC\\%s\\bin\\HostX64\\%s\\%s" % (vc_path, full_version, arch, tool) +- +- if not tool_path or not repository_ctx.path(tool_path).exists: +- return None +- +- return tool_path.replace("\\", "/") +- +-def _find_missing_vc_tools(repository_ctx, vc_path, arch): +- """Check if any required tool is missing under given VC path.""" +- missing_tools = [] +- if not _find_vcvars_bat_script(repository_ctx, vc_path): +- missing_tools.append("VCVARSALL.BAT") +- +- for tool in ["cl.exe", "link.exe", "lib.exe"]: +- if not find_msvc_tool(repository_ctx, vc_path, tool, arch): +- missing_tools.append(tool) +- +- return missing_tools +- +-def _is_support_debug_fastlink(repository_ctx, linker): +- """Run linker alone to see if it supports /DEBUG:FASTLINK.""" +- result = execute(repository_ctx, [linker], expect_failure = True) +- return result.find("/DEBUG[:{FASTLINK|FULL|NONE}]") != -1 +- +-def _get_msvc_vars(repository_ctx, paths, arch): +- """Get the variables we need to populate the MSVC toolchains.""" +- msvc_vars = dict() +- vc_path = find_vc_path(repository_ctx) +- missing_tools = None +- if not vc_path: +- repository_ctx.template( +- "vc_installation_error.bat", +- paths["@bazel_tools//tools/cpp:vc_installation_error.bat.tpl"], +- {"%{vc_error_message}": ""}, +- ) +- else: +- missing_tools = _find_missing_vc_tools(repository_ctx, vc_path, arch) +- if missing_tools: +- message = "\r\n".join([ +- "echo. 1>&2", +- "echo Visual C++ build tools seems to be installed at %s 1>&2" % vc_path, +- "echo But Bazel can't find the following tools: 1>&2", +- "echo %s 1>&2" % ", ".join(missing_tools), +- "echo. 1>&2", +- ]) +- repository_ctx.template( +- "vc_installation_error.bat", +- paths["@bazel_tools//tools/cpp:vc_installation_error.bat.tpl"], +- {"%{vc_error_message}": message}, +- ) +- +- if not vc_path or missing_tools: +- write_builtin_include_directory_paths(repository_ctx, "msvc", [], file_suffix = "_msvc") +- msvc_vars = { +- "%{msvc_env_tmp}": "msvc_not_found", +- "%{msvc_env_path}": "msvc_not_found", +- "%{msvc_env_include}": "msvc_not_found", +- "%{msvc_env_lib}": "msvc_not_found", +- "%{msvc_cl_path}": "vc_installation_error.bat", +- "%{msvc_ml_path}": "vc_installation_error.bat", +- "%{msvc_link_path}": "vc_installation_error.bat", +- "%{msvc_lib_path}": "vc_installation_error.bat", +- "%{dbg_mode_debug_flag}": "/DEBUG", +- "%{fastbuild_mode_debug_flag}": "/DEBUG", +- "%{msvc_cxx_builtin_include_directories}": "", +- } +- return msvc_vars +- +- vcvars_arch_map = { +- "x64": "amd64", +- "arm64": "x64_arm64", +- } +- +- env = setup_vc_env_vars(repository_ctx, vc_path, vcvars_arch_map[arch]) +- escaped_paths = escape_string(env["PATH"]) +- escaped_include_paths = escape_string(env["INCLUDE"]) +- escaped_lib_paths = escape_string(env["LIB"]) +- +- escaped_tmp_dir = escape_string(_get_temp_env(repository_ctx).replace("\\", "\\\\")) +- +- cl_path = find_msvc_tool(repository_ctx, vc_path, "cl.exe", arch) +- link_path = find_msvc_tool(repository_ctx, vc_path, "link.exe", arch) +- lib_path = find_msvc_tool(repository_ctx, vc_path, "lib.exe", arch) +- +- vcvars_ml_map = { +- "x64": "ml64.exe", +- "arm64": "armasm64.exe", +- } +- msvc_ml_path = find_msvc_tool(repository_ctx, vc_path, vcvars_ml_map[arch], arch) +- +- escaped_cxx_include_directories = [] +- +- for path in escaped_include_paths.split(";"): +- if path: +- escaped_cxx_include_directories.append("\"%s\"" % path) +- +- support_debug_fastlink = _is_support_debug_fastlink(repository_ctx, link_path) +- +- write_builtin_include_directory_paths(repository_ctx, "msvc", escaped_cxx_include_directories, file_suffix = "_msvc") +- msvc_vars = { +- "%{msvc_env_tmp}": escaped_tmp_dir, +- "%%{msvc_%s_env_path}" % arch: escaped_paths, +- "%%{msvc_%s_env_include}" % arch: escaped_include_paths, +- "%%{msvc_%s_env_lib}" % arch: escaped_lib_paths, +- "%%{msvc_%s_cl_path}" % arch: cl_path, +- "%%{msvc_%s_ml_path}" % arch: msvc_ml_path, +- "%%{msvc_%s_link_path}" % arch: link_path, +- "%%{msvc_%s_lib_path}" % arch: lib_path, +- "%{dbg_mode_debug_flag}": "/DEBUG:FULL" if support_debug_fastlink else "/DEBUG", +- "%{fastbuild_mode_debug_flag}": "/DEBUG:FASTLINK" if support_debug_fastlink else "/DEBUG", +- "%{msvc_cxx_builtin_include_directories}": " " + ",\n ".join(escaped_cxx_include_directories), +- } +- return msvc_vars +- +-def configure_windows_toolchain(repository_ctx): +- """Configure C++ toolchain on Windows.""" +- paths = resolve_labels(repository_ctx, [ +- "@bazel_tools//tools/cpp:vc_installation_error.bat.tpl", +- ]) +- +- repository_ctx.symlink( +- Label("//:windows_cc_toolchain_config.bzl"), +- "windows_cc_toolchain_config.bzl", +- ) +- +- template_vars = dict() +- x64_msvc_vars = _get_msvc_vars(repository_ctx, paths, "x64") +- template_vars.update(x64_msvc_vars) +- +- arm64_msvc_vars = _get_msvc_vars(repository_ctx, paths, "arm64") +- template_vars.update(arm64_msvc_vars) +- +- return template_vars +diff --git a/windows_cc_toolchain_config.bzl b/windows_cc_toolchain_config.bzl +deleted file mode 100644 +index ecf67ac..0000000 +--- a/windows_cc_toolchain_config.bzl ++++ /dev/null +@@ -1,1136 +0,0 @@ +-# Copyright 2019 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. +- +-"""A Starlark cc_toolchain configuration rule for Windows""" +- +-load( +- "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", +- "action_config", +- "artifact_name_pattern", +- "env_entry", +- "env_set", +- "feature", +- "feature_set", +- "flag_group", +- "flag_set", +- "tool", +- "tool_path", +- "variable_with_value", +- "with_feature_set", +-) +-load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +- +-all_compile_actions = [ +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.linkstamp_compile, +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ACTION_NAMES.clif_match, +- ACTION_NAMES.lto_backend, +-] +- +-all_cpp_compile_actions = [ +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.linkstamp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ACTION_NAMES.clif_match, +-] +- +-preprocessor_compile_actions = [ +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.linkstamp_compile, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.clif_match, +-] +- +-codegen_compile_actions = [ +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.linkstamp_compile, +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.cpp_module_codegen, +- ACTION_NAMES.lto_backend, +-] +- +-all_link_actions = [ +- ACTION_NAMES.cpp_link_executable, +- ACTION_NAMES.cpp_link_dynamic_library, +- ACTION_NAMES.cpp_link_nodeps_dynamic_library, +-] +- +-def _impl(ctx): +- artifact_name_patterns = [ +- artifact_name_pattern( +- category_name = "object_file", +- prefix = "", +- extension = ".obj", +- ), +- artifact_name_pattern( +- category_name = "static_library", +- prefix = "", +- extension = ".lib", +- ), +- artifact_name_pattern( +- category_name = "alwayslink_static_library", +- prefix = "", +- extension = ".lo.lib", +- ), +- artifact_name_pattern( +- category_name = "executable", +- prefix = "", +- extension = ".exe", +- ), +- artifact_name_pattern( +- category_name = "dynamic_library", +- prefix = "", +- extension = ".dll", +- ), +- artifact_name_pattern( +- category_name = "interface_library", +- prefix = "", +- extension = ".if.lib", +- ), +- ] +- +- cpp_link_nodeps_dynamic_library_action = action_config( +- action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, +- implies = [ +- "nologo", +- "shared_flag", +- "linkstamps", +- "output_execpath_flags", +- "input_param_flags", +- "user_link_flags", +- "default_link_flags", +- "linker_subsystem_flag", +- "linker_param_file", +- "msvc_env", +- "no_stripping", +- "has_configured_linker_path", +- "def_file", +- ], +- tools = [tool(path = ctx.attr.msvc_link_path)], +- ) +- +- cpp_link_static_library_action = action_config( +- action_name = ACTION_NAMES.cpp_link_static_library, +- implies = [ +- "nologo", +- "archiver_flags", +- "input_param_flags", +- "linker_param_file", +- "msvc_env", +- ], +- tools = [tool(path = ctx.attr.msvc_lib_path)], +- ) +- +- assemble_action = action_config( +- action_name = ACTION_NAMES.assemble, +- implies = [ +- "compiler_input_flags", +- "compiler_output_flags", +- "nologo", +- "msvc_env", +- "sysroot", +- ], +- tools = [tool(path = ctx.attr.msvc_ml_path)], +- ) +- +- preprocess_assemble_action = action_config( +- action_name = ACTION_NAMES.preprocess_assemble, +- implies = [ +- "compiler_input_flags", +- "compiler_output_flags", +- "nologo", +- "msvc_env", +- "sysroot", +- ], +- tools = [tool(path = ctx.attr.msvc_ml_path)], +- ) +- +- c_compile_action = action_config( +- action_name = ACTION_NAMES.c_compile, +- implies = [ +- "compiler_input_flags", +- "compiler_output_flags", +- "default_compile_flags", +- "nologo", +- "msvc_env", +- "parse_showincludes", +- "user_compile_flags", +- "sysroot", +- "unfiltered_compile_flags", +- ], +- tools = [tool(path = ctx.attr.msvc_cl_path)], +- ) +- +- cpp_compile_action = action_config( +- action_name = ACTION_NAMES.cpp_compile, +- implies = [ +- "compiler_input_flags", +- "compiler_output_flags", +- "default_compile_flags", +- "nologo", +- "msvc_env", +- "parse_showincludes", +- "user_compile_flags", +- "sysroot", +- "unfiltered_compile_flags", +- ], +- tools = [tool(path = ctx.attr.msvc_cl_path)], +- ) +- +- cpp_link_executable_action = action_config( +- action_name = ACTION_NAMES.cpp_link_executable, +- implies = [ +- "nologo", +- "linkstamps", +- "output_execpath_flags", +- "input_param_flags", +- "user_link_flags", +- "default_link_flags", +- "linker_subsystem_flag", +- "linker_param_file", +- "msvc_env", +- "no_stripping", +- ], +- tools = [tool(path = ctx.attr.msvc_link_path)], +- ) +- +- cpp_link_dynamic_library_action = action_config( +- action_name = ACTION_NAMES.cpp_link_dynamic_library, +- implies = [ +- "nologo", +- "shared_flag", +- "linkstamps", +- "output_execpath_flags", +- "input_param_flags", +- "user_link_flags", +- "default_link_flags", +- "linker_subsystem_flag", +- "linker_param_file", +- "msvc_env", +- "no_stripping", +- "has_configured_linker_path", +- "def_file", +- ], +- tools = [tool(path = ctx.attr.msvc_link_path)], +- ) +- +- action_configs = [ +- assemble_action, +- preprocess_assemble_action, +- c_compile_action, +- cpp_compile_action, +- cpp_link_executable_action, +- cpp_link_dynamic_library_action, +- cpp_link_nodeps_dynamic_library_action, +- cpp_link_static_library_action, +- ] +- +- msvc_link_env_feature = feature( +- name = "msvc_link_env", +- env_sets = [ +- env_set( +- actions = all_link_actions + +- [ACTION_NAMES.cpp_link_static_library], +- env_entries = [env_entry(key = "LIB", value = ctx.attr.msvc_env_lib)], +- ), +- ], +- ) +- +- shared_flag_feature = feature( +- name = "shared_flag", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.cpp_link_dynamic_library, +- ACTION_NAMES.cpp_link_nodeps_dynamic_library, +- ], +- flag_groups = [flag_group(flags = ["/DLL"])], +- ), +- ], +- ) +- +- determinism_feature = feature( +- name = "determinism", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [ +- flag_group( +- flags = [ +- "/wd4117", +- "-D__DATE__=\"redacted\"", +- "-D__TIMESTAMP__=\"redacted\"", +- "-D__TIME__=\"redacted\"", +- ] + (["-Wno-builtin-macro-redefined"] if ctx.attr.compiler == "clang-cl" else []), +- ), +- ], +- ), +- ], +- ) +- +- sysroot_feature = feature( +- name = "sysroot", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- 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.cpp_link_executable, +- ACTION_NAMES.cpp_link_dynamic_library, +- ACTION_NAMES.cpp_link_nodeps_dynamic_library, +- ], +- flag_groups = [ +- flag_group( +- flags = ["--sysroot=%{sysroot}"], +- iterate_over = "sysroot", +- expand_if_available = "sysroot", +- ), +- ], +- ), +- ], +- ) +- +- unfiltered_compile_flags_feature = feature( +- name = "unfiltered_compile_flags", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ], +- flag_groups = [ +- flag_group( +- flags = ["%{unfiltered_compile_flags}"], +- iterate_over = "unfiltered_compile_flags", +- expand_if_available = "unfiltered_compile_flags", +- ), +- ], +- ), +- ], +- ) +- +- compiler_param_file_feature = feature( +- name = "compiler_param_file", +- ) +- +- copy_dynamic_libraries_to_binary_feature = feature( +- name = "copy_dynamic_libraries_to_binary", +- ) +- +- input_param_flags_feature = feature( +- name = "input_param_flags", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.cpp_link_dynamic_library, +- ACTION_NAMES.cpp_link_nodeps_dynamic_library, +- ], +- flag_groups = [ +- flag_group( +- flags = ["/IMPLIB:%{interface_library_output_path}"], +- expand_if_available = "interface_library_output_path", +- ), +- ], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = ["%{libopts}"], +- iterate_over = "libopts", +- expand_if_available = "libopts", +- ), +- ], +- ), +- flag_set( +- actions = all_link_actions + +- [ACTION_NAMES.cpp_link_static_library], +- flag_groups = [ +- flag_group( +- iterate_over = "libraries_to_link", +- flag_groups = [ +- flag_group( +- iterate_over = "libraries_to_link.object_files", +- flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])], +- expand_if_equal = variable_with_value( +- name = "libraries_to_link.type", +- value = "object_file_group", +- ), +- ), +- flag_group( +- flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], +- expand_if_equal = variable_with_value( +- name = "libraries_to_link.type", +- value = "object_file", +- ), +- ), +- flag_group( +- flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], +- expand_if_equal = variable_with_value( +- name = "libraries_to_link.type", +- value = "interface_library", +- ), +- ), +- flag_group( +- flag_groups = [ +- flag_group( +- flags = ["%{libraries_to_link.name}"], +- expand_if_false = "libraries_to_link.is_whole_archive", +- ), +- flag_group( +- flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"], +- expand_if_true = "libraries_to_link.is_whole_archive", +- ), +- ], +- expand_if_equal = variable_with_value( +- name = "libraries_to_link.type", +- value = "static_library", +- ), +- ), +- ], +- expand_if_available = "libraries_to_link", +- ), +- ], +- ), +- ], +- ) +- +- fastbuild_feature = feature( +- name = "fastbuild", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/Od", "/Z7"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = [ctx.attr.fastbuild_mode_debug_flag, "/INCREMENTAL:NO"], +- ), +- ], +- ), +- ], +- implies = ["generate_pdb_file"], +- ) +- +- user_compile_flags_feature = feature( +- name = "user_compile_flags", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ], +- flag_groups = [ +- flag_group( +- flags = ["%{user_compile_flags}"], +- iterate_over = "user_compile_flags", +- expand_if_available = "user_compile_flags", +- ), +- ], +- ), +- ], +- ) +- +- archiver_flags_feature = feature( +- name = "archiver_flags", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.cpp_link_static_library], +- flag_groups = [ +- flag_group( +- flags = ["/OUT:%{output_execpath}"], +- expand_if_available = "output_execpath", +- ), +- ], +- ), +- ], +- ) +- +- default_link_flags_feature = feature( +- name = "default_link_flags", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ctx.attr.default_link_flags)], +- ), +- ], +- ) +- +- static_link_msvcrt_feature = feature(name = "static_link_msvcrt") +- +- dynamic_link_msvcrt_debug_feature = feature( +- name = "dynamic_link_msvcrt_debug", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/MDd"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])], +- ), +- ], +- requires = [feature_set(features = ["dbg"])], +- ) +- +- dbg_feature = feature( +- name = "dbg", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/Od", "/Z7"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = [ctx.attr.dbg_mode_debug_flag, "/INCREMENTAL:NO"], +- ), +- ], +- ), +- ], +- implies = ["generate_pdb_file"], +- ) +- +- opt_feature = feature( +- name = "opt", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/O2"])], +- ), +- ], +- implies = ["frame_pointer"], +- ) +- +- supports_interface_shared_libraries_feature = feature( +- name = "supports_interface_shared_libraries", +- enabled = True, +- ) +- +- user_link_flags_feature = feature( +- name = "user_link_flags", +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = ["%{user_link_flags}"], +- iterate_over = "user_link_flags", +- expand_if_available = "user_link_flags", +- ), +- ], +- ), +- ], +- ) +- +- 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_groups = [ +- flag_group( +- flags = [ +- "/DCOMPILER_MSVC", +- "/DNOMINMAX", +- "/D_WIN32_WINNT=0x0601", +- "/D_CRT_SECURE_NO_DEPRECATE", +- "/D_CRT_SECURE_NO_WARNINGS", +- "/bigobj", +- "/Zm500", +- "/EHsc", +- "/wd4351", +- "/wd4291", +- "/wd4250", +- "/wd4996", +- ], +- ), +- ], +- ), +- ], +- ) +- +- msvc_compile_env_feature = feature( +- name = "msvc_compile_env", +- 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, +- ], +- env_entries = [env_entry(key = "INCLUDE", value = ctx.attr.msvc_env_include)], +- ), +- ], +- ) +- +- preprocessor_defines_feature = feature( +- name = "preprocessor_defines", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ], +- flag_groups = [ +- flag_group( +- flags = ["/D%{preprocessor_defines}"], +- iterate_over = "preprocessor_defines", +- ), +- ], +- ), +- ], +- ) +- +- generate_pdb_file_feature = feature( +- name = "generate_pdb_file", +- requires = [ +- feature_set(features = ["dbg"]), +- feature_set(features = ["fastbuild"]), +- ], +- ) +- +- output_execpath_flags_feature = feature( +- name = "output_execpath_flags", +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = ["/OUT:%{output_execpath}"], +- expand_if_available = "output_execpath", +- ), +- ], +- ), +- ], +- ) +- +- dynamic_link_msvcrt_no_debug_feature = feature( +- name = "dynamic_link_msvcrt_no_debug", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/MD"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], +- ), +- ], +- requires = [ +- feature_set(features = ["fastbuild"]), +- feature_set(features = ["opt"]), +- ], +- ) +- +- disable_assertions_feature = feature( +- name = "disable_assertions", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/DNDEBUG"])], +- with_features = [with_feature_set(features = ["opt"])], +- ), +- ], +- ) +- +- has_configured_linker_path_feature = feature(name = "has_configured_linker_path") +- +- supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) +- +- no_stripping_feature = feature(name = "no_stripping") +- +- linker_param_file_feature = feature( +- name = "linker_param_file", +- flag_sets = [ +- flag_set( +- actions = all_link_actions + +- [ACTION_NAMES.cpp_link_static_library], +- flag_groups = [ +- flag_group( +- flags = ["@%{linker_param_file}"], +- expand_if_available = "linker_param_file", +- ), +- ], +- ), +- ], +- ) +- +- ignore_noisy_warnings_feature = feature( +- name = "ignore_noisy_warnings", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.cpp_link_static_library], +- flag_groups = [flag_group(flags = ["/ignore:4221"])], +- ), +- ], +- ) +- +- no_legacy_features_feature = feature(name = "no_legacy_features") +- +- parse_showincludes_feature = feature( +- name = "parse_showincludes", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_header_parsing, +- ], +- flag_groups = [flag_group(flags = ["/showIncludes"])], +- ), +- ], +- ) +- +- static_link_msvcrt_no_debug_feature = feature( +- name = "static_link_msvcrt_no_debug", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/MT"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], +- ), +- ], +- requires = [ +- feature_set(features = ["fastbuild"]), +- feature_set(features = ["opt"]), +- ], +- ) +- +- treat_warnings_as_errors_feature = feature( +- name = "treat_warnings_as_errors", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/WX"])], +- ), +- ], +- ) +- +- windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols") +- +- no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols") +- +- include_paths_feature = feature( +- name = "include_paths", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ], +- flag_groups = [ +- flag_group( +- flags = ["/I%{quote_include_paths}"], +- iterate_over = "quote_include_paths", +- ), +- flag_group( +- flags = ["/I%{include_paths}"], +- iterate_over = "include_paths", +- ), +- flag_group( +- flags = ["/I%{system_include_paths}"], +- iterate_over = "system_include_paths", +- ), +- ], +- ), +- ], +- ) +- +- linkstamps_feature = feature( +- name = "linkstamps", +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = ["%{linkstamp_paths}"], +- iterate_over = "linkstamp_paths", +- expand_if_available = "linkstamp_paths", +- ), +- ], +- ), +- ], +- ) +- +- targets_windows_feature = feature( +- name = "targets_windows", +- enabled = True, +- implies = ["copy_dynamic_libraries_to_binary"], +- ) +- +- linker_subsystem_flag_feature = feature( +- name = "linker_subsystem_flag", +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])], +- ), +- ], +- ) +- +- static_link_msvcrt_debug_feature = feature( +- name = "static_link_msvcrt_debug", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/MTd"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], +- ), +- ], +- requires = [feature_set(features = ["dbg"])], +- ) +- +- frame_pointer_feature = feature( +- name = "frame_pointer", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/Oy-"])], +- ), +- ], +- ) +- +- compiler_output_flags_feature = feature( +- name = "compiler_output_flags", +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.assemble], +- flag_groups = [ +- flag_group( +- flag_groups = [ +- flag_group( +- flags = ["/Fo%{output_file}", "/Zi"], +- expand_if_available = "output_file", +- expand_if_not_available = "output_assembly_file", +- ), +- ], +- expand_if_not_available = "output_preprocess_file", +- ), +- ], +- ), +- flag_set( +- actions = [ +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ], +- flag_groups = [ +- flag_group( +- flag_groups = [ +- flag_group( +- flags = ["/Fo%{output_file}"], +- expand_if_not_available = "output_preprocess_file", +- ), +- ], +- expand_if_available = "output_file", +- expand_if_not_available = "output_assembly_file", +- ), +- flag_group( +- flag_groups = [ +- flag_group( +- flags = ["/Fa%{output_file}"], +- expand_if_available = "output_assembly_file", +- ), +- ], +- expand_if_available = "output_file", +- ), +- flag_group( +- flag_groups = [ +- flag_group( +- flags = ["/P", "/Fi%{output_file}"], +- expand_if_available = "output_preprocess_file", +- ), +- ], +- expand_if_available = "output_file", +- ), +- ], +- ), +- ], +- ) +- +- nologo_feature = feature( +- name = "nologo", +- flag_sets = [ +- flag_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, +- ], +- flag_groups = [flag_group(flags = ["/nologo"])], +- ), +- ], +- ) +- +- smaller_binary_feature = feature( +- name = "smaller_binary", +- enabled = True, +- flag_sets = [ +- flag_set( +- actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], +- flag_groups = [flag_group(flags = ["/Gy", "/Gw"])], +- with_features = [with_feature_set(features = ["opt"])], +- ), +- flag_set( +- actions = all_link_actions, +- flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])], +- with_features = [with_feature_set(features = ["opt"])], +- ), +- ], +- ) +- +- compiler_input_flags_feature = feature( +- name = "compiler_input_flags", +- flag_sets = [ +- flag_set( +- actions = [ +- ACTION_NAMES.assemble, +- ACTION_NAMES.preprocess_assemble, +- ACTION_NAMES.c_compile, +- ACTION_NAMES.cpp_compile, +- ACTION_NAMES.cpp_header_parsing, +- ACTION_NAMES.cpp_module_compile, +- ACTION_NAMES.cpp_module_codegen, +- ], +- flag_groups = [ +- flag_group( +- flags = ["/c", "%{source_file}"], +- expand_if_available = "source_file", +- ), +- ], +- ), +- ], +- ) +- +- def_file_feature = feature( +- name = "def_file", +- flag_sets = [ +- flag_set( +- actions = all_link_actions, +- flag_groups = [ +- flag_group( +- flags = ["/DEF:%{def_file_path}", "/ignore:4070"], +- expand_if_available = "def_file_path", +- ), +- ], +- ), +- ], +- ) +- +- msvc_env_feature = feature( +- name = "msvc_env", +- 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 = ctx.attr.msvc_env_path), +- env_entry(key = "TMP", value = ctx.attr.msvc_env_tmp), +- env_entry(key = "TEMP", value = ctx.attr.msvc_env_tmp), +- ], +- ), +- ], +- implies = ["msvc_compile_env", "msvc_link_env"], +- ) +- features = [ +- no_legacy_features_feature, +- nologo_feature, +- has_configured_linker_path_feature, +- no_stripping_feature, +- targets_windows_feature, +- copy_dynamic_libraries_to_binary_feature, +- default_compile_flags_feature, +- msvc_env_feature, +- msvc_compile_env_feature, +- msvc_link_env_feature, +- include_paths_feature, +- preprocessor_defines_feature, +- parse_showincludes_feature, +- generate_pdb_file_feature, +- shared_flag_feature, +- linkstamps_feature, +- output_execpath_flags_feature, +- archiver_flags_feature, +- input_param_flags_feature, +- linker_subsystem_flag_feature, +- user_link_flags_feature, +- default_link_flags_feature, +- linker_param_file_feature, +- static_link_msvcrt_feature, +- static_link_msvcrt_no_debug_feature, +- dynamic_link_msvcrt_no_debug_feature, +- static_link_msvcrt_debug_feature, +- dynamic_link_msvcrt_debug_feature, +- dbg_feature, +- fastbuild_feature, +- opt_feature, +- frame_pointer_feature, +- disable_assertions_feature, +- determinism_feature, +- treat_warnings_as_errors_feature, +- smaller_binary_feature, +- ignore_noisy_warnings_feature, +- user_compile_flags_feature, +- sysroot_feature, +- unfiltered_compile_flags_feature, +- compiler_param_file_feature, +- compiler_output_flags_feature, +- compiler_input_flags_feature, +- def_file_feature, +- windows_export_all_symbols_feature, +- no_windows_export_all_symbols_feature, +- supports_dynamic_linker_feature, +- supports_interface_shared_libraries_feature, +- ] +- +- tool_paths = [ +- tool_path(name = name, path = path) +- for name, path in ctx.attr.tool_paths.items() +- ] +- +- 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 = ctx.attr.cxx_builtin_include_directories, +- toolchain_identifier = ctx.attr.toolchain_identifier, +- host_system_name = ctx.attr.host_system_name, +- target_system_name = ctx.attr.target_system_name, +- target_cpu = ctx.attr.cpu, +- target_libc = ctx.attr.target_libc, +- compiler = ctx.attr.compiler, +- abi_version = ctx.attr.abi_version, +- abi_libc_version = ctx.attr.abi_libc_version, +- tool_paths = tool_paths, +- ) +- +-windows_cc_toolchain_config = rule( +- implementation = _impl, +- attrs = { +- "cpu": attr.string(mandatory = True), +- "compiler": attr.string(), +- "toolchain_identifier": attr.string(), +- "host_system_name": attr.string(), +- "target_system_name": attr.string(), +- "target_libc": attr.string(), +- "abi_version": attr.string(), +- "abi_libc_version": attr.string(), +- "tool_paths": attr.string_dict(), +- "cxx_builtin_include_directories": attr.string_list(), +- "default_link_flags": attr.string_list(default = []), +- "msvc_env_tmp": attr.string(default = "msvc_not_found"), +- "msvc_env_path": attr.string(default = "msvc_not_found"), +- "msvc_env_include": attr.string(default = "msvc_not_found"), +- "msvc_env_lib": attr.string(default = "msvc_not_found"), +- "msvc_cl_path": attr.string(default = "vc_installation_error.bat"), +- "msvc_ml_path": attr.string(default = "vc_installation_error.bat"), +- "msvc_link_path": attr.string(default = "vc_installation_error.bat"), +- "msvc_lib_path": attr.string(default = "vc_installation_error.bat"), +- "dbg_mode_debug_flag": attr.string(), +- "fastbuild_mode_debug_flag": attr.string(), +- "tool_bin_path": attr.string(default = "not_found"), +- }, +- provides = [CcToolchainConfigInfo], +-) diff --git a/tools/rules_cgo.patch b/tools/rules_cgo.patch index 715e39cca7..0f4f2d26e2 100644 --- a/tools/rules_cgo.patch +++ b/tools/rules_cgo.patch @@ -1,9 +1,3 @@ -commit 6df2a94ece32425f53ea6fecdca3af7148dcc48b -Author: Andrei Vagin -Date: Wed Feb 5 20:18:13 2025 +0000 - - ../gvisor/tools/rules_cgo.patch - diff --git a/go/private/rules/cgo.bzl b/go/private/rules/cgo.bzl index b8fc93a6..3fec27e4 100644 --- a/go/private/rules/cgo.bzl diff --git a/tools/rules_go_export.patch b/tools/rules_go_export.patch index 04095d2cd9..6955cfc380 100644 --- a/tools/rules_go_export.patch +++ b/tools/rules_go_export.patch @@ -1,8 +1,8 @@ diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl -index 3bf0bffd..7cfe2fcc 100644 +index ab56991c..ebe43ca2 100644 --- a/go/private/actions/archive.bzl +++ b/go/private/actions/archive.bzl -@@ -201,6 +201,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d +@@ -219,6 +219,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d data = data, direct = direct, libs = depset(direct = [out_lib], transitive = [a.libs for a in direct]), @@ -11,22 +11,22 @@ index 3bf0bffd..7cfe2fcc 100644 x_defs = x_defs, cgo_deps = depset(transitive = [cgo_deps] + [a.cgo_deps for a in direct]), diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl -index 40b4011e..688a90b8 100644 +index 064831bb..3ca16253 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl -@@ -124,6 +124,7 @@ def _go_binary_impl(ctx): - source, +@@ -157,6 +157,7 @@ def _go_binary_impl(ctx): + providers = [ archive, OutputGroupInfo( + export_files = archive.export_files, cgo_exports = archive.cgo_exports, compilation_outputs = [archive.data.file], - ), + nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [], diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl -index ac563544..e3dbfe81 100644 +index 68a1d3b9..53c38cb2 100644 --- a/go/private/rules/library.bzl +++ b/go/private/rules/library.bzl -@@ -53,6 +53,8 @@ def _go_library_impl(ctx): +@@ -64,6 +64,8 @@ def _go_library_impl(ctx): extensions = ["go"], ), OutputGroupInfo( @@ -34,45 +34,59 @@ index ac563544..e3dbfe81 100644 + libs = archive.libs, cgo_exports = archive.cgo_exports, compilation_outputs = [archive.data.file], - ), -@@ -102,8 +104,7 @@ go_library = rule( - with the same path (for example, from different vendor directories). - """, - ), -- "importpath_aliases": attr.string_list( -- ), # experimental, undocumented -+ "importpath_aliases": attr.string_list(), # experimental, undocumented - "embed": attr.label_list( - providers = [GoLibrary], - doc = """ + nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [], +@@ -214,9 +216,23 @@ def _go_tool_library_impl(ctx): + go_info = new_go_info(go, ctx.attr) + archive = go.archive(go, go_info) + ++ validation_output = archive.data._validation_output ++ nogo_diagnostics = archive.data._nogo_diagnostics ++ + return [ + go_info, + archive, ++ DefaultInfo( ++ files = depset([archive.data.export_file]), ++ ), ++ OutputGroupInfo( ++ export_files = archive.export_files, ++ libs = archive.libs, ++ cgo_exports = archive.cgo_exports, ++ compilation_outputs = [archive.data.file], ++ nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [], ++ _validation = [validation_output] if validation_output else [], ++ ), + ] + + go_tool_library = rule( diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl -index 554cd30c..4aeab1b4 100644 +index dcb4eb63..660505b4 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl -@@ -183,6 +183,8 @@ def _go_test_impl(ctx): +@@ -215,6 +215,8 @@ def _go_test_impl(ctx): ), OutputGroupInfo( compilation_outputs = [internal_archive.data.file], + export_files = internal_archive.export_files, + libs = internal_archive.libs, + nogo_fix = nogo_diagnosticss, + _validation = validation_outputs, ), - coverage_common.instrumented_files_info( - ctx, -@@ -697,6 +699,7 @@ def _recompile_external_deps(go, external_source, internal_archive, library_labe +@@ -723,6 +725,7 @@ def _recompile_external_deps(go, external_go_info, internal_archive, library_lab data = arc_data, direct = deps, libs = depset(direct = [arc_data.file], transitive = [a.libs for a in deps]), + export_files = depset(direct = [arc_data.export_file], transitive = [a.export_files for a in deps]), transitive = depset(direct = [arc_data], transitive = [a.transitive for a in deps]), - x_defs = source.x_defs, - cgo_deps = depset(direct = arc_data._cgo_deps, transitive = [a.cgo_deps for a in deps]), + x_defs = go_info.x_defs, + cgo_deps = depset(transitive = [arc_data._cgo_deps] + [a.cgo_deps for a in deps]), diff --git a/proto/def.bzl b/proto/def.bzl -index 6a2a2d72..0fa8f800 100644 +index 7b70b83c..5c120de5 100644 --- a/proto/def.bzl +++ b/proto/def.bzl -@@ -136,10 +136,11 @@ def _go_proto_library_impl(ctx): +@@ -154,10 +154,11 @@ def _go_proto_library_impl(ctx): if valid_archive: - archive = go.archive(go, source) + archive = go.archive(go, go_info) output_groups["compilation_outputs"] = [archive.data.file] + output_groups["export_files"] = archive.export_files providers.extend([ diff --git a/tools/rules_go_sdk.patch b/tools/rules_go_sdk.patch index 5cd98a971e..2e43f5db48 100644 --- a/tools/rules_go_sdk.patch +++ b/tools/rules_go_sdk.patch @@ -1,14 +1,8 @@ -commit 441d5858370a443b117e1bcc19288b79d092147e -Author: Andrei Vagin -Date: Wed Feb 5 20:18:48 2025 +0000 - - ../gvisor/tools/rules_go_sdk.patch - diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl -index ca70b237..71149eba 100644 +index 156bb255..619c5395 100644 --- a/go/private/sdk.bzl +++ b/go/private/sdk.bzl -@@ -130,6 +130,8 @@ def _go_download_sdk_impl(ctx): +@@ -129,6 +129,8 @@ def _go_download_sdk_impl(ctx): "sdks": ctx.attr.sdks, "urls": ctx.attr.urls, "version": version, @@ -17,7 +11,7 @@ index ca70b237..71149eba 100644 "strip_prefix": ctx.attr.strip_prefix, } return None -@@ -145,6 +147,7 @@ go_download_sdk_rule = repository_rule( +@@ -144,6 +146,7 @@ go_download_sdk_rule = repository_rule( ), "urls": attr.string_list(default = ["https://dl.google.com/go/{}"]), "version": attr.string(), @@ -25,12 +19,12 @@ index ca70b237..71149eba 100644 "strip_prefix": attr.string(default = "go"), "patches": attr.label_list( doc = "A list of patches to apply to the SDK after downloading it", -@@ -462,6 +465,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256): - res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"]) - if res.return_code: - fail("error extracting Go SDK:\n" + res.stdout + res.stderr) -+ if ctx.attr.patch: -+ ctx.patch(ctx.attr.patch, strip=ctx.attr.patch_strip) - ctx.delete("go_sdk.tar.gz") - elif (urls[0].endswith(".zip") and - host_goos == "darwin" and +@@ -432,6 +435,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256): + sha256 = sha256, + auth = auth, + ) ++ if ctx.attr.patch: ++ ctx.patch(ctx.attr.patch, strip = ctx.attr.patch_strip) + + def _local_sdk(ctx, path): + for entry in ctx.path(path).readdir(): diff --git a/tools/rules_go_symbols.patch b/tools/rules_go_symbols.patch index 51e5f15ad8..dd6e18338f 100644 --- a/tools/rules_go_symbols.patch +++ b/tools/rules_go_symbols.patch @@ -1,12 +1,12 @@ diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl -index 1283776a..bc868296 100644 +index 12dd1cc5..dcb4eb63 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl -@@ -124,9 +124,6 @@ def _go_test_impl(ctx): +@@ -150,9 +150,6 @@ def _go_test_impl(ctx): ) test_gc_linkopts = gc_linkopts(ctx) -- if not go.mode.debug: +- if not go.mode.debug and go.mode.strip: - # Disable symbol table and DWARF generation for test binaries. - test_gc_linkopts.extend(["-s", "-w"]) diff --git a/vdso/BUILD b/vdso/BUILD index cc993b2e96..acfd53d295 100644 --- a/vdso/BUILD +++ b/vdso/BUILD @@ -5,7 +5,7 @@ # Placeholder: load py_test load("//tools:arch.bzl", "select_arch") -load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain", "vdso_linker_option") +load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain") package( default_applicable_licenses = ["//:license"], @@ -40,7 +40,6 @@ genrule( # Some toolchains enable stack protector by default. Disable it, the # VDSO has no hooks to handle failures. "-fno-stack-protector " + - vdso_linker_option + "-shared " + "-nostdlib " + "-Wl,-soname=linux-vdso.so.1 " +