Add toolchain definitions for autoconfigured cc_toolchain entries.
PiperOrigin-RevId: 190611069
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 4412b14..57007d32 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -1,7 +1,52 @@
+# Copyright 2018 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.
+
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
+# The toolchain type used to distinguish cc toolchains.
+cc_toolchain_type(name = "toolchain_type")
+
+# It is frequently necessary to constrain platforms based on the cc compiler type.
+constraint_setting(name = "cc_compiler")
+
+constraint_value(
+ name = "clang",
+ constraint_setting = ":cc_compiler",
+)
+
+constraint_value(
+ name = "gcc",
+ constraint_setting = ":cc_compiler",
+)
+
+constraint_value(
+ name = "msvc",
+ constraint_setting = ":cc_compiler",
+)
+
+constraint_value(
+ name = "mingw",
+ constraint_setting = ":cc_compiler",
+)
+
+constraint_value(
+ name = "msys",
+ constraint_setting = ":cc_compiler",
+)
+
# TODO(lberki): Remove this once cc_toolchain_alias is in a Bazel release
cc_toolchain_alias(name = "current_cc_toolchain")
@@ -67,6 +112,18 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-local",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:autoconfigured",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:autoconfigured",
+ ],
+ toolchain = ":cc-compiler-local",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-ppc",
all_files = ":empty",
@@ -81,6 +138,18 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-ppc",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:ppc",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:ppc",
+ ],
+ toolchain = ":cc-compiler-ppc",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-armeabi-v7a",
all_files = ":empty",
@@ -95,6 +164,18 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-armeabi-v7a",
+ exec_compatible_with = [
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:arm",
+ "@bazel_tools//platforms:android",
+ ],
+ toolchain = ":cc-compiler-armeabi-v7a",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-k8",
all_files = ":empty",
@@ -109,6 +190,20 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-k8",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:linux",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:linux",
+ ],
+ toolchain = ":cc-compiler-k8",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-darwin",
all_files = ":osx_wrapper",
@@ -123,6 +218,20 @@
supports_param_files = 0,
)
+toolchain(
+ name = "cc-toolchain-darwin",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:osx",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:osx",
+ ],
+ toolchain = ":cc-compiler-darwin",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-freebsd",
all_files = ":empty",
@@ -137,6 +246,20 @@
supports_param_files = 0,
)
+toolchain(
+ name = "cc-toolchain-freebsd",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:freebsd",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:freebsd",
+ ],
+ toolchain = ":cc-compiler-freebsd",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-x64_windows",
all_files = ":empty",
@@ -151,6 +274,20 @@
supports_param_files = 0,
)
+toolchain(
+ name = "cc-toolchain-x64_windows",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ toolchain = ":cc-compiler-x64_windows",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-x64_windows_msvc",
all_files = ":every-file-x64_windows",
@@ -165,6 +302,21 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-x64_windows_msvc",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ":msvc",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ toolchain = ":cc-compiler-x64_windows_msvc",
+ toolchain_type = ":toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-ios_x86_64",
all_files = ":empty",
@@ -179,6 +331,18 @@
supports_param_files = 0,
)
+toolchain(
+ name = "cc-toolchain-ios_x86_64",
+ exec_compatible_with = [
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:ios",
+ ],
+ toolchain = ":cc-compiler-ios_x86_64",
+ toolchain_type = ":toolchain_type",
+)
+
filegroup(
name = "every-file-x64_windows",
srcs = [
@@ -228,18 +392,3 @@
name = "crosstool_lib",
srcs = ["crosstool_lib.bzl"],
)
-
-cc_toolchain_type(name = "toolchain_type")
-
-# A dummy toolchain is necessary to satisfy toolchain resolution until platforms
-# are used in c++ by default.
-# TODO(b/64754003): Remove once platforms are used in c++ by default.
-toolchain(
- name = "dummy_cc_toolchain",
- toolchain = "dummy_cc_toolchain_impl",
- toolchain_type = ":toolchain_type",
-)
-
-load(":dummy_toolchain.bzl", "dummy_toolchain")
-
-dummy_toolchain(name = "dummy_cc_toolchain_impl")
diff --git a/tools/cpp/BUILD.static b/tools/cpp/BUILD.static
deleted file mode 100644
index 6175a5a..0000000
--- a/tools/cpp/BUILD.static
+++ /dev/null
@@ -1,146 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "malloc",
-)
-
-cc_library(
- name = "stl",
-)
-
-filegroup(
- name = "empty",
- srcs = [],
-)
-
-# Hardcoded toolchain, legacy behaviour.
-cc_toolchain_suite(
- name = "toolchain",
- toolchains = {
- "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
- "freebsd|compiler": ":cc-compiler-freebsd",
- "x64_windows|msvc-cl": ":cc-compiler-x64_windows",
- "x64_windows|msys-gcc": ":cc-compiler-x64_windows_msys",
- "x64_windows|mingw-gcc": ":cc-compiler-x64_windows_mingw",
- "ios_x86_64|compiler": ":cc-compiler-ios_x86_64",
- },
-)
-
-cc_toolchain(
- name = "cc-compiler-armeabi-v7a",
- all_files = ":empty",
- compiler_files = ":empty",
- cpu = "local",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 1,
-)
-
-cc_toolchain(
- name = "cc-compiler-freebsd",
- all_files = ":empty",
- compiler_files = ":empty",
- cpu = "local",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 0,
-)
-
-cc_toolchain(
- name = "cc-compiler-x64_windows_msys",
- all_files = ":empty",
- compiler_files = ":empty",
- cpu = "local",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 1,
-)
-
-cc_toolchain(
- name = "cc-compiler-x64_windows_mingw",
- all_files = ":empty",
- compiler_files = ":empty",
- cpu = "x64_windows",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 1,
-)
-
-cc_toolchain(
- name = "cc-compiler-x64_windows",
- all_files = ":every-file-x64_windows",
- compiler_files = ":compile-x64_windows",
- cpu = "x64_windows",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 1,
-)
-
-cc_toolchain(
- name = "cc-compiler-ios_x86_64",
- all_files = ":empty",
- compiler_files = ":empty",
- cpu = "local",
- dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
- linker_files = ":empty",
- objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
- strip_files = ":empty",
- supports_param_files = 0,
-)
-
-filegroup(
- name = "every-file-x64_windows",
- srcs = [
- ":compile-x64_windows",
- ],
-)
-
-filegroup(
- name = "compile-x64_windows",
- srcs = glob([
- "wrapper/bin/msvc_*",
- "wrapper/bin/pydir/msvc*",
- ]),
-)
-
-filegroup(
- name = "link_dynamic_library",
- srcs = ["link_dynamic_library.sh"],
-)
-
-cc_toolchain_type(name = "toolchain_type")
-
-# A dummy toolchain is necessary to satisfy toolchain resolution until platforms
-# are used in c++ by default.
-# TODO(b/64754003): Remove once platforms are used in c++ by default.
-toolchain(
- name = "dummy_cc_toolchain",
- toolchain = "dummy_cc_toolchain_impl",
- toolchain_type = ":toolchain_type",
-)
-
-load(":dummy_toolchain.bzl", "dummy_toolchain")
-
-dummy_toolchain(name = "dummy_cc_toolchain_impl")
diff --git a/tools/cpp/BUILD.static.freebsd b/tools/cpp/BUILD.static.freebsd
new file mode 100644
index 0000000..4ec5691
--- /dev/null
+++ b/tools/cpp/BUILD.static.freebsd
@@ -0,0 +1,128 @@
+# Copyright 2018 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 becomes the BUILD file for @local_config_cc// under FreeBSD.
+
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "malloc",
+)
+
+cc_library(
+ name = "stl",
+)
+
+filegroup(
+ name = "empty",
+ srcs = [],
+)
+
+# Hardcoded toolchain, legacy behaviour.
+cc_toolchain_suite(
+ name = "toolchain",
+ toolchains = {
+ "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
+ "freebsd|compiler": ":cc-compiler-freebsd",
+ "ios_x86_64|compiler": ":cc-compiler-ios_x86_64",
+ },
+)
+
+cc_toolchain(
+ name = "cc-compiler-freebsd",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
+toolchain(
+ name = "cc-toolchain-freebsd",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:freebsd",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:freebsd",
+ ],
+ toolchain = ":cc-compiler-freebsd",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-armeabi-v7a",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
+toolchain(
+ name = "cc-toolchain-armeabi-v7a",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:arm",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:arm",
+ "@bazel_tools//platforms:android",
+ ],
+ toolchain = ":cc-compiler-armeabi-v7a",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-ios_x86_64",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
+toolchain(
+ name = "cc-toolchain-ios_x86_64",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:osx",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:ios",
+ ],
+ toolchain = ":cc-compiler-ios_x86_64",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+filegroup(
+ name = "link_dynamic_library",
+ srcs = ["link_dynamic_library.sh"],
+)
diff --git a/tools/cpp/BUILD.static.windows b/tools/cpp/BUILD.static.windows
new file mode 100644
index 0000000..6281a05
--- /dev/null
+++ b/tools/cpp/BUILD.static.windows
@@ -0,0 +1,200 @@
+# Copyright 2018 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 becomes the BUILD file for @local_config_cc// under Windows.
+
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "malloc",
+)
+
+cc_library(
+ name = "stl",
+)
+
+filegroup(
+ name = "empty",
+ srcs = [],
+)
+
+# Hardcoded toolchain, legacy behaviour.
+cc_toolchain_suite(
+ name = "toolchain",
+ toolchains = {
+ "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
+ "x64_windows|msvc-cl": ":cc-compiler-x64_windows",
+ "x64_windows|msys-gcc": ":cc-compiler-x64_windows_msys",
+ "x64_windows|mingw-gcc": ":cc-compiler-x64_windows_mingw",
+ "ios_x86_64|compiler": ":cc-compiler-ios_x86_64",
+ },
+)
+
+cc_toolchain(
+ name = "cc-compiler-x64_windows_msys",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 1,
+)
+
+toolchain(
+ name = "cc-toolchain-x64_windows_msys",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ "@bazel_tools//tools/cpp:msys",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ toolchain = ":cc-compiler-x64_windows_msys",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-x64_windows_mingw",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "x64_windows",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
+toolchain(
+ name = "cc-toolchain-x64_windows_mingw",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ "@bazel_tools//tools/cpp:mingw",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ toolchain = ":cc-compiler-x64_windows_mingw",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-x64_windows",
+ all_files = ":every-file-x64_windows",
+ compiler_files = ":compile-x64_windows",
+ cpu = "x64_windows",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 1,
+)
+
+toolchain(
+ name = "cc-toolchain-x64_windows",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:windows",
+ ],
+ toolchain = ":cc-compiler-x64_windows",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-armeabi-v7a",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 1,
+)
+
+toolchain(
+ name = "cc-toolchain-armeabi-v7a",
+ exec_compatible_with = [
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:arm",
+ "@bazel_tools//platforms:android",
+ ],
+ toolchain = ":cc-compiler-armeabi-v7a",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+cc_toolchain(
+ name = "cc-compiler-ios_x86_64",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
+toolchain(
+ name = "cc-toolchain-ios_x86_64",
+ exec_compatible_with = [
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:ios",
+ ],
+ toolchain = ":cc-compiler-ios_x86_64",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
+filegroup(
+ name = "every-file-x64_windows",
+ srcs = [
+ ":compile-x64_windows",
+ ],
+)
+
+filegroup(
+ name = "compile-x64_windows",
+ srcs = glob([
+ "wrapper/bin/msvc_*",
+ "wrapper/bin/pydir/msvc*",
+ ]),
+)
+
+filegroup(
+ name = "link_dynamic_library",
+ srcs = ["link_dynamic_library.sh"],
+)
diff --git a/tools/cpp/BUILD.tpl b/tools/cpp/BUILD.tpl
index edf2ba6..f2bf8cd 100644
--- a/tools/cpp/BUILD.tpl
+++ b/tools/cpp/BUILD.tpl
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# This becomes the BUILD file for @local_config_cc// under non-FreeBSD unixes.
+
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
@@ -65,6 +67,19 @@
supports_param_files = %{supports_param_files},
)
+toolchain(
+ name = "cc-toolchain-%{name}",
+ exec_compatible_with = [
+ # This toolchain will only work with the local autoconfigured platforms.
+ "@bazel_tools//platforms:autoconfigured",
+ # TODO(katre): add autodiscovered constraints for host CPU and OS.
+ ],
+ target_compatible_with = [
+ # TODO(katre): add autodiscovered constraints for host CPU and OS.
+ ],
+ toolchain = ":cc-compiler-%{name}",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
# Android tooling requires a default toolchain for the armeabi-v7a cpu.
cc_toolchain(
@@ -81,6 +96,19 @@
supports_param_files = 1,
)
+toolchain(
+ name = "cc-toolchain-armeabi-v7a",
+ exec_compatible_with = [
+ # TODO(katre): add autodiscovered constraints for host CPU and OS.
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:arm",
+ "@bazel_tools//platforms:android",
+ ],
+ toolchain = ":cc-compiler-armabi-v7a",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
# ios crosstool configuration requires a default toolchain for the
# ios_x86_64 cpu.
cc_toolchain(
@@ -97,17 +125,15 @@
supports_param_files = 1,
)
-cc_toolchain_type(name = "toolchain_type")
-
-# A dummy toolchain is necessary to satisfy toolchain resolution until platforms
-# are used in c++ by default.
-# TODO(b/64754003): Remove once platforms are used in c++ by default.
toolchain(
- name = "dummy_cc_toolchain",
- toolchain = "dummy_cc_toolchain_impl",
- toolchain_type = ":toolchain_type",
+ name = "cc-toolchain-ios_x86_64",
+ exec_compatible_with = [
+ # TODO(katre): add autodiscovered constraints for host CPU and OS.
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:ios",
+ ],
+ toolchain = ":cc-compiler-ios_x86_64",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
-
-load(":dummy_toolchain.bzl", "dummy_toolchain")
-
-dummy_toolchain(name = "dummy_cc_toolchain_impl")
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 858c5bc..925ecbc 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -13,7 +13,6 @@
# limitations under the License.
"""Rules for configuring the C++ toolchain (experimental)."""
-
load("@bazel_tools//tools/cpp:windows_cc_configure.bzl", "configure_windows_toolchain")
load("@bazel_tools//tools/cpp:osx_cc_configure.bzl", "configure_osx_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_configure.bzl", "configure_unix_toolchain")
@@ -30,7 +29,7 @@
# straightforward to add but we cannot run it in a docker container so
# skipping until we have proper tests for FreeBSD.
repository_ctx.symlink(Label("@bazel_tools//tools/cpp:CROSSTOOL"), "CROSSTOOL")
- repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static"), "BUILD")
+ repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static.freebsd"), "BUILD")
elif cpu_value == "x64_windows":
# TODO(ibiryukov): overriden_tools are only supported in configure_unix_toolchain.
# We might want to add that to Windows too(at least for msys toolchain).
@@ -42,7 +41,6 @@
configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools)
cc_autoconf = repository_rule(
- implementation = cc_autoconf_impl,
environ = [
"ABI_LIBC_VERSION",
"ABI_VERSION",
@@ -72,10 +70,15 @@
"VS100COMNTOOLS",
"VS110COMNTOOLS",
"VS120COMNTOOLS",
- "VS140COMNTOOLS"])
-
+ "VS140COMNTOOLS",
+ ],
+ implementation = cc_autoconf_impl,
+)
def cc_configure():
"""A C++ configuration rules that generate the crosstool file."""
cc_autoconf(name="local_config_cc")
native.bind(name="cc_toolchain", actual="@local_config_cc//:toolchain")
+ native.register_toolchains(
+ # Use register_toolchain's target pattern expansion to register all toolchains in the package.
+ "@local_config_cc//:all")
diff --git a/tools/cpp/windows_cc_configure.bzl b/tools/cpp/windows_cc_configure.bzl
index f7f7df1..605760d 100644
--- a/tools/cpp/windows_cc_configure.bzl
+++ b/tools/cpp/windows_cc_configure.bzl
@@ -27,7 +27,6 @@
"is_cc_configure_debug",
)
-
def _get_escaped_windows_msys_crosstool_content(repository_ctx, use_mingw = False):
"""Return the content of msys crosstool which is still the default CROSSTOOL on Windows."""
bazel_sh = get_env_var(repository_ctx, "BAZEL_SH").replace("\\", "/").lower()
@@ -71,7 +70,6 @@
' feature { name: "targets_windows" implies: "copy_dynamic_libraries_to_binary" enabled: true }' +
' feature { name: "copy_dynamic_libraries_to_binary" }' )
-
def _get_system_root(repository_ctx):
r"""Get System root path on Windows, default is C:\\Windows. Doesn't %-escape the result."""
if "SYSTEMROOT" in repository_ctx.os.environ:
@@ -79,7 +77,6 @@
auto_configure_warning("SYSTEMROOT is not set, using default SYSTEMROOT=C:\\Windows")
return "C:\\Windows"
-
def _find_cuda(repository_ctx):
"""Find out if and where cuda is installed. Doesn't %-escape the result."""
if "CUDA_PATH" in repository_ctx.os.environ:
@@ -89,7 +86,6 @@
return nvcc[:-len("/bin/nvcc.exe")]
return None
-
def _find_python(repository_ctx):
"""Find where is python on Windows. Doesn't %-escape the result."""
if "BAZEL_PYTHON" in repository_ctx.os.environ:
@@ -102,7 +98,6 @@
auto_configure_warning("Python found at %s" % python_binary)
return python_binary
-
def _add_system_root(repository_ctx, env):
r"""Running VCVARSALL.BAT and VCVARSQUERYREGISTRY.BAT need %SYSTEMROOT%\\system32 in PATH."""
if "PATH" not in env:
@@ -110,7 +105,6 @@
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.
@@ -167,7 +161,6 @@
auto_configure_warning("Visual C++ build tools found at %s" % vc_dir)
return vc_dir
-
def _is_vs_2017(vc_path):
"""Check if the installed VS version is Visual Studio 2017."""
# In VS 2017, the location of VC is like:
@@ -176,7 +169,6 @@
# C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\
return vc_path.find("2017") != -1
-
def _find_vcvarsall_bat_script(repository_ctx, vc_path):
"""Find vcvarsall.bat script. Doesn't %-escape the result."""
if _is_vs_2017(vc_path):
@@ -189,7 +181,6 @@
return vcvarsall
-
def setup_vc_env_vars(repository_ctx, vc_path):
"""Get environment variables set by VCVARSALL.BAT. Doesn't %-escape the result!"""
vcvarsall = _find_vcvarsall_bat_script(repository_ctx, vc_path)
@@ -208,7 +199,6 @@
env_map[key] = escape_string(value.replace("\\", "\\\\"))
return env_map
-
def find_msvc_tool(repository_ctx, vc_path, tool):
"""Find the exact path of a specific build tool in MSVC. Doesn't %-escape the result."""
tool_path = ""
@@ -246,7 +236,6 @@
return missing_tools
-
def _is_support_whole_archive(repository_ctx, vc_path):
"""Run MSVC linker alone to see if it supports /WHOLEARCHIVE."""
env = repository_ctx.os.environ
@@ -256,20 +245,17 @@
result = execute(repository_ctx, [linker], expect_failure = True)
return result.find("/WHOLEARCHIVE") != -1
-
def _is_support_debug_fastlink(repository_ctx, vc_path):
"""Run MSVC linker alone to see if it supports /DEBUG:FASTLINK."""
linker = find_msvc_tool(repository_ctx, vc_path, "link.exe")
result = execute(repository_ctx, [linker], expect_failure = True)
return result.find("/DEBUG[:{FASTLINK|FULL|NONE}]") != -1
-
def _is_use_msvc_wrapper(repository_ctx):
"""Returns True if USE_MSVC_WRAPPER is set to 1."""
env = repository_ctx.os.environ
return "USE_MSVC_WRAPPER" in env and env["USE_MSVC_WRAPPER"] == "1"
-
def _get_compilation_mode_content():
"""Return the content for adding flags for different compilation modes when using MSVC wrapper."""
return "\n".join([
@@ -289,7 +275,6 @@
" linker_flag: '-Xcompilation-mode=opt'",
" }"])
-
def _escaped_cuda_compute_capabilities(repository_ctx):
"""Returns a %-escaped list of strings representing cuda compute capabilities."""
@@ -306,10 +291,9 @@
auto_configure_fail("Invalid compute capability: %s" % capability)
return capabilities
-
def configure_windows_toolchain(repository_ctx):
"""Configure C++ toolchain on Windows."""
- repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static"), "BUILD")
+ repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static.windows"), "BUILD")
vc_path = find_vc_path(repository_ctx)
missing_tools = None