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/bazel_tools_changes/tools/cpp/unix_cc_toolchain_config.bzl b/third_party/bazel-toolchain/bazel_tools_changes/tools/cpp/unix_cc_toolchain_config.bzl
index d44b792..8e49eda 100755
--- a/third_party/bazel-toolchain/bazel_tools_changes/tools/cpp/unix_cc_toolchain_config.bzl
+++ b/third_party/bazel-toolchain/bazel_tools_changes/tools/cpp/unix_cc_toolchain_config.bzl
@@ -169,6 +169,7 @@
enabled = True,
)
+ cxx_flags_actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend]
default_compile_flags_feature = feature(
name = "default_compile_flags",
enabled = True,
@@ -200,13 +201,29 @@
with_features = [with_feature_set(features = ["opt"])],
),
flag_set(
- actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend],
+ actions = [ACTION_NAMES.c_compile],
+ flag_groups = ([
+ flag_group(
+ flags = ctx.attr.c_flags,
+ ),
+ ] if ctx.attr.c_flags else []),
+ ),
+ flag_set(
+ actions = cxx_flags_actions,
flag_groups = ([
flag_group(
flags = ctx.attr.cxx_flags,
),
] if ctx.attr.cxx_flags else []),
),
+ flag_set(
+ actions = [a for a in all_compile_actions if a not in cxx_flags_actions],
+ flag_groups = ([
+ flag_group(
+ flags = ctx.attr.compile_not_cxx_flags,
+ ),
+ ] if ctx.attr.compile_not_cxx_flags else []),
+ ),
],
)
@@ -1260,6 +1277,8 @@
"dbg_compile_flags": attr.string_list(),
"opt_compile_flags": attr.string_list(),
"cxx_flags": attr.string_list(),
+ "c_flags": attr.string_list(),
+ "compile_not_cxx_flags": attr.string_list(),
"link_flags": attr.string_list(),
"link_libs": attr.string_list(),
"opt_link_flags": attr.string_list(),
diff --git a/third_party/bazel-toolchain/platforms/BUILD.bazel b/third_party/bazel-toolchain/platforms/BUILD.bazel
index 16c1983..de77762 100644
--- a/third_party/bazel-toolchain/platforms/BUILD.bazel
+++ b/third_party/bazel-toolchain/platforms/BUILD.bazel
@@ -31,6 +31,14 @@
)
platform(
+ name = "linux-armv7",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:armv7",
+ ],
+)
+
+platform(
name = "darwin-x86_64",
constraint_values = [
"@platforms//os:osx",
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.",
diff --git a/third_party/cddlib/BUILD b/third_party/cddlib/BUILD
index 08684fc..ffcc836 100644
--- a/third_party/cddlib/BUILD
+++ b/third_party/cddlib/BUILD
@@ -1,7 +1,5 @@
licenses(["notice"])
-load("//tools/build_rules:select.bzl", "compiler_select")
-
cc_library(
name = "cddlib",
srcs = [
@@ -27,10 +25,8 @@
"-Wno-sign-compare",
"-Wno-implicit-fallthrough",
"-Wno-unused-result",
- ] + compiler_select({
- "gcc": ["-Wno-unused-but-set-variable"],
- "clang": [],
- }),
+ "-Wno-unused-but-set-variable",
+ ],
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
)
diff --git a/third_party/ceres/BUILD b/third_party/ceres/BUILD
index c4648a6..5fa8ef2 100644
--- a/third_party/ceres/BUILD
+++ b/third_party/ceres/BUILD
@@ -57,6 +57,7 @@
],
copts = [
"-Wno-sign-compare",
+ "-Wno-unused-but-set-variable",
"-DCERES_TEST_SRCDIR_SUFFIX=\\\"data/\\\"",
],
includes = [
diff --git a/third_party/ceres/bazel/ceres.bzl b/third_party/ceres/bazel/ceres.bzl
index fff9c30..e1bc356 100644
--- a/third_party/ceres/bazel/ceres.bzl
+++ b/third_party/ceres/bazel/ceres.bzl
@@ -184,6 +184,7 @@
"-Wno-sign-compare",
"-Wno-format-nonliteral",
"-Wno-unused-parameter",
+ "-Wno-unused-but-set-variable",
] + schur_eliminator_copts,
# These include directories and defines are propagated to other targets
diff --git a/third_party/ceres/internal/ceres/autodiff_test.cc b/third_party/ceres/internal/ceres/autodiff_test.cc
index 2d56400..e42da58 100644
--- a/third_party/ceres/internal/ceres/autodiff_test.cc
+++ b/third_party/ceres/internal/ceres/autodiff_test.cc
@@ -640,6 +640,10 @@
}
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-but-set-variable"
+#endif
// This is fragile test that triggers the alignment bug on
// i686-apple-darwin10-llvm-g++-4.2 (GCC) 4.2.1. It is quite possible,
// that other combinations of operating system + compiler will
@@ -664,6 +668,9 @@
// Need this to makes sure that x does not get optimized out.
x[0] = x[0] + JetT(1.0);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
} // namespace internal
} // namespace ceres
diff --git a/third_party/ceres/internal/ceres/triplet_sparse_matrix_test.cc b/third_party/ceres/internal/ceres/triplet_sparse_matrix_test.cc
index 3af634f..beee36b 100644
--- a/third_party/ceres/internal/ceres/triplet_sparse_matrix_test.cc
+++ b/third_party/ceres/internal/ceres/triplet_sparse_matrix_test.cc
@@ -184,8 +184,15 @@
orig.mutable_values()[1] = 5.2;
orig.set_num_nonzeros(2);
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wself-assign-overloaded"
+#endif
// Who's on earth gonna do this?
orig = orig;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
EXPECT_EQ(orig.num_rows(), 2);
EXPECT_EQ(orig.num_cols(), 5);
diff --git a/third_party/cimg/BUILD b/third_party/cimg/BUILD
index fc73f38..e59ae51 100644
--- a/third_party/cimg/BUILD
+++ b/third_party/cimg/BUILD
@@ -7,7 +7,15 @@
"plugins/*.h",
]),
target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
+ # This library has undefined behavior, so don't use it anywhere else without
+ # evaluating carefully. Note that this is different from most compiler
+ # warnings about undefined behavior: in several places it is statically
+ # always undefined behavior, not just code that looks like it might have
+ # undefined behavior when executed sometimes.
+ #
+ # Also, if the compiler finds several, there are probably more subtle ones
+ # that the compiler doesn't notice.
+ visibility = ["//y2019/image_streamer:__pkg__"],
deps = [
"//third_party/libjpeg",
],
diff --git a/third_party/eigen/BUILD b/third_party/eigen/BUILD
index 02f259d..18c487b 100644
--- a/third_party/eigen/BUILD
+++ b/third_party/eigen/BUILD
@@ -17,6 +17,11 @@
],
) + ["unsupported/Eigen/MatrixFunctions"] + glob([
"unsupported/Eigen/src/MatrixFunctions/*.h",
+ "unsupported/Eigen/CXX11/Tensor",
+ "unsupported/Eigen/SpecialFunctions",
+ "unsupported/Eigen/src/SpecialFunctions/*.h",
+ "unsupported/Eigen/CXX11/src/util/*.h",
+ "unsupported/Eigen/CXX11/src/Tensor/*.h",
]),
includes = ["."],
visibility = ["//visibility:public"],
diff --git a/third_party/google-benchmark/BUILD.bazel b/third_party/google-benchmark/BUILD.bazel
index 479d59e..5069c0b 100644
--- a/third_party/google-benchmark/BUILD.bazel
+++ b/third_party/google-benchmark/BUILD.bazel
@@ -21,6 +21,7 @@
copts = [
"-Wno-format-nonliteral",
"-Wno-deprecated-declarations",
+ "-Wno-unused-but-set-variable",
],
linkopts = select({
":windows": ["-DEFAULTLIB:shlwapi.lib"],
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index a56f38f..7dd86dc 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -111,6 +111,7 @@
}) + compiler_select({
"clang": [
"-Wno-unused-const-variable",
+ "-Wno-unused-but-set-variable",
"-Wno-gnu-alignof-expression",
"-Wno-unused-private-field",
diff --git a/third_party/matplotlib-cpp/BUILD b/third_party/matplotlib-cpp/BUILD
index 56fe228..6221abb 100644
--- a/third_party/matplotlib-cpp/BUILD
+++ b/third_party/matplotlib-cpp/BUILD
@@ -14,7 +14,7 @@
target_compatible_with = ["@platforms//cpu:x86_64"],
visibility = ["//visibility:public"],
deps = [
- "@python_repo//:python3.7_lib",
+ "@python_repo//:python3.9_lib",
],
)
diff --git a/third_party/pico-sdk/tools/elf2uf2/BUILD b/third_party/pico-sdk/tools/elf2uf2/BUILD
index 98b8209..3c8cf78 100644
--- a/third_party/pico-sdk/tools/elf2uf2/BUILD
+++ b/third_party/pico-sdk/tools/elf2uf2/BUILD
@@ -9,6 +9,7 @@
"-Wno-reorder",
"-Wno-unused-parameter",
"-Wno-unused-function",
+ "-Wno-type-limits",
],
includes = ["."],
target_compatible_with = ["@platforms//os:linux"],
diff --git a/third_party/protobuf/protobuf.bzl b/third_party/protobuf/protobuf.bzl
index ae3ea54..35c0e4a 100644
--- a/third_party/protobuf/protobuf.bzl
+++ b/third_party/protobuf/protobuf.bzl
@@ -196,6 +196,7 @@
"clang": [
"-Wno-unused-const-variable",
"-Wno-unused-private-field",
+ "-Wno-tautological-type-limit-compare",
],
})
diff --git a/third_party/rawrtc/usrsctp/BUILD b/third_party/rawrtc/usrsctp/BUILD
index 654d29b..4c9c015 100644
--- a/third_party/rawrtc/usrsctp/BUILD
+++ b/third_party/rawrtc/usrsctp/BUILD
@@ -48,7 +48,9 @@
"-DHAVE_LINUX_IF_ADDR_H",
"-Wno-address-of-packed-member",
] + compiler_select({
- "clang": [],
+ "clang": [
+ "-Wno-unused-but-set-variable",
+ ],
"gcc": [
"-Wno-discarded-qualifiers",
],
diff --git a/third_party/seasocks/src/main/c/Server.cpp b/third_party/seasocks/src/main/c/Server.cpp
index 4908b90..bd0746c 100644
--- a/third_party/seasocks/src/main/c/Server.cpp
+++ b/third_party/seasocks/src/main/c/Server.cpp
@@ -90,7 +90,7 @@
constexpr int EpollTimeoutMillis = 500; // Twice a second is ample.
constexpr int DefaultLameConnectionTimeoutSeconds = 10;
-pid_t gettid() {
+pid_t seasocks_gettid() {
return static_cast<pid_t>(syscall(SYS_gettid));
}
@@ -405,7 +405,7 @@
}
// Stash away "the" server thread id.
- _threadId = gettid();
+ _threadId = seasocks_gettid();
while (!_terminate) {
// Always process events first to catch start up events.
@@ -422,8 +422,8 @@
Server::PollResult Server::poll(int millis) {
// Grab the thread ID on the first poll.
if (_threadId == 0)
- _threadId = gettid();
- if (_threadId != gettid()) {
+ _threadId = seasocks_gettid();
+ if (_threadId != seasocks_gettid()) {
LS_ERROR(_logger, "poll() called from the wrong thread");
return PollResult::Error;
}
@@ -613,7 +613,7 @@
}
void Server::checkThread() const {
- auto thisTid = gettid();
+ auto thisTid = seasocks_gettid();
if (thisTid != _threadId) {
std::ostringstream o;
o << "seasocks called on wrong thread : " << thisTid << " instead of " << _threadId;