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 17load(":cc_toolchain_config.bzl", "cc_toolchain_config") 18load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config") 19load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite") 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) # Apache 2.0 24 25cc_library(name = "empty_lib") 26 27# Label flag for extra libraries to be linked into every binary. 28# TODO(bazel-team): Support passing flag multiple times to build a list. 29label_flag( 30 name = "link_extra_libs", 31 build_setting_default = ":empty_lib", 32) 33 34# The final extra library to be linked into every binary target. This collects 35# the above flag, but may also include more libraries depending on config. 36cc_library( 37 name = "link_extra_lib", 38 deps = [ 39 ":link_extra_libs", 40 ], 41) 42 43cc_library( 44 name = "malloc", 45) 46 47filegroup( 48 name = "empty", 49 srcs = [], 50) 51 52filegroup( 53 name = "cc_wrapper", 54 srcs = ["cc_wrapper.sh"], 55) 56 57filegroup( 58 name = "validate_static_library", 59 srcs = ["validate_static_library.sh"], 60) 61 62filegroup( 63 name = "compiler_deps", 64 srcs = glob(["extra_tools/**"], allow_empty = True) + [":builtin_include_directory_paths", 65 ":cc_wrapper", 66 ":validate_static_library"], 67) 68 69# This is the entry point for --crosstool_top. Toolchains are found 70# by lopping off the name of --crosstool_top and searching for 71# the "${CPU}" entry in the toolchains attribute. 72cc_toolchain_suite( 73 name = "toolchain", 74 toolchains = { 75 "k8|clang": ":cc-compiler-k8", 76 "k8": ":cc-compiler-k8", 77 "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", 78 "armeabi-v7a": ":cc-compiler-armeabi-v7a", 79 }, 80) 81 82cc_toolchain( 83 name = "cc-compiler-k8", 84 toolchain_identifier = "linux_gnu_x86", 85 toolchain_config = ":linux_gnu_x86", 86 all_files = ":compiler_deps", 87 ar_files = ":compiler_deps", 88 as_files = ":compiler_deps", 89 compiler_files = ":compiler_deps", 90 dwp_files = ":empty", 91 linker_files = ":compiler_deps", 92 objcopy_files = ":empty", 93 strip_files = ":empty", 94 supports_header_parsing = 1, 95 supports_param_files = 1, 96 module_map = ":module.modulemap", 97) 98 99cc_toolchain_config( 100 name = "linux_gnu_x86", 101 cpu = "k8", 102 compiler = "clang", 103 toolchain_identifier = "linux_gnu_x86", 104 host_system_name = "i686-unknown-linux-gnu", 105 target_system_name = "x86_64-unknown-linux-gnu", 106 target_libc = "glibc_2.19", 107 abi_version = "clang", 108 abi_libc_version = "glibc_2.19", 109 cxx_builtin_include_directories = ["/usr/local/lib/clang/19/include", 110 "/usr/local/include", 111 "/usr/include/x86_64-linux-gnu", 112 "/usr/include", 113 "/usr/local/lib/clang/19/share", 114 "/usr/include/c++/9", 115 "/usr/include/x86_64-linux-gnu/c++/9", 116 "/usr/include/c++/9/backward", 117 "/usr/local/include/c++/v1", 118 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"], 119 tool_paths = {"ar": "/usr/bin/ar", 120 "ld": "/usr/bin/ld", 121 "llvm-cov": "/usr/local/bin/llvm-cov", 122 "llvm-profdata": "/usr/local/bin/llvm-profdata", 123 "cpp": "/usr/bin/cpp", 124 "gcc": "/usr/local/bin/clang-19", 125 "dwp": "/usr/bin/dwp", 126 "gcov": "/dev/null", 127 "nm": "/usr/bin/nm", 128 "objcopy": "/usr/bin/objcopy", 129 "objdump": "/usr/bin/objdump", 130 "strip": "/usr/bin/strip", 131 "c++filt": "/usr/bin/c++filt", 132 "parse_headers": "cc_wrapper.sh", 133 "validate_static_library": "validate_static_library.sh"}, 134 compile_flags = ["-fstack-protector", 135 "-Wall", 136 "-Wthread-safety", 137 "-Wself-assign", 138 "-Wunused-but-set-parameter", 139 "-Wno-free-nonheap-object", 140 "-fcolor-diagnostics", 141 "-fno-omit-frame-pointer"], 142 opt_compile_flags = ["-g0", 143 "-O2", 144 "-D_FORTIFY_SOURCE=1", 145 "-DNDEBUG", 146 "-ffunction-sections", 147 "-fdata-sections"], 148 dbg_compile_flags = ["-g"], 149 conly_flags = [], 150 cxx_flags = ["-std=c++14"], 151 link_flags = ["-fuse-ld=/usr/local/bin/ld.lld", 152 "-B/usr/local/bin", 153 "-Wl,-no-as-needed", 154 "-Wl,-z,relro,-z,now"], 155 link_libs = ["-Wl,--push-state,-as-needed", 156 "-lstdc++", 157 "-Wl,--pop-state", 158 "-Wl,--push-state,-as-needed", 159 "-lm", 160 "-Wl,--pop-state"], 161 opt_link_flags = ["-Wl,--gc-sections"], 162 unfiltered_compile_flags = ["-no-canonical-prefixes", 163 "-Wno-builtin-macro-redefined", 164 "-D__DATE__=\"redacted\"", 165 "-D__TIMESTAMP__=\"redacted\"", 166 "-D__TIME__=\"redacted\""], 167 coverage_compile_flags = ["--coverage"], 168 coverage_link_flags = ["--coverage"], 169 supports_start_end_lib = True, 170 extra_flags_per_feature = {"use_module_maps": ["-Xclang", "-fno-cxx-modules"]}, 171) 172 173# Android tooling requires a default toolchain for the armeabi-v7a cpu. 174cc_toolchain( 175 name = "cc-compiler-armeabi-v7a", 176 toolchain_identifier = "stub_armeabi-v7a", 177 toolchain_config = ":stub_armeabi-v7a", 178 all_files = ":empty", 179 ar_files = ":empty", 180 as_files = ":empty", 181 compiler_files = ":empty", 182 dwp_files = ":empty", 183 linker_files = ":empty", 184 objcopy_files = ":empty", 185 strip_files = ":empty", 186 supports_param_files = 1, 187) 188 189armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") 190