From 17273615633abbbdcd0b0f7b0945a7d479b709e4 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 5 May 2022 02:02:41 -0700 Subject: [PATCH] Remove cpp:default-toolchain This was disabled in bazel 1.0 but there were still a lot of remnants around. https://github.com/bazelbuild/bazel/issues/8546 Closes #15003. PiperOrigin-RevId: 446659276 --- .../build/lib/rules/cpp/CppOptions.java | 12 - .../shell/integration/loading_phase_test.sh | 3 - tools/cpp/BUILD.tools | 389 ----- tools/cpp/cc_toolchain_config.bzl | 1498 ----------------- 4 files changed, 1902 deletions(-) delete mode 100644 tools/cpp/cc_toolchain_config.bzl diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 7825ef35873feb..df2ec9036d643d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -888,17 +888,6 @@ public Label getPropellerOptimizeLabel() { + "actions. See https://github.com/bazelbuild/bazel/issues/8531") public boolean useSpecificToolFiles; - @Option( - name = "incompatible_disable_static_cc_toolchains", - defaultValue = "true", - documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, - effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, - help = - "@bazel_tools//tools/cpp:default-toolchain target was removed." - + "See https://github.com/bazelbuild/bazel/issues/8546.") - public boolean disableStaticCcToolchains; - @Option( name = "incompatible_disable_nocopts", defaultValue = "true", @@ -1200,7 +1189,6 @@ public FragmentOptions getHost() { host.requireCtxInConfigureFeatures = requireCtxInConfigureFeatures; host.useStandaloneLtoIndexingCommandLines = useStandaloneLtoIndexingCommandLines; host.useSpecificToolFiles = useSpecificToolFiles; - host.disableStaticCcToolchains = disableStaticCcToolchains; host.disableNoCopts = disableNoCopts; host.loadCcRulesFromBzl = loadCcRulesFromBzl; host.validateTopLevelHeaderInclusions = validateTopLevelHeaderInclusions; diff --git a/src/test/shell/integration/loading_phase_test.sh b/src/test/shell/integration/loading_phase_test.sh index 502441c8998070..b4e497051d1a73 100755 --- a/src/test/shell/integration/loading_phase_test.sh +++ b/src/test/shell/integration/loading_phase_test.sh @@ -57,9 +57,6 @@ if "$is_windows"; then export MSYS2_ARG_CONV_EXCL="*" fi -# Our tests use the static crosstool, so make it the default. -# add_to_bazelrc "build --crosstool_top=@bazel_tools//tools/cpp:default-toolchain" - output_base=$TEST_TMPDIR/out TEST_stderr=$(dirname $TEST_log)/stderr diff --git a/tools/cpp/BUILD.tools b/tools/cpp/BUILD.tools index 2be05b758cfeff..af0e9a92a18a5e 100644 --- a/tools/cpp/BUILD.tools +++ b/tools/cpp/BUILD.tools @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load(":cc_toolchain_config.bzl", "cc_toolchain_config") - package(default_visibility = ["//visibility:public"]) licenses(["notice"]) # Apache 2.0 @@ -97,393 +95,6 @@ alias( actual = "@local_config_cc//:toolchain", ) -# Hardcoded toolchain, legacy behaviour. -cc_toolchain_suite( - name = "default-toolchain", - toolchains = { - "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", - "darwin|compiler": ":cc-compiler-darwin", - "freebsd|compiler": ":cc-compiler-freebsd", - "local|compiler": ":cc-compiler-local", - "x64_windows|compiler": ":cc-compiler-x64_windows", - "x64_windows_msvc|compiler": ":cc-compiler-x64_windows_msvc", - "s390x|compiler": ":cc-compiler-s390x", - "ppc|compiler": ":cc-compiler-ppc", - "mips64|compiler": ":cc-compiler-mips64", - "riscv64|compiler": ":cc-compiler-riscv64", - "k8": ":cc-compiler-local", - "piii": ":cc-compiler-local", - "arm": ":cc-compiler-local", - "aarch64": ":cc-compiler-local", - "s390x": ":cc-compiler-local", - "ppc": ":cc-compiler-local", - "ppc64": ":cc-compiler-local", - "mips64": ":cc-compiler-local", - "riscv64": ":cc-compiler-local", - "darwin": ":cc-compiler-darwin", - "freebsd": ":cc-compiler-freebsd", - "armeabi-v7a": ":cc-compiler-armeabi-v7a", - "x64_windows": ":cc-compiler-x64_windows", - "x64_windows_msvc": ":cc-compiler-x64_windows_msvc", - }, -) - -cc_toolchain( - name = "cc-compiler-local", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -cc_toolchain_config( - name = "local_linux", - compiler = "compiler", - cpu = "local", - disable_static_cc_toolchains = select({ - ":disable_static_cc_toolchains": True, - "//conditions:default": False, - }), -) - -toolchain( - name = "cc-toolchain-local", - exec_compatible_with = [ - ], - target_compatible_with = [ - ], - toolchain = ":cc-compiler-local", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-ppc", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-ppc", - exec_compatible_with = [ - "@platforms//cpu:ppc", - ], - target_compatible_with = [ - "@platforms//cpu:ppc", - ], - toolchain = ":cc-compiler-ppc", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-s390x", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-s390x", - exec_compatible_with = [ - "@platforms//cpu:s390x", - ], - target_compatible_with = [ - "@platforms//cpu:s390x", - ], - toolchain = ":cc-compiler-s390x", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-mips64", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-mips64", - exec_compatible_with = [ - "@platforms//cpu:mips64", - ], - target_compatible_with = [ - "@platforms//cpu:mips64", - ], - toolchain = ":cc-compiler-mips64", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-riscv64", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-riscv64", - exec_compatible_with = [ - "@platforms//cpu:riscv64", - ], - target_compatible_with = [ - "@platforms//cpu:riscv64", - ], - toolchain = ":cc-compiler-riscv64", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-armeabi-v7a", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-armeabi-v7a", - exec_compatible_with = [ - ], - target_compatible_with = [ - "@platforms//cpu:arm", - "@platforms//os:android", - ], - toolchain = ":cc-compiler-armeabi-v7a", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-k8", - 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, - toolchain_config = ":local_linux", - toolchain_identifier = "local_linux", -) - -toolchain( - name = "cc-toolchain-k8", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - toolchain = ":cc-compiler-k8", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-darwin", - all_files = ":osx_wrapper", - ar_files = ":empty", - as_files = ":osx_wrapper", - compiler_files = ":osx_wrapper", - dwp_files = ":empty", - linker_files = ":osx_wrapper", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - toolchain_config = ":local_darwin", - toolchain_identifier = "local_darwin", -) - -cc_toolchain_config( - name = "local_darwin", - compiler = "compiler", - cpu = "darwin", - disable_static_cc_toolchains = select({ - ":disable_static_cc_toolchains": True, - "//conditions:default": False, - }), -) - -toolchain( - name = "cc-toolchain-darwin", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:osx", - ], - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:osx", - ], - toolchain = ":cc-compiler-darwin", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-freebsd", - all_files = ":empty", - ar_files = ":empty", - as_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, - toolchain_config = ":local_freebsd", - toolchain_identifier = "local_freebsd", -) - -cc_toolchain_config( - name = "local_freebsd", - compiler = "compiler", - cpu = "freebsd", - disable_static_cc_toolchains = select({ - ":disable_static_cc_toolchains": True, - "//conditions:default": False, - }), -) - -toolchain( - name = "cc-toolchain-freebsd", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd", - ], - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd", - ], - toolchain = ":cc-compiler-freebsd", - toolchain_type = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-x64_windows", - all_files = ":empty", - ar_files = ":empty", - as_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, - toolchain_config = ":local_windows_msys64", - toolchain_identifier = "local_windows_msys64", -) - -cc_toolchain_config( - name = "local_windows_msys64", - compiler = "windows_msys64", - cpu = "x64_windows", - disable_static_cc_toolchains = select({ - ":disable_static_cc_toolchains": True, - "//conditions:default": False, - }), -) - -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 = ":toolchain_type", -) - -cc_toolchain( - name = "cc-compiler-x64_windows_msvc", - 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, - toolchain_config = ":vc_14_0_x64", - toolchain_identifier = "vc_14_0_x64", -) - -cc_toolchain_config( - name = "vc_14_0_x64", - compiler = "cl", - cpu = "x64_windows_msvc", - disable_static_cc_toolchains = select({ - ":disable_static_cc_toolchains": True, - "//conditions:default": False, - }), -) - -toolchain( - name = "cc-toolchain-x64_windows_msvc", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - ":msvc", - ], - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - ], - toolchain = ":cc-compiler-x64_windows_msvc", - toolchain_type = ":toolchain_type", -) - filegroup( name = "srcs", srcs = glob(["**"]) + [ diff --git a/tools/cpp/cc_toolchain_config.bzl b/tools/cpp/cc_toolchain_config.bzl deleted file mode 100644 index c36078599e962d..00000000000000 --- a/tools/cpp/cc_toolchain_config.bzl +++ /dev/null @@ -1,1498 +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""" - -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "action_config", - "feature", - "flag_group", - "flag_set", - "tool", - "tool_path", - "with_feature_set", -) -load( - "@bazel_tools//tools/build_defs/cc:action_names.bzl", - _ASSEMBLE_ACTION_NAME = "ASSEMBLE_ACTION_NAME", - _CLIF_MATCH_ACTION_NAME = "CLIF_MATCH_ACTION_NAME", - _CPP_COMPILE_ACTION_NAME = "CPP_COMPILE_ACTION_NAME", - _CPP_HEADER_PARSING_ACTION_NAME = "CPP_HEADER_PARSING_ACTION_NAME", - _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME", - _CPP_LINK_EXECUTABLE_ACTION_NAME = "CPP_LINK_EXECUTABLE_ACTION_NAME", - _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME", - _CPP_MODULE_CODEGEN_ACTION_NAME = "CPP_MODULE_CODEGEN_ACTION_NAME", - _CPP_MODULE_COMPILE_ACTION_NAME = "CPP_MODULE_COMPILE_ACTION_NAME", - _C_COMPILE_ACTION_NAME = "C_COMPILE_ACTION_NAME", - _LINKSTAMP_COMPILE_ACTION_NAME = "LINKSTAMP_COMPILE_ACTION_NAME", - _LTO_BACKEND_ACTION_NAME = "LTO_BACKEND_ACTION_NAME", - _PREPROCESS_ASSEMBLE_ACTION_NAME = "PREPROCESS_ASSEMBLE_ACTION_NAME", -) - -all_compile_actions = [ - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, -] - -all_cpp_compile_actions = [ - _CPP_COMPILE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, -] - -preprocessor_compile_actions = [ - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, -] - -codegen_compile_actions = [ - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, -] - -all_link_actions = [ - _CPP_LINK_EXECUTABLE_ACTION_NAME, - _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, - _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, -] - -def _impl(ctx): - if ctx.attr.disable_static_cc_toolchains: - fail("@bazel_tools//tools/cpp:default-toolchain, as well as the cc_toolchains it points " + - "to have been removed. See https://github.com/bazelbuild/bazel/issues/8546.") - - if (ctx.attr.cpu == "darwin"): - toolchain_identifier = "local_darwin" - elif (ctx.attr.cpu == "freebsd"): - toolchain_identifier = "local_freebsd" - elif (ctx.attr.cpu == "openbsd"): - toolchain_identifier = "local_openbsd" - elif (ctx.attr.cpu == "local"): - toolchain_identifier = "local_linux" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): - toolchain_identifier = "local_windows_clang" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): - toolchain_identifier = "local_windows_mingw" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - toolchain_identifier = "local_windows_msys64" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - toolchain_identifier = "local_windows_msys64_mingw64" - elif (ctx.attr.cpu == "armeabi-v7a"): - toolchain_identifier = "stub_armeabi-v7a" - elif (ctx.attr.cpu == "x64_windows_msvc"): - toolchain_identifier = "vc_14_0_x64" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - host_system_name = "armeabi-v7a" - elif (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows" or - ctx.attr.cpu == "x64_windows_msvc"): - host_system_name = "local" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - target_system_name = "armeabi-v7a" - elif (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows" or - ctx.attr.cpu == "x64_windows_msvc"): - target_system_name = "local" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - target_cpu = "armeabi-v7a" - elif (ctx.attr.cpu == "darwin"): - target_cpu = "darwin" - elif (ctx.attr.cpu == "freebsd"): - target_cpu = "freebsd" - elif (ctx.attr.cpu == "openbsd"): - target_cpu = "openbsd" - elif (ctx.attr.cpu == "local"): - target_cpu = "local" - elif (ctx.attr.cpu == "x64_windows"): - target_cpu = "x64_windows" - elif (ctx.attr.cpu == "x64_windows_msvc"): - target_cpu = "x64_windows_msvc" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - target_libc = "armeabi-v7a" - elif (ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows"): - target_libc = "local" - elif (ctx.attr.cpu == "darwin"): - target_libc = "macosx" - elif (ctx.attr.cpu == "x64_windows_msvc"): - target_libc = "msvcrt140" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "x64_windows_msvc"): - compiler = "cl" - elif (ctx.attr.cpu == "armeabi-v7a" or - ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local"): - compiler = "compiler" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): - compiler = "windows_clang" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): - compiler = "windows_mingw" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - compiler = "windows_msys64" - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - compiler = "windows_msys64_mingw64" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - abi_version = "armeabi-v7a" - elif (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows" or - ctx.attr.cpu == "x64_windows_msvc"): - abi_version = "local" - else: - fail("Unreachable") - - if (ctx.attr.cpu == "armeabi-v7a"): - abi_libc_version = "armeabi-v7a" - elif (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows" or - ctx.attr.cpu == "x64_windows_msvc"): - abi_libc_version = "local" - else: - fail("Unreachable") - - cc_target_os = None - - builtin_sysroot = None - - if (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local"): - objcopy_embed_data_action = action_config( - action_name = "objcopy_embed_data", - enabled = True, - tools = [tool(path = "/usr/bin/objcopy")], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): - objcopy_embed_data_action = action_config( - action_name = "objcopy_embed_data", - enabled = True, - tools = [tool(path = "C:/Program Files (x86)/LLVM/bin/objcopy")], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): - objcopy_embed_data_action = action_config( - action_name = "objcopy_embed_data", - enabled = True, - tools = [tool(path = "C:/mingw/bin/objcopy")], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - objcopy_embed_data_action = action_config( - action_name = "objcopy_embed_data", - enabled = True, - tools = [tool(path = "C:/tools/msys64/mingw64/bin/objcopy")], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - objcopy_embed_data_action = action_config( - action_name = "objcopy_embed_data", - enabled = True, - tools = [tool(path = "C:/tools/msys64/usr/bin/objcopy")], - ) - - c_compile_action = action_config( - action_name = _C_COMPILE_ACTION_NAME, - implies = [ - "compiler_input_flags", - "compiler_output_flags", - "default_compile_flags", - "user_compile_flags", - "sysroot", - "unfiltered_compile_flags", - ], - tools = [tool(path = "wrapper/bin/msvc_cl.bat")], - ) - - cpp_compile_action = action_config( - action_name = _CPP_COMPILE_ACTION_NAME, - implies = [ - "compiler_input_flags", - "compiler_output_flags", - "default_compile_flags", - "user_compile_flags", - "sysroot", - "unfiltered_compile_flags", - ], - tools = [tool(path = "wrapper/bin/msvc_cl.bat")], - ) - - if (ctx.attr.cpu == "armeabi-v7a"): - action_configs = [] - elif (ctx.attr.cpu == "x64_windows_msvc"): - action_configs = [c_compile_action, cpp_compile_action] - elif (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows"): - action_configs = [objcopy_embed_data_action] - else: - fail("Unreachable") - - random_seed_feature = feature(name = "random_seed", enabled = True) - - compiler_output_flags_feature = feature( - name = "compiler_output_flags", - flag_sets = [ - flag_set( - actions = [_ASSEMBLE_ACTION_NAME], - flag_groups = [ - flag_group( - flags = ["/Fo%{output_file}", "/Zi"], - expand_if_available = "output_file", - expand_if_not_available = "output_assembly_file", - ), - ], - ), - flag_set( - actions = [ - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/Fo%{output_file}"], - expand_if_available = "output_file", - expand_if_not_available = "output_assembly_file", - ), - flag_group( - flags = ["/Fa%{output_file}"], - expand_if_available = "output_file", - ), - flag_group( - flags = ["/P", "/Fi%{output_file}"], - expand_if_available = "output_file", - ), - ], - ), - ], - ) - - if (ctx.attr.cpu == "local"): - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = [ - "-lstdc++", - "-Wl,-z,relro,-z,now", - "-no-canonical-prefixes", - "-pass-exit-codes", - ], - ), - ], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], - with_features = [with_feature_set(features = ["opt"])], - ), - ], - ) - elif (ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd"): - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = [ - "-lc++", - "-Wl,-z,relro,-z,now", - "-no-canonical-prefixes", - ], - ), - ], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], - with_features = [with_feature_set(features = ["opt"])], - ), - ], - ) - elif (ctx.attr.cpu == "darwin"): - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [ - flag_group( - flags = [ - "-lc++", - "-undefined", - "dynamic_lookup", - "-headerpad_max_install_names", - "-no-canonical-prefixes", - ], - ), - ], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-lstdc++"])], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows_msvc"): - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-m64"])], - ), - ], - ) - - if (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd"): - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-no-canonical-prefixes", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], - ), - ], - ), - ], - ) - elif (ctx.attr.cpu == "local"): - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-no-canonical-prefixes", - "-fno-canonical-system-headers", - "-Wno-builtin-macro-redefined", - "-D__DATE__=\"redacted\"", - "-D__TIMESTAMP__=\"redacted\"", - "-D__TIME__=\"redacted\"", - ], - ), - ], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows_msvc"): - unfiltered_compile_flags_feature = feature( - name = "unfiltered_compile_flags", - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["%{unfiltered_compile_flags}"], - iterate_over = "unfiltered_compile_flags", - expand_if_available = "unfiltered_compile_flags", - ), - ], - ), - ], - ) - - supports_pic_feature = feature(name = "supports_pic", enabled = True) - - if (ctx.attr.cpu == "darwin"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-D_FORTIFY_SOURCE=1", - "-fstack-protector", - "-fcolor-diagnostics", - "-Wall", - "-Wthread-safety", - "-Wself-assign", - "-fno-omit-frame-pointer", - ], - ), - ], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-g"])], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-g0", - "-O2", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = [ - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-std=c++0x"])], - ), - ], - ) - elif (ctx.attr.cpu == "local"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-U_FORTIFY_SOURCE", - "-D_FORTIFY_SOURCE=1", - "-fstack-protector", - "-Wall", - "-Wunused-but-set-parameter", - "-Wno-free-nonheap-object", - "-fno-omit-frame-pointer", - ], - ), - ], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-g"])], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-g0", - "-O2", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = [ - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-std=c++0x"])], - ), - ], - ) - elif (ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-U_FORTIFY_SOURCE", - "-D_FORTIFY_SOURCE=1", - "-fstack-protector", - "-Wall", - "-fno-omit-frame-pointer", - ], - ), - ], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-g"])], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-g0", - "-O2", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = [ - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-std=c++0x"])], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows_msvc"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = [ - "-m64", - "/D__inline__=__inline", - "/DCOMPILER_MSVC", - "/DNOGDI", - "/DNOMINMAX", - "/DPRAGMA_SUPPORTED", - "/D_WIN32_WINNT=0x0601", - "/D_CRT_SECURE_NO_DEPRECATE", - "/D_CRT_SECURE_NO_WARNINGS", - "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS", - "/D_USE_MATH_DEFINES", - "/nologo", - "/bigobj", - "/Zm500", - "/J", - "/Gy", - "/GF", - "/W3", - "/EHsc", - "/wd4351", - "/wd4291", - "/wd4250", - "/wd4996", - ], - ), - ], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/DDEBUG=1", "-g", "/Od", "-Xcompilation-mode=dbg"], - ), - ], - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/DNDEBUG", "/Od", "-Xcompilation-mode=fastbuild"], - ), - ], - with_features = [with_feature_set(features = ["fastbuild"])], - ), - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/DNDEBUG", "/O2", "-Xcompilation-mode=opt"], - ), - ], - with_features = [with_feature_set(features = ["opt"])], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or - ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or - ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-std=c++0x"])], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _LINKSTAMP_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [flag_group(flags = ["-std=gnu++0x"])], - ), - ], - ) - - opt_feature = feature(name = "opt") - - supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) - - objcopy_embed_flags_feature = feature( - name = "objcopy_embed_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = ["objcopy_embed_data"], - flag_groups = [flag_group(flags = ["-I", "binary"])], - ), - ], - ) - - dbg_feature = feature(name = "dbg") - - if (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local"): - user_compile_flags_feature = feature( - name = "user_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["%{user_compile_flags}"], - iterate_over = "user_compile_flags", - expand_if_available = "user_compile_flags", - ), - ], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows_msvc"): - user_compile_flags_feature = feature( - name = "user_compile_flags", - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["%{user_compile_flags}"], - iterate_over = "user_compile_flags", - expand_if_available = "user_compile_flags", - ), - ], - ), - ], - ) - - if (ctx.attr.cpu == "darwin" or - ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local"): - sysroot_feature = feature( - name = "sysroot", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _LINKSTAMP_COMPILE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _LTO_BACKEND_ACTION_NAME, - _CLIF_MATCH_ACTION_NAME, - _CPP_LINK_EXECUTABLE_ACTION_NAME, - _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, - _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["--sysroot=%{sysroot}"], - expand_if_available = "sysroot", - ), - ], - ), - ], - ) - elif (ctx.attr.cpu == "x64_windows_msvc"): - sysroot_feature = feature( - name = "sysroot", - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - _CPP_LINK_EXECUTABLE_ACTION_NAME, - _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, - _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["--sysroot=%{sysroot}"], - iterate_over = "sysroot", - expand_if_available = "sysroot", - ), - ], - ), - ], - ) - - include_paths_feature = feature( - name = "include_paths", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - ], - 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", - ), - ], - ), - ], - ) - - dependency_file_feature = feature( - name = "dependency_file", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/DEPENDENCY_FILE", "%{dependency_file}"], - expand_if_available = "dependency_file", - ), - ], - ), - ], - ) - - compiler_input_flags_feature = feature( - name = "compiler_input_flags", - flag_sets = [ - flag_set( - actions = [ - _ASSEMBLE_ACTION_NAME, - _PREPROCESS_ASSEMBLE_ACTION_NAME, - _C_COMPILE_ACTION_NAME, - _CPP_COMPILE_ACTION_NAME, - _CPP_HEADER_PARSING_ACTION_NAME, - _CPP_MODULE_COMPILE_ACTION_NAME, - _CPP_MODULE_CODEGEN_ACTION_NAME, - ], - flag_groups = [ - flag_group( - flags = ["/c", "%{source_file}"], - expand_if_available = "source_file", - ), - ], - ), - ], - ) - - fastbuild_feature = feature(name = "fastbuild") - - if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - features = [ - default_compile_flags_feature, - default_link_flags_feature, - supports_dynamic_linker_feature, - objcopy_embed_flags_feature, - ] - elif (ctx.attr.cpu == "darwin"): - features = [ - default_compile_flags_feature, - default_link_flags_feature, - supports_pic_feature, - objcopy_embed_flags_feature, - dbg_feature, - opt_feature, - user_compile_flags_feature, - sysroot_feature, - unfiltered_compile_flags_feature, - ] - elif (ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd" or - ctx.attr.cpu == "local"): - features = [ - default_compile_flags_feature, - default_link_flags_feature, - supports_dynamic_linker_feature, - supports_pic_feature, - objcopy_embed_flags_feature, - opt_feature, - dbg_feature, - user_compile_flags_feature, - sysroot_feature, - unfiltered_compile_flags_feature, - ] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or - ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or - ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - features = [ - default_compile_flags_feature, - supports_dynamic_linker_feature, - objcopy_embed_flags_feature, - ] - elif (ctx.attr.cpu == "x64_windows_msvc"): - features = [ - default_link_flags_feature, - random_seed_feature, - default_compile_flags_feature, - include_paths_feature, - dependency_file_feature, - user_compile_flags_feature, - sysroot_feature, - unfiltered_compile_flags_feature, - compiler_output_flags_feature, - compiler_input_flags_feature, - dbg_feature, - fastbuild_feature, - opt_feature, - ] - elif (ctx.attr.cpu == "armeabi-v7a"): - features = [supports_dynamic_linker_feature, supports_pic_feature] - - if (ctx.attr.cpu == "armeabi-v7a"): - cxx_builtin_include_directories = [] - elif (ctx.attr.cpu == "darwin"): - cxx_builtin_include_directories = ["/"] - elif (ctx.attr.cpu == "freebsd" or - ctx.attr.cpu == "openbsd"): - cxx_builtin_include_directories = ["/usr/lib/clang", "/usr/local/include", "/usr/include"] - elif (ctx.attr.cpu == "local" or - ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): - cxx_builtin_include_directories = ["/usr/lib/gcc/", "/usr/local/include", "/usr/include"] - elif (ctx.attr.cpu == "x64_windows_msvc"): - cxx_builtin_include_directories = [ - "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/INCLUDE", - "C:/Program Files (x86)/Windows Kits/10/include/", - "C:/Program Files (x86)/Windows Kits/8.1/include/", - "C:/Program Files (x86)/GnuWin32/include/", - "C:/python_27_amd64/files/include", - ] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): - cxx_builtin_include_directories = ["C:/mingw/include", "C:/mingw/lib/gcc"] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - cxx_builtin_include_directories = ["C:/tools/msys64/mingw64/x86_64-w64-mingw32/include"] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - cxx_builtin_include_directories = ["C:/tools/msys64/", "/usr/"] - else: - fail("Unreachable") - - artifact_name_patterns = [] - - make_variables = [] - - if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): - tool_paths = [ - tool_path( - name = "ar", - path = "C:/tools/msys64/mingw64/bin/ar", - ), - tool_path( - name = "cpp", - path = "C:/tools/msys64/mingw64/bin/cpp", - ), - tool_path( - name = "dwp", - path = "C:/tools/msys64/mingw64/bin/dwp", - ), - tool_path( - name = "gcc", - path = "C:/tools/msys64/mingw64/bin/gcc", - ), - tool_path( - name = "gcov", - path = "C:/tools/msys64/mingw64/bin/gcov", - ), - tool_path( - name = "ld", - path = "C:/tools/msys64/mingw64/bin/ld", - ), - tool_path( - name = "nm", - path = "C:/tools/msys64/mingw64/bin/nm", - ), - tool_path( - name = "objcopy", - path = "C:/tools/msys64/mingw64/bin/objcopy", - ), - tool_path( - name = "objdump", - path = "C:/tools/msys64/mingw64/bin/objdump", - ), - tool_path( - name = "strip", - path = "C:/tools/msys64/mingw64/bin/strip", - ), - ] - elif (ctx.attr.cpu == "armeabi-v7a"): - tool_paths = [ - tool_path(name = "ar", path = "/bin/false"), - tool_path(name = "cpp", path = "/bin/false"), - tool_path(name = "dwp", path = "/bin/false"), - tool_path(name = "gcc", path = "/bin/false"), - tool_path(name = "gcov", path = "/bin/false"), - tool_path(name = "ld", path = "/bin/false"), - tool_path(name = "nm", path = "/bin/false"), - tool_path(name = "objcopy", path = "/bin/false"), - tool_path(name = "objdump", path = "/bin/false"), - tool_path(name = "strip", path = "/bin/false"), - ] - elif (ctx.attr.cpu == "freebsd"): - tool_paths = [ - tool_path(name = "ar", path = "/usr/bin/ar"), - tool_path(name = "cpp", path = "/usr/bin/cpp"), - tool_path(name = "dwp", path = "/usr/bin/dwp"), - tool_path(name = "gcc", path = "/usr/bin/clang"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "ld", path = "/usr/bin/ld"), - tool_path(name = "nm", path = "/usr/bin/nm"), - tool_path(name = "objcopy", path = "/usr/bin/objcopy"), - tool_path(name = "objdump", path = "/usr/bin/objdump"), - tool_path(name = "strip", path = "/usr/bin/strip"), - ] - elif (ctx.attr.cpu == "openbsd"): - tool_paths = [ - tool_path(name = "ar", path = "/usr/bin/ar"), - tool_path(name = "cpp", path = "/usr/bin/cpp"), - tool_path(name = "dwp", path = "/usr/bin/false"), - tool_path(name = "gcc", path = "/usr/bin/clang"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "ld", path = "/usr/bin/ld"), - tool_path(name = "nm", path = "/usr/bin/nm"), - tool_path(name = "objcopy", path = "/usr/bin/objcopy"), - tool_path(name = "objdump", path = "/usr/bin/objdump"), - tool_path(name = "strip", path = "/usr/bin/strip"), - ] - elif (ctx.attr.cpu == "local"): - tool_paths = [ - tool_path(name = "ar", path = "/usr/bin/ar"), - tool_path(name = "cpp", path = "/usr/bin/cpp"), - tool_path(name = "dwp", path = "/usr/bin/dwp"), - tool_path(name = "gcc", path = "/usr/bin/gcc"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "ld", path = "/usr/bin/ld"), - tool_path(name = "nm", path = "/usr/bin/nm"), - tool_path(name = "objcopy", path = "/usr/bin/objcopy"), - tool_path(name = "objdump", path = "/usr/bin/objdump"), - tool_path(name = "strip", path = "/usr/bin/strip"), - ] - elif (ctx.attr.cpu == "darwin"): - tool_paths = [ - tool_path(name = "ar", path = "/usr/bin/libtool"), - tool_path(name = "cpp", path = "/usr/bin/cpp"), - tool_path(name = "dwp", path = "/usr/bin/dwp"), - tool_path(name = "gcc", path = "osx_cc_wrapper.sh"), - tool_path(name = "gcov", path = "/usr/bin/gcov"), - tool_path(name = "ld", path = "/usr/bin/ld"), - tool_path(name = "nm", path = "/usr/bin/nm"), - tool_path(name = "objcopy", path = "/usr/bin/objcopy"), - tool_path(name = "objdump", path = "/usr/bin/objdump"), - tool_path(name = "strip", path = "/usr/bin/strip"), - ] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): - tool_paths = [ - tool_path(name = "ar", path = "C:/mingw/bin/ar"), - tool_path( - name = "cpp", - path = "C:/Program Files (x86)/LLVM/bin/cpp", - ), - tool_path( - name = "dwp", - path = "C:/Program Files (x86)/LLVM/bin/dwp", - ), - tool_path( - name = "gcc", - path = "C:/Program Files (x86)/LLVM/bin/clang", - ), - tool_path( - name = "gcov", - path = "C:/Program Files (x86)/LLVM/bin/gcov", - ), - tool_path( - name = "ld", - path = "C:/Program Files (x86)/LLVM/bin/ld", - ), - tool_path( - name = "nm", - path = "C:/Program Files (x86)/LLVM/bin/nm", - ), - tool_path( - name = "objcopy", - path = "C:/Program Files (x86)/LLVM/bin/objcopy", - ), - tool_path( - name = "objdump", - path = "C:/Program Files (x86)/LLVM/bin/objdump", - ), - tool_path( - name = "strip", - path = "C:/Program Files (x86)/LLVM/bin/strip", - ), - ] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): - tool_paths = [ - tool_path(name = "ar", path = "C:/mingw/bin/ar"), - tool_path(name = "cpp", path = "C:/mingw/bin/cpp"), - tool_path(name = "dwp", path = "C:/mingw/bin/dwp"), - tool_path(name = "gcc", path = "C:/mingw/bin/gcc"), - tool_path(name = "gcov", path = "C:/mingw/bin/gcov"), - tool_path(name = "ld", path = "C:/mingw/bin/ld"), - tool_path(name = "nm", path = "C:/mingw/bin/nm"), - tool_path(name = "objcopy", path = "C:/mingw/bin/objcopy"), - tool_path(name = "objdump", path = "C:/mingw/bin/objdump"), - tool_path(name = "strip", path = "C:/mingw/bin/strip"), - ] - elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): - tool_paths = [ - tool_path(name = "ar", path = "C:/tools/msys64/usr/bin/ar"), - tool_path( - name = "cpp", - path = "C:/tools/msys64/usr/bin/cpp", - ), - tool_path( - name = "dwp", - path = "C:/tools/msys64/usr/bin/dwp", - ), - tool_path( - name = "gcc", - path = "C:/tools/msys64/usr/bin/gcc", - ), - tool_path( - name = "gcov", - path = "C:/tools/msys64/usr/bin/gcov", - ), - tool_path(name = "ld", path = "C:/tools/msys64/usr/bin/ld"), - tool_path(name = "nm", path = "C:/tools/msys64/usr/bin/nm"), - tool_path( - name = "objcopy", - path = "C:/tools/msys64/usr/bin/objcopy", - ), - tool_path( - name = "objdump", - path = "C:/tools/msys64/usr/bin/objdump", - ), - tool_path( - name = "strip", - path = "C:/tools/msys64/usr/bin/strip", - ), - ] - elif (ctx.attr.cpu == "x64_windows_msvc"): - tool_paths = [ - tool_path(name = "ar", path = "wrapper/bin/msvc_link.bat"), - tool_path(name = "cpp", path = "wrapper/bin/msvc_cl.bat"), - tool_path(name = "gcc", path = "wrapper/bin/msvc_cl.bat"), - tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), - tool_path(name = "ld", path = "wrapper/bin/msvc_link.bat"), - tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), - tool_path( - name = "objcopy", - path = "wrapper/bin/msvc_nop.bat", - ), - tool_path( - name = "objdump", - path = "wrapper/bin/msvc_nop.bat", - ), - tool_path( - name = "strip", - path = "wrapper/bin/msvc_nop.bat", - ), - ] - else: - fail("Unreachable") - - out = ctx.actions.declare_file(ctx.label.name) - ctx.actions.write(out, "Fake executable") - return [ - cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, - action_configs = action_configs, - artifact_name_patterns = artifact_name_patterns, - cxx_builtin_include_directories = cxx_builtin_include_directories, - toolchain_identifier = toolchain_identifier, - host_system_name = host_system_name, - target_system_name = target_system_name, - target_cpu = target_cpu, - target_libc = target_libc, - compiler = compiler, - abi_version = abi_version, - abi_libc_version = abi_libc_version, - tool_paths = tool_paths, - make_variables = make_variables, - builtin_sysroot = builtin_sysroot, - cc_target_os = cc_target_os, - ), - DefaultInfo( - executable = out, - ), - ] - -cc_toolchain_config = rule( - implementation = _impl, - attrs = { - "cpu": attr.string(mandatory = True), - "compiler": attr.string(), - "disable_static_cc_toolchains": attr.bool(), - }, - provides = [CcToolchainConfigInfo], - executable = True, -)