Force Clang modules with LLVM >= 14 (#337)
Otherwise Clang defaults to C++ modules with `-std=c++20`, which breaks `layering_check`. Fixes #334
This commit is contained in:
parent
1f6b2f13b6
commit
b193952cdb
|
@ -40,7 +40,8 @@ def cc_toolchain_config(
|
|||
tools_path_prefix,
|
||||
wrapper_bin_prefix,
|
||||
compiler_configuration,
|
||||
cxx_builtin_include_directories):
|
||||
cxx_builtin_include_directories,
|
||||
major_llvm_version):
|
||||
exec_os_arch_key = _os_arch_pair(exec_os, exec_arch)
|
||||
target_os_arch_key = _os_arch_pair(target_os, target_arch)
|
||||
_check_os_arch_keys([exec_os_arch_key, target_os_arch_key])
|
||||
|
@ -189,6 +190,15 @@ def cc_toolchain_config(
|
|||
"-std=" + cxx_standard,
|
||||
"-stdlib=libc++",
|
||||
]
|
||||
if major_llvm_version >= 14:
|
||||
# With C++20, Clang defaults to using C++ rather than Clang modules,
|
||||
# which breaks Bazel's `use_module_maps` feature, which is used by
|
||||
# `layering_check`. Since Bazel doesn't support C++ modules yet, it
|
||||
# is safe to disable them globally until the toolchain shipped by
|
||||
# Bazel sets this flag on `use_module_maps`.
|
||||
# https://github.com/llvm/llvm-project/commit/0556138624edf48621dd49a463dbe12e7101f17d
|
||||
cxx_flags.append("-Xclang")
|
||||
cxx_flags.append("-fno-cxx-modules")
|
||||
if use_lld:
|
||||
# For single-platform builds, we can statically link the bundled
|
||||
# libraries.
|
||||
|
|
|
@ -372,6 +372,7 @@ cc_toolchain_config(
|
|||
"unfiltered_compile_flags": {unfiltered_compile_flags},
|
||||
}},
|
||||
cxx_builtin_include_directories = {cxx_builtin_include_directories},
|
||||
major_llvm_version = {major_llvm_version},
|
||||
)
|
||||
|
||||
toolchain(
|
||||
|
@ -541,6 +542,7 @@ cc_toolchain(
|
|||
if _is_hermetic_or_exists(rctx, dir, sysroot_path)
|
||||
]),
|
||||
extra_compiler_files = ("\"%s\"," % str(toolchain_info.extra_compiler_files)) if toolchain_info.extra_compiler_files else "",
|
||||
major_llvm_version = major_llvm_version,
|
||||
)
|
||||
|
||||
def _convenience_targets_str(rctx, use_absolute_paths, llvm_dist_rel_path, llvm_dist_label_prefix, exec_dl_ext):
|
||||
|
|
Loading…
Reference in New Issue