|
| 1 | +# Copyright 2016 The Bazel Authors. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# This becomes the BUILD file for @local_config_cc// under non-BSD unixes. |
| 16 | + |
| 17 | +load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES") |
| 18 | +load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain") |
| 19 | +load(":cc_toolchain_config.bzl", "cc_toolchain_config") |
| 20 | + |
| 21 | +package(default_visibility = ["//visibility:public"]) |
| 22 | + |
| 23 | +licenses(["notice"]) # Apache 2.0 |
| 24 | + |
| 25 | +filegroup( |
| 26 | + name = "empty", |
| 27 | + srcs = [], |
| 28 | +) |
| 29 | + |
| 30 | +filegroup( |
| 31 | + name = "cc_wrapper", |
| 32 | + srcs = ["cc_wrapper.sh"], |
| 33 | +) |
| 34 | + |
| 35 | +filegroup( |
| 36 | + name = "validate_static_library", |
| 37 | + srcs = ["validate_static_library.sh"], |
| 38 | +) |
| 39 | + |
| 40 | +filegroup( |
| 41 | + name = "deps_scanner_wrapper", |
| 42 | + srcs = ["deps_scanner_wrapper.sh"], |
| 43 | +) |
| 44 | + |
| 45 | +filegroup( |
| 46 | + name = "compiler_deps", |
| 47 | + srcs = glob( |
| 48 | + ["extra_tools/**"], |
| 49 | + allow_empty = True, |
| 50 | + ) + [ |
| 51 | + ":builtin_include_directory_paths", |
| 52 | + ":cc_wrapper", |
| 53 | + ":deps_scanner_wrapper", |
| 54 | + ":validate_static_library", |
| 55 | + ], |
| 56 | +) |
| 57 | + |
| 58 | +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") |
| 59 | +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") |
| 60 | + |
| 61 | +cc_feature( |
| 62 | + name = "foo", |
| 63 | + args = [":flags"], |
| 64 | + feature_name = "foo", |
| 65 | + visibility = ["//visibility:public"], |
| 66 | +) |
| 67 | + |
| 68 | +cc_args( |
| 69 | + name = "flags", |
| 70 | + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], |
| 71 | + args = ["-foo"], |
| 72 | +) |
| 73 | + |
| 74 | +toolchain( |
| 75 | + name = "my_linux_toolchain", |
| 76 | + exec_compatible_with = [ |
| 77 | + "@platforms//os:linux", |
| 78 | + "@platforms//cpu:x86_64", |
| 79 | + ], |
| 80 | + target_compatible_with = [ |
| 81 | + "@platforms//os:linux", |
| 82 | + "@platforms//cpu:x86_64", |
| 83 | + ], |
| 84 | + toolchain = ":cc-compiler-k8", |
| 85 | + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", |
| 86 | +) |
| 87 | + |
| 88 | +cc_toolchain( |
| 89 | + name = "cc-compiler-k8", |
| 90 | + all_files = ":compiler_deps", |
| 91 | + ar_files = ":compiler_deps", |
| 92 | + as_files = ":compiler_deps", |
| 93 | + compiler_files = ":compiler_deps", |
| 94 | + dwp_files = ":empty", |
| 95 | + linker_files = ":compiler_deps", |
| 96 | + module_map = None, |
| 97 | + objcopy_files = ":empty", |
| 98 | + strip_files = ":empty", |
| 99 | + supports_header_parsing = 1, |
| 100 | + supports_param_files = 1, |
| 101 | + toolchain_config = ":local", |
| 102 | + toolchain_identifier = "local", |
| 103 | +) |
| 104 | + |
| 105 | +cc_toolchain_config( |
| 106 | + name = "local", |
| 107 | + abi_libc_version = "local", |
| 108 | + abi_version = "local", |
| 109 | + compile_flags = [ |
| 110 | + "-fstack-protector", |
| 111 | + "-Wall", |
| 112 | + "-Wunused-but-set-parameter", |
| 113 | + "-Wno-free-nonheap-object", |
| 114 | + "-fno-omit-frame-pointer", |
| 115 | + ], |
| 116 | + compiler = "gcc", |
| 117 | + conly_flags = [], |
| 118 | + coverage_compile_flags = ["--coverage"], |
| 119 | + coverage_link_flags = ["--coverage"], |
| 120 | + cpu = "k8", |
| 121 | + cxx_builtin_include_directories = [ |
| 122 | + "/usr/lib/gcc/x86_64-linux-gnu/10/include", |
| 123 | + "/usr/local/include", |
| 124 | + "/usr/include/x86_64-linux-gnu", |
| 125 | + "/usr/include", |
| 126 | + "/usr/include/c++/10", |
| 127 | + "/usr/include/x86_64-linux-gnu/c++/10", |
| 128 | + "/usr/include/c++/10/backward", |
| 129 | + ], |
| 130 | + cxx_flags = ["-std=c++17"], |
| 131 | + dbg_compile_flags = ["-g"], |
| 132 | + extra_features = [":foo"], |
| 133 | + host_system_name = "local", |
| 134 | + link_flags = [ |
| 135 | + "-fuse-ld=gold", |
| 136 | + "-B/usr/bin", |
| 137 | + "-Wl,-no-as-needed", |
| 138 | + "-Wl,-z,relro,-z,now", |
| 139 | + "-pass-exit-codes", |
| 140 | + ], |
| 141 | + link_libs = [ |
| 142 | + "-Wl,--push-state,-as-needed", |
| 143 | + "-lstdc++", |
| 144 | + "-Wl,--pop-state", |
| 145 | + "-Wl,--push-state,-as-needed", |
| 146 | + "-lm", |
| 147 | + "-Wl,--pop-state", |
| 148 | + ], |
| 149 | + opt_compile_flags = [ |
| 150 | + "-g0", |
| 151 | + "-O2", |
| 152 | + "-D_FORTIFY_SOURCE=1", |
| 153 | + "-DNDEBUG", |
| 154 | + "-ffunction-sections", |
| 155 | + "-fdata-sections", |
| 156 | + ], |
| 157 | + opt_link_flags = ["-Wl,--gc-sections"], |
| 158 | + supports_start_end_lib = True, |
| 159 | + target_libc = "local", |
| 160 | + target_system_name = "local", |
| 161 | + tool_paths = { |
| 162 | + "ar": "/usr/bin/ar", |
| 163 | + "ld": "/usr/bin/ld", |
| 164 | + "cpp": "/usr/bin/cpp-10", |
| 165 | + "gcc": "/usr/bin/gcc-10", |
| 166 | + "dwp": "/usr/bin/dwp", |
| 167 | + "gcov": "/usr/bin/gcov-10", |
| 168 | + "nm": "/usr/bin/nm", |
| 169 | + "objcopy": "/usr/bin/objcopy", |
| 170 | + "objdump": "/usr/bin/objdump", |
| 171 | + "strip": "/usr/bin/strip", |
| 172 | + "c++filt": "/usr/bin/c++filt", |
| 173 | + "cpp-module-deps-scanner": "deps_scanner_wrapper.sh", |
| 174 | + "parse_headers": "cc_wrapper.sh", |
| 175 | + "validate_static_library": "validate_static_library.sh", |
| 176 | + }, |
| 177 | + toolchain_identifier = "local", |
| 178 | + unfiltered_compile_flags = [ |
| 179 | + "-fno-canonical-system-headers", |
| 180 | + "-Wno-builtin-macro-redefined", |
| 181 | + "-D__DATE__=\"redacted\"", |
| 182 | + "-D__TIMESTAMP__=\"redacted\"", |
| 183 | + "-D__TIME__=\"redacted\"", |
| 184 | + ], |
| 185 | +) |
0 commit comments