Skip to content

Commit a2452f1

Browse files
authored
Plumb conly_flags through to the toolchain (#435)
This allows us to pull even more configuration of the toolchain out of .bazelrc flags into the toolchain definition. Signed-off-by: Austin Schuh <[email protected]>
1 parent 9ead61d commit a2452f1

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

toolchain/cc_toolchain_config.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def cc_toolchain_config(
208208
# The linker has no way of knowing if there are C++ objects; so we
209209
# always link C++ libraries.
210210
cxx_standard = compiler_configuration["cxx_standard"]
211+
conly_flags = compiler_configuration["conly_flags"]
211212
sysroot_path = compiler_configuration["sysroot_path"]
212213
if stdlib == "builtin-libc++" and is_xcompile:
213214
stdlib = "stdc++"
@@ -380,6 +381,7 @@ def cc_toolchain_config(
380381
compile_flags = compile_flags,
381382
dbg_compile_flags = dbg_compile_flags,
382383
opt_compile_flags = opt_compile_flags,
384+
conly_flags = conly_flags,
383385
cxx_flags = cxx_flags,
384386
link_flags = link_flags + select({str(Label("@toolchains_llvm//toolchain/config:use_libunwind")): libunwind_link_flags, "//conditions:default": []}) +
385387
select({str(Label("@toolchains_llvm//toolchain/config:use_compiler_rt")): compiler_rt_link_flags, "//conditions:default": []}),

toolchain/internal/configure.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def llvm_config_impl(rctx):
159159
stdlib_dict = rctx.attr.stdlib,
160160
cxx_standard_dict = rctx.attr.cxx_standard,
161161
compile_flags_dict = rctx.attr.compile_flags,
162+
conly_flags_dict = rctx.attr.conly_flags,
162163
cxx_flags_dict = rctx.attr.cxx_flags,
163164
link_flags_dict = rctx.attr.link_flags,
164165
archive_flags_dict = rctx.attr.archive_flags,
@@ -377,6 +378,7 @@ cc_toolchain_config(
377378
"stdlib": "{stdlib}",
378379
"cxx_standard": "{cxx_standard}",
379380
"compile_flags": {compile_flags},
381+
"conly_flags": {conly_flags},
380382
"cxx_flags": {cxx_flags},
381383
"link_flags": {link_flags},
382384
"archive_flags": {archive_flags},
@@ -549,6 +551,7 @@ cc_toolchain(
549551
stdlib = _dict_value(toolchain_info.stdlib_dict, target_pair, "builtin-libc++"),
550552
cxx_standard = _dict_value(toolchain_info.cxx_standard_dict, target_pair, "c++17"),
551553
compile_flags = _list_to_string(_dict_value(toolchain_info.compile_flags_dict, target_pair)),
554+
conly_flags = _list_to_string(toolchain_info.conly_flags_dict.get(target_pair, [])),
552555
cxx_flags = _list_to_string(_dict_value(toolchain_info.cxx_flags_dict, target_pair)),
553556
link_flags = _list_to_string(_dict_value(toolchain_info.link_flags_dict, target_pair)),
554557
archive_flags = _list_to_string(_dict_value(toolchain_info.archive_flags_dict, target_pair)),

toolchain/internal/repo.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ _compiler_configuration_attrs = {
163163
"target OS and arch pair you want to override " +
164164
"({}); empty key overrides all.".format(_target_pairs)),
165165
),
166+
"conly_flags": attr.string_list_dict(
167+
mandatory = False,
168+
doc = ("Extra flags for compiling C (not C++) files, " +
169+
"for each target OS and arch pair you want to support " +
170+
"({}), ".format(", ".join(_supported_os_arch_keys())) + "."),
171+
),
166172
"cxx_flags": attr.string_list_dict(
167173
mandatory = False,
168174
doc = ("Override for cxx_flags, replacing the default values. " +

0 commit comments

Comments
 (0)