11load ("@hermetic_cc_toolchain//toolchain/private:defs.bzl" , "target_structs" )
22
3- def declare_toolchains (configs = "" ):
3+ def declare_toolchains (configs = "" , extra_target_settings = [] ):
44 for target_config in target_structs ():
55 gotarget = target_config .gotarget
66 zigtarget = target_config .zigtarget
@@ -12,11 +12,11 @@ def declare_toolchains(configs = ""):
1212 if hasattr (target_config , "libc_constraint" ):
1313 extra_constraints = ["@zig_sdk//libc:unconstrained" ]
1414
15- _declare_toolchain (gotarget , zigtarget , target_config .constraint_values + extra_constraints , configs )
15+ _declare_toolchain (gotarget , zigtarget , target_config .constraint_values + extra_constraints , configs , extra_target_settings )
1616
1717 _declare_zig_toolchain ("zig" , configs )
1818
19- def declare_libc_aware_toolchains (configs = "" ):
19+ def declare_libc_aware_toolchains (configs = "" , extra_target_settings = [] ):
2020 for target_config in target_structs ():
2121 gotarget = target_config .gotarget
2222 zigtarget = target_config .zigtarget
@@ -25,15 +25,16 @@ def declare_libc_aware_toolchains(configs = ""):
2525 # is only selected if libc is not expicitly set and another one that is
2626 # only selected if the specific libc variant is selected.
2727 if hasattr (target_config , "libc_constraint" ):
28- _declare_toolchain (gotarget , zigtarget , target_config .constraint_values + [target_config .libc_constraint ], configs )
28+ _declare_toolchain (gotarget , zigtarget , target_config .constraint_values + [target_config .libc_constraint ], configs , extra_target_settings )
2929
30- def _declare_toolchain (gotarget , zigtarget , target_compatible_with , configs ):
30+ def _declare_toolchain (gotarget , zigtarget , target_compatible_with , configs , extra_target_settings ):
3131 # register two kinds of toolchain targets: Go and Zig conventions.
3232 # Go convention: amd64/arm64, linux/darwin
3333 native .toolchain (
3434 name = gotarget ,
3535 exec_compatible_with = ["{}//:exec_os" .format (configs ), "{}//:exec_cpu" .format (configs )],
3636 target_compatible_with = target_compatible_with ,
37+ target_settings = extra_target_settings ,
3738 toolchain = "{}//:{}_cc" .format (configs , zigtarget ),
3839 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type" ,
3940 )
@@ -43,6 +44,7 @@ def _declare_toolchain(gotarget, zigtarget, target_compatible_with, configs):
4344 name = zigtarget ,
4445 exec_compatible_with = ["{}//:exec_os" .format (configs ), "{}//:exec_cpu" .format (configs )],
4546 target_compatible_with = target_compatible_with ,
47+ target_settings = extra_target_settings ,
4648 toolchain = "{}//:{}_cc" .format (configs , zigtarget ),
4749 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type" ,
4850 )
0 commit comments