Switch to a preconfigured Clang for k8 and armv7
This one reuses more of Bazel's builtin features to remain up to date
more easily, and it's easier to expand support for more platforms. This
also takes care of upgrading to a newer Clang.
This will require updating to raspios bullseye on the Raspberry Pis.
This also renames armhf-debian to armv7 to match the broader Bazel
ecosystem's name for this architecture.
Change-Id: I3e2a4f4efea43e76314ca34a9293c7b4b45edd2c
Signed-off-by: Brian Silverman <bsilver16834@gmail.com>
diff --git a/third_party/bazel-toolchain/toolchain/cc_toolchain_config.bzl b/third_party/bazel-toolchain/toolchain/cc_toolchain_config.bzl
index 1f0395b..ccadb7c 100644
--- a/third_party/bazel-toolchain/toolchain/cc_toolchain_config.bzl
+++ b/third_party/bazel-toolchain/toolchain/cc_toolchain_config.bzl
@@ -13,7 +13,7 @@
# limitations under the License.
load(
- "@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl",
+ "//bazel_tools_changes/tools/cpp:unix_cc_toolchain_config.bzl",
unix_cc_toolchain_config = "cc_toolchain_config",
)
load(
@@ -33,11 +33,20 @@
target_arch,
target_os,
toolchain_path_prefix,
+ target_toolchain_path_prefix,
tools_path_prefix,
wrapper_bin_prefix,
sysroot_path,
additional_include_dirs,
llvm_version,
+ standard_library,
+ static_libstdcxx,
+ conlyopts,
+ cxxopts,
+ copts,
+ opt_copts,
+ dbg_copts,
+ linkopts,
host_tools_info = {}):
host_os_arch_key = _os_arch_pair(host_os, host_arch)
target_os_arch_key = _os_arch_pair(target_os, target_arch)
@@ -55,6 +64,7 @@
compiler,
abi_version,
abi_libc_version,
+ multiarch,
) = {
"darwin-x86_64": (
"clang-x86_64-darwin",
@@ -64,6 +74,7 @@
"clang",
"darwin_x86_64",
"darwin_x86_64",
+ None,
),
"linux-x86_64": (
"clang-x86_64-linux",
@@ -73,6 +84,7 @@
"clang",
"clang",
"glibc_unknown",
+ "x86_64-linux-gnu",
),
"linux-aarch64": (
"clang-aarch64-linux",
@@ -82,6 +94,17 @@
"clang",
"clang",
"glibc_unknown",
+ "aarch64-linux-gnu",
+ ),
+ "linux-armv7": (
+ "clang-armv7-linux",
+ "armv7a-unknown-linux-gnueabihf",
+ "armv7",
+ "glibc_unknown",
+ "clang",
+ "clang",
+ "glibc_unknown",
+ "arm-linux-gnueabihf",
),
}[target_os_arch_key]
@@ -96,14 +119,25 @@
"-D__TIME__=\"redacted\"",
"-fdebug-prefix-map={}=__bazel_toolchain_llvm_repo__/".format(toolchain_path_prefix),
]
+ if target_toolchain_path_prefix != toolchain_path_prefix:
+ unfiltered_compile_flags.extend([
+ "-fdebug-prefix-map={}=__bazel_target_toolchain_llvm_repo__/".format(target_toolchain_path_prefix),
+ ])
is_xcompile = not (host_os == target_os and host_arch == target_arch)
+ resource_dir = [
+ "-resource-dir",
+ "{}lib/clang/{}".format(target_toolchain_path_prefix, llvm_version),
+ ]
+
# Default compiler flags:
compile_flags = [
"--target=" + target_system_name,
# Security
"-U_FORTIFY_SOURCE", # https://github.com/google/sanitizers/issues/247
+ "-D_FORTIFY_SOURCE=2",
+ "-ggdb3",
"-fstack-protector",
"-fno-omit-frame-pointer",
# Diagnostics
@@ -111,14 +145,13 @@
"-Wall",
"-Wthread-safety",
"-Wself-assign",
- ]
+ "-B{}bin/".format(toolchain_path_prefix),
+ ] + resource_dir
- dbg_compile_flags = ["-g", "-fstandalone-debug"]
+ dbg_compile_flags = ["-fstandalone-debug"]
opt_compile_flags = [
- "-g0",
"-O2",
- "-D_FORTIFY_SOURCE=1",
"-DNDEBUG",
"-ffunction-sections",
"-fdata-sections",
@@ -128,7 +161,7 @@
"--target=" + target_system_name,
"-lm",
"-no-canonical-prefixes",
- ]
+ ] + resource_dir
link_libs = []
# Linker flags:
@@ -153,47 +186,130 @@
])
# Flags related to C++ standard.
+ cxx_flags = [
+ "-std=c++17",
+ ]
+ compile_not_cxx_flags = []
+
+ # We only support getting libc++ from the toolchain for now. Is it worth
+ # supporting libc++ from the sysroot? Or maybe just part of a LLVM distribution
+ # that's built for the target?
+ if not standard_library and is_xcompile:
+ print("WARNING: Using libc++ for host architecture while cross compiling, this is " +
+ "probably not what you want. Explicitly set standard_libraries to libc++ to silence.")
+
# The linker has no way of knowing if there are C++ objects; so we
# always link C++ libraries.
- if not is_xcompile:
- cxx_flags = [
- "-std=c++17",
+ if not standard_library or standard_library == "libc++":
+ cxx_flags.extend([
"-stdlib=libc++",
- ]
+ ])
if use_lld:
# For single-platform builds, we can statically link the bundled
# libraries.
link_flags.extend([
- "-L{}lib".format(toolchain_path_prefix),
- "-l:libc++.a",
- "-l:libc++abi.a",
+ "-L{}lib".format(target_toolchain_path_prefix),
+ ])
+ if static_libstdcxx:
+ link_flags.extend([
+ "-l:libc++.a",
+ "-l:libc++abi.a",
+ ])
+ else:
+ link_flags.extend([
+ "-l:libc++.so",
+ "-l:libc++abi.so",
+ ])
+ link_flags.extend([
"-l:libunwind.a",
# Compiler runtime features.
"-rtlib=compiler-rt",
])
- link_libs.extend([
- # To support libunwind.
- "-lpthread",
- "-ldl",
- ])
else:
- # TODO: Not sure how to achieve static linking of bundled libraries
- # with ld64; maybe we don't really need it.
+ if not static_libstdcxx:
+ # TODO: Not sure how to achieve static linking of bundled libraries
+ # with ld64; maybe we don't really need it.
+ print("WARNING: static libc++ with non-lld linker not supported, ignoring")
link_flags.extend([
"-lc++",
"-lc++abi",
])
- else:
- cxx_flags = [
- "-std=c++17",
- "-stdlib=libstdc++",
- ]
+ elif standard_library.startswith("libstdc++"):
+ if not use_lld:
+ fail("libstdc++ only supported with lld")
- # For xcompile, we expect to pick up these libraries from the sysroot.
+ # We use libgcc when using libstdc++ from a sysroot. Most libstdc++
+ # builds link to libgcc, which means we need to use libgcc's exception
+ # handling implementation, not the separate one in compiler-rt.
+ # Unfortunately, clang sometimes emits code incompatible with libgcc,
+ # see <https://bugs.llvm.org/show_bug.cgi?id=27455> and
+ # <https://lists.llvm.org/pipermail/cfe-dev/2016-April/048466.html> for
+ # example. This seems to be a commonly-used configuration with clang
+ # though, so it's probably good enough for most people.
+
link_flags.extend([
- "-l:libstdc++.a",
+ "-L{}lib".format(target_toolchain_path_prefix),
])
+ # We expect to pick up these libraries from the sysroot.
+ if static_libstdcxx:
+ link_flags.extend([
+ "-l:libstdc++.a",
+ ])
+ else:
+ link_flags.extend([
+ "-l:libstdc++.so",
+ ])
+
+ if standard_library == "libstdc++":
+ cxx_flags.extend([
+ "-stdlib=libstdc++",
+ ])
+ elif standard_library.startswith("libstdc++-"):
+ # -stdlib does nothing when using -nostdinc besides produce a warning
+ # that it's unused, so don't use it here.
+
+ libstdcxx_version = standard_library[len("libstdc++-"):]
+
+ common_include_flags = [
+ "-nostdinc",
+ "-isystem",
+ target_toolchain_path_prefix + "lib/clang/{}/include".format(llvm_version),
+ "-isystem",
+ sysroot_path + "/usr/local/include",
+ "-isystem",
+ sysroot_path + "/usr/" + multiarch + "/include",
+ "-isystem",
+ sysroot_path + "/usr/include/" + multiarch,
+ "-isystem",
+ sysroot_path + "/usr/include",
+ "-isystem",
+ sysroot_path + "/include",
+ "-isystem",
+ sysroot_path + "/usr/include",
+ ]
+ compile_not_cxx_flags.extend(common_include_flags)
+ cxx_flags.extend([
+ "-nostdinc++",
+ "-isystem",
+ sysroot_path + "/usr/include/c++/" + libstdcxx_version,
+ "-isystem",
+ sysroot_path + "/usr/include/" + multiarch + "/c++/" + libstdcxx_version,
+ "-isystem",
+ sysroot_path + "/usr/include/c++/" + libstdcxx_version + "/backward",
+ ] + common_include_flags)
+ else:
+ fail("Invalid standard_libary: " + standard_library)
+ else:
+ fail("Invalid standard_libary: " + standard_library)
+
+ link_libs.extend([
+ # To support libunwind. We do this even if not using libunwind explicitly
+ # to keep the resulting toolchains more similar.
+ "-lpthread",
+ "-ldl",
+ ])
+
opt_link_flags = ["-Wl,--gc-sections"] if target_os == "linux" else []
# Coverage flags:
@@ -205,9 +321,9 @@
# C++ built-in include directories:
cxx_builtin_include_directories = [
- toolchain_path_prefix + "include/c++/v1",
- toolchain_path_prefix + "lib/clang/{}/include".format(llvm_version),
- toolchain_path_prefix + "lib64/clang/{}/include".format(llvm_version),
+ target_toolchain_path_prefix + "include/c++/v1",
+ target_toolchain_path_prefix + "lib/clang/{}/include".format(llvm_version),
+ target_toolchain_path_prefix + "lib64/clang/{}/include".format(llvm_version),
]
sysroot_prefix = ""
@@ -275,6 +391,13 @@
# `lld` is being used as the linker.
supports_start_end_lib = use_lld
+ # Add extra flags at the end so they can override anything from this file if desired.
+ cxx_flags.extend(cxxopts)
+ compile_flags.extend(copts)
+ dbg_compile_flags.extend(dbg_copts)
+ opt_compile_flags.extend(opt_copts)
+ link_flags.extend(linkopts)
+
# Source: https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/unix_cc_toolchain_config.bzl
unix_cc_toolchain_config(
name = name,
@@ -292,6 +415,8 @@
dbg_compile_flags = dbg_compile_flags,
opt_compile_flags = opt_compile_flags,
cxx_flags = cxx_flags,
+ c_flags = conlyopts,
+ compile_not_cxx_flags = compile_not_cxx_flags,
link_flags = link_flags,
link_libs = link_libs,
opt_link_flags = opt_link_flags,
diff --git a/third_party/bazel-toolchain/toolchain/internal/common.bzl b/third_party/bazel-toolchain/toolchain/internal/common.bzl
index a0e73c9..96e0f68 100644
--- a/third_party/bazel-toolchain/toolchain/internal/common.bzl
+++ b/third_party/bazel-toolchain/toolchain/internal/common.bzl
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("darwin", "x86_64")]
+SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("linux", "armv7"), ("darwin", "x86_64")]
host_tool_features = struct(
SUPPORTS_ARG_FILE = "supports_arg_file",
diff --git a/third_party/bazel-toolchain/toolchain/internal/configure.bzl b/third_party/bazel-toolchain/toolchain/internal/configure.bzl
index 3aba341..6a183fc 100644
--- a/third_party/bazel-toolchain/toolchain/internal/configure.bzl
+++ b/third_party/bazel-toolchain/toolchain/internal/configure.bzl
@@ -37,10 +37,15 @@
return ""
return ("\n" + 12 * " ").join(["\"%s\"," % d for d in dirs])
+def _is_absolute(path):
+ return path[0] == "/" and (len(path) == 1 or path[1] != "/")
+
def llvm_config_impl(rctx):
_check_os_arch_keys(rctx.attr.toolchain_roots)
+ _check_os_arch_keys(rctx.attr.target_toolchain_roots)
_check_os_arch_keys(rctx.attr.sysroot)
_check_os_arch_keys(rctx.attr.cxx_builtin_include_directories)
+ _check_os_arch_keys(rctx.attr.standard_libraries)
os = _os(rctx)
if os == "windows":
@@ -61,18 +66,27 @@
# Check if the toolchain root is an absolute path.
use_absolute_paths = rctx.attr.absolute_paths
- if toolchain_root[0] == "/" and (len(toolchain_root) == 1 or toolchain_root[1] != "/"):
+ for target_toolchain_root in rctx.attr.target_toolchain_roots.values():
+ if _is_absolute(toolchain_root) != _is_absolute(target_toolchain_root):
+ fail("Host and target toolchain roots must both be absolute or not")
+ if _is_absolute(toolchain_root):
use_absolute_paths = True
+ target_llvm_repo_paths = {}
if use_absolute_paths:
llvm_repo_label = Label(toolchain_root + ":BUILD.bazel") # Exact target does not matter.
llvm_repo_path = _canonical_dir_path(str(rctx.path(llvm_repo_label).dirname))
+ for a_key in rctx.attr.target_toolchain_roots:
+ target_llvm_repo_label = Label(rctx.attr.target_toolchain_roots[a_key] + ":BUILD.bazel")
+ target_llvm_repo_paths[a_key] = _canonical_dir_path(str(rctx.path(target_llvm_repo_label).dirname))
config_repo_path = _canonical_dir_path(str(rctx.path("")))
toolchain_path_prefix = llvm_repo_path
tools_path_prefix = llvm_repo_path
wrapper_bin_prefix = config_repo_path
else:
llvm_repo_path = _pkg_path_from_label(Label(toolchain_root + ":BUILD.bazel"))
+ for a_key in rctx.attr.target_toolchain_roots:
+ target_llvm_repo_paths[a_key] = _pkg_path_from_label(Label(rctx.attr.target_toolchain_roots[a_key] + ":BUILD.bazel"))
config_repo_path = "external/%s/" % rctx.name
# tools can only be defined in a subdirectory of config_repo_path,
@@ -100,13 +114,24 @@
os = os,
arch = arch,
toolchain_root = toolchain_root,
+ additional_target_compatible_with_dict = rctx.attr.additional_target_compatible_with,
+ target_toolchain_roots_dict = rctx.attr.target_toolchain_roots,
toolchain_path_prefix = toolchain_path_prefix,
+ target_toolchain_path_prefixes_dict = target_llvm_repo_paths,
tools_path_prefix = tools_path_prefix,
wrapper_bin_prefix = wrapper_bin_prefix,
additional_include_dirs_dict = rctx.attr.cxx_builtin_include_directories,
sysroot_dict = rctx.attr.sysroot,
default_sysroot_path = default_sysroot_path,
llvm_version = rctx.attr.llvm_version,
+ standard_libraries_dict = rctx.attr.standard_libraries,
+ static_libstdcxx = rctx.attr.static_libstdcxx,
+ conlyopts_dict = rctx.attr.conlyopts,
+ cxxopts_dict = rctx.attr.cxxopts,
+ copts_dict = rctx.attr.copts,
+ opt_copts_dict = rctx.attr.opt_copts,
+ dbg_copts_dict = rctx.attr.dbg_copts,
+ linkopts_dict = rctx.attr.linkopts,
)
host_tools_info = dict([
pair
@@ -237,7 +262,8 @@
extra_files_str = ", \":llvm\", \":wrapper-files\""
- additional_include_dirs = toolchain_info.additional_include_dirs_dict.get(_os_arch_pair(target_os, target_arch))
+ key = _os_arch_pair(target_os, target_arch)
+ additional_include_dirs = toolchain_info.additional_include_dirs_dict.get(key)
additional_include_dirs_str = "[]"
if additional_include_dirs:
additional_include_dirs_str = "[{}]".format(
@@ -250,6 +276,25 @@
# them into `dict`s.
host_tools_info = json.decode(json.encode(host_tools_info))
+ standard_library = toolchain_info.standard_libraries_dict.get(key, "")
+ conlyopts = toolchain_info.conlyopts_dict.get(key, [])
+ cxxopts = toolchain_info.cxxopts_dict.get(key, [])
+ copts = toolchain_info.copts_dict.get(key, [])
+ opt_copts = toolchain_info.opt_copts_dict.get(key, [])
+ dbg_copts = toolchain_info.dbg_copts_dict.get(key, [])
+ linkopts = toolchain_info.linkopts_dict.get(key, [])
+ target_toolchain_root = toolchain_info.toolchain_root
+ if key in toolchain_info.target_toolchain_roots_dict:
+ target_toolchain_root = toolchain_info.target_toolchain_roots_dict[key]
+ elif "" in toolchain_info.target_toolchain_roots_dict:
+ target_toolchain_root = toolchain_info.target_toolchain_roots_dict[""]
+ target_toolchain_path_prefix = toolchain_info.toolchain_path_prefix
+ if key in toolchain_info.target_toolchain_path_prefixes_dict:
+ target_toolchain_path_prefix = toolchain_info.target_toolchain_path_prefixes_dict[key]
+ elif "" in toolchain_info.target_toolchain_roots_dict:
+ target_toolchain_path_prefix = toolchain_info.target_toolchain_path_prefixes_dict[""]
+ additional_target_compatible_with = toolchain_info.additional_target_compatible_with_dict.get(key, [])
+
template = """
# CC toolchain for cc-clang-{suffix}.
@@ -260,12 +305,21 @@
target_arch = "{target_arch}",
target_os = "{target_os}",
toolchain_path_prefix = "{toolchain_path_prefix}",
+ target_toolchain_path_prefix = "{target_toolchain_path_prefix}",
tools_path_prefix = "{tools_path_prefix}",
wrapper_bin_prefix = "{wrapper_bin_prefix}",
sysroot_path = "{sysroot_path}",
additional_include_dirs = {additional_include_dirs_str},
llvm_version = "{llvm_version}",
host_tools_info = {host_tools_info},
+ standard_library = "{standard_library}",
+ static_libstdcxx = {static_libstdcxx},
+ conlyopts = {conlyopts},
+ cxxopts = {cxxopts},
+ copts = {copts},
+ opt_copts = {opt_copts},
+ dbg_copts = {dbg_copts},
+ linkopts = {linkopts},
)
toolchain(
@@ -277,7 +331,7 @@
target_compatible_with = [
"@platforms//cpu:{target_arch}",
"@platforms//os:{target_os_bzl}",
- ],
+ ] + {additional_target_compatible_with},
toolchain = ":cc-clang-{suffix}",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
@@ -307,7 +361,7 @@
name = "compiler-components-{suffix}",
srcs = [
"{toolchain_root}:clang",
- "{toolchain_root}:include",
+ "{target_toolchain_root}:include",
":sysroot-components-{suffix}",
],
)
@@ -318,7 +372,7 @@
"{toolchain_root}:clang",
"{toolchain_root}:ld",
"{toolchain_root}:ar",
- "{toolchain_root}:lib",
+ "{target_toolchain_root}:lib",
":sysroot-components-{suffix}",
],
)
@@ -363,8 +417,11 @@
host_arch = host_arch,
target_os_bzl = target_os_bzl,
host_os_bzl = host_os_bzl,
+ additional_target_compatible_with = additional_target_compatible_with,
toolchain_root = toolchain_info.toolchain_root,
toolchain_path_prefix = toolchain_info.toolchain_path_prefix,
+ target_toolchain_root = target_toolchain_root,
+ target_toolchain_path_prefix = target_toolchain_path_prefix,
tools_path_prefix = toolchain_info.tools_path_prefix,
wrapper_bin_prefix = toolchain_info.wrapper_bin_prefix,
additional_include_dirs_str = additional_include_dirs_str,
@@ -373,4 +430,12 @@
llvm_version = toolchain_info.llvm_version,
extra_files_str = extra_files_str,
host_tools_info = host_tools_info,
+ standard_library = standard_library,
+ static_libstdcxx = toolchain_info.static_libstdcxx,
+ conlyopts = conlyopts,
+ cxxopts = cxxopts,
+ copts = copts,
+ opt_copts = opt_copts,
+ dbg_copts = dbg_copts,
+ linkopts = linkopts,
)
diff --git a/third_party/bazel-toolchain/toolchain/internal/llvm_distributions.bzl b/third_party/bazel-toolchain/toolchain/internal/llvm_distributions.bzl
index 8d3441b..4ba4601 100644
--- a/third_party/bazel-toolchain/toolchain/internal/llvm_distributions.bzl
+++ b/third_party/bazel-toolchain/toolchain/internal/llvm_distributions.bzl
@@ -174,6 +174,7 @@
"clang+llvm-13.0.0-amd64-unknown-freebsd13.tar.xz": "c4f15e156afaa530eb47ba13c46800275102af535ed48e395aed4c1decc1eaa1",
"clang+llvm-13.0.0-i386-unknown-freebsd12.tar.xz": "4d14b19c082438a5ceed61e538e5a0298018b1773e8ba2e990f3fbe33492f48f",
"clang+llvm-13.0.0-i386-unknown-freebsd13.tar.xz": "f8e105c6ac2fd517ae5ed8ef9b9bab4b015fe89a06c90c3dd5d5c7933dca2276",
+ "clang+llvm-13.0.0-armv7a-linux-gnueabihf.tar.xz": "e17aacd843cc7c3c3c27a0d2293af8b3e9ad76408f7c178a92a182f18e7734e5",
"clang+llvm-13.0.0-powerpc64le-linux-rhel-7.9.tar.xz": "cfade83f6da572a8ab0e4796d1f657967b342e98202c26e76c857879fb2fa2d2",
"clang+llvm-13.0.0-powerpc64le-linux-ubuntu-18.04.tar.xz": "5d79e9e2919866a91431589355f6d07f35d439458ff12cb8f36093fb314a7028",
"clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz": "d051234eca1db1f5e4bc08c64937c879c7098900f7a0370f3ceb7544816a8b09",
diff --git a/third_party/bazel-toolchain/toolchain/rules.bzl b/third_party/bazel-toolchain/toolchain/rules.bzl
index 92d2d33..f27e387 100644
--- a/third_party/bazel-toolchain/toolchain/rules.bzl
+++ b/third_party/bazel-toolchain/toolchain/rules.bzl
@@ -95,6 +95,19 @@
"paths. Else, the value will be assumed to be a bazel package containing the " +
"filegroup targets as in BUILD.llvm_repo."),
),
+ "target_toolchain_roots": attr.string_dict(
+ mandatory = True,
+ # TODO: Ideally, we should be taking a filegroup label here instead of a package path, but
+ # we ultimately need to subset the files to be more selective in what we include in the
+ # sandbox for which operations, and it is not straightforward to subset a filegroup.
+ doc = ("System or package path, for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) +
+ "to be used as the LLVM toolchain distributions. " +
+ "If the value begins with exactly one forward slash '/', then the value is " +
+ "assumed to be a system path and the toolchain is configured to use absolute " +
+ "paths. Else, the value will be assumed to be a bazel package containing the " +
+ "filegroup targets as in BUILD.llvm_repo."),
+ ),
"sysroot": attr.string_dict(
mandatory = False,
doc = ("System path or fileset, for each target OS and arch pair you want to support " +
@@ -112,6 +125,67 @@
"({}); ".format(", ".join(_supported_os_arch_keys())) +
"see documentation for bazel's create_cc_toolchain_config_info."),
),
+ "standard_libraries": attr.string_dict(
+ mandatory = False,
+ doc = ("The C++ standard library to use, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) +
+ "used to find this version in the sysroot or host system. " +
+ "If set to \"libc++\" \"libstdc++\", that will be passed to clang directly. " +
+ "If set to \"libstdc++-N\", then explicit paths for major version N of " +
+ "libstdc++ will be passed to clang."),
+ ),
+ "additional_target_compatible_with": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Additional target_compatible_with values, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) +
+ "in addition to the @platforms//os and @platforms//cpu entries " +
+ "added automatically."),
+ ),
+ "conlyopts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags for compiling C (not C++) files, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) + "."),
+ ),
+ "cxxopts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags for compiling C++ (not C) files, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) + "."),
+ ),
+ "copts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags for compiling C, C++, and assembly files, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) + "."),
+ ),
+ "opt_copts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags for compiling C, C++, and assembly files, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) +
+ "used only with -c opt."),
+ ),
+ "dbg_copts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags for compiling C, C++, and assembly files, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) +
+ "used only with -c dbg."),
+ ),
+ "linkopts": attr.string_list_dict(
+ mandatory = False,
+ doc = ("Extra flags to pass to the linker, " +
+ "for each target OS and arch pair you want to support " +
+ "({}), ".format(", ".join(_supported_os_arch_keys())) + "."),
+ ),
+ "static_libstdcxx": attr.bool(
+ default = True,
+ doc = "Link the C++ standard library statically. Note that this applies " +
+ "to all C++ standard libraries, like the -static-libstdc++ clang flag.",
+ ),
"absolute_paths": attr.bool(
default = False,
doc = "Use absolute paths in the toolchain. Avoids sandbox overhead.",