diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl index 013a59d1..6349a979 100644 --- a/toolchain/cc_toolchain_config.bzl +++ b/toolchain/cc_toolchain_config.bzl @@ -208,6 +208,7 @@ def cc_toolchain_config( # The linker has no way of knowing if there are C++ objects; so we # always link C++ libraries. cxx_standard = compiler_configuration["cxx_standard"] + conly_flags = compiler_configuration["conly_flags"] sysroot_path = compiler_configuration["sysroot_path"] if stdlib == "builtin-libc++" and is_xcompile: stdlib = "stdc++" @@ -380,6 +381,7 @@ def cc_toolchain_config( compile_flags = compile_flags, dbg_compile_flags = dbg_compile_flags, opt_compile_flags = opt_compile_flags, + conly_flags = conly_flags, cxx_flags = cxx_flags, link_flags = link_flags + select({str(Label("@toolchains_llvm//toolchain/config:use_libunwind")): libunwind_link_flags, "//conditions:default": []}) + select({str(Label("@toolchains_llvm//toolchain/config:use_compiler_rt")): compiler_rt_link_flags, "//conditions:default": []}), diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl index 37756dd9..16afd5f8 100644 --- a/toolchain/internal/configure.bzl +++ b/toolchain/internal/configure.bzl @@ -159,6 +159,7 @@ def llvm_config_impl(rctx): stdlib_dict = rctx.attr.stdlib, cxx_standard_dict = rctx.attr.cxx_standard, compile_flags_dict = rctx.attr.compile_flags, + conly_flags_dict = rctx.attr.conly_flags, cxx_flags_dict = rctx.attr.cxx_flags, link_flags_dict = rctx.attr.link_flags, archive_flags_dict = rctx.attr.archive_flags, @@ -377,6 +378,7 @@ cc_toolchain_config( "stdlib": "{stdlib}", "cxx_standard": "{cxx_standard}", "compile_flags": {compile_flags}, + "conly_flags": {conly_flags}, "cxx_flags": {cxx_flags}, "link_flags": {link_flags}, "archive_flags": {archive_flags}, @@ -549,6 +551,7 @@ cc_toolchain( stdlib = _dict_value(toolchain_info.stdlib_dict, target_pair, "builtin-libc++"), cxx_standard = _dict_value(toolchain_info.cxx_standard_dict, target_pair, "c++17"), compile_flags = _list_to_string(_dict_value(toolchain_info.compile_flags_dict, target_pair)), + conly_flags = _list_to_string(toolchain_info.conly_flags_dict.get(target_pair, [])), cxx_flags = _list_to_string(_dict_value(toolchain_info.cxx_flags_dict, target_pair)), link_flags = _list_to_string(_dict_value(toolchain_info.link_flags_dict, target_pair)), archive_flags = _list_to_string(_dict_value(toolchain_info.archive_flags_dict, target_pair)), diff --git a/toolchain/internal/repo.bzl b/toolchain/internal/repo.bzl index 3bd95a93..0f17cb56 100644 --- a/toolchain/internal/repo.bzl +++ b/toolchain/internal/repo.bzl @@ -163,6 +163,12 @@ _compiler_configuration_attrs = { "target OS and arch pair you want to override " + "({}); empty key overrides all.".format(_target_pairs)), ), + "conly_flags": 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())) + "."), + ), "cxx_flags": attr.string_list_dict( mandatory = False, doc = ("Override for cxx_flags, replacing the default values. " +