@@ -21,7 +21,7 @@ load(":full_version.bzl", "full_version")
21
21
load (":python_register_toolchains.bzl" , "python_register_toolchains" )
22
22
load (":pythons_hub.bzl" , "hub_repo" )
23
23
load (":repo_utils.bzl" , "repo_utils" )
24
- load (":toolchains_repo.bzl" , "multi_toolchain_aliases" )
24
+ load (":toolchains_repo.bzl" , "host_toolchain" , " multi_toolchain_aliases" )
25
25
load (":util.bzl" , "IS_BAZEL_6_4_OR_HIGHER" )
26
26
load (":version.bzl" , "version" )
27
27
@@ -298,6 +298,7 @@ def _python_impl(module_ctx):
298
298
_internal_bzlmod_toolchain_call = True ,
299
299
** kwargs
300
300
)
301
+ host_compatible = []
301
302
for repo_name , (platform_name , platform_info ) in register_result .impl_repos .items ():
302
303
toolchain_impls .append (struct (
303
304
# str: The base name to use for the toolchain() target
@@ -315,12 +316,15 @@ def _python_impl(module_ctx):
315
316
# The last toolchain is the default; it can't have version constraints
316
317
set_python_version_constraint = is_last ,
317
318
))
318
- if _is_compatible_with_host (mctx , platform_info ):
319
- host_toolchain (
320
- name = toolchain_info .name ,
321
- platforms = [platform_name ],
322
- python_version = full_python_version ,
323
- )
319
+ if _is_compatible_with_host (module_ctx , platform_info ):
320
+ host_compatible .append (platform_name )
321
+
322
+ host_toolchain (
323
+ name = toolchain_info .name + "_host" ,
324
+ # NOTE: Order matters. The first found to be compatible is (usually) used.
325
+ platforms = host_compatible ,
326
+ python_version = full_python_version ,
327
+ )
324
328
325
329
# List of the base names ("python_3_10") for the toolchain repos
326
330
base_toolchain_repo_names = []
@@ -413,8 +417,8 @@ def _python_impl(module_ctx):
413
417
return None
414
418
415
419
def _is_compatible_with_host (mctx , platform_info ):
416
- os_name = repo_utils .get_platforms_os_name (rctx )
417
- cpu_name = repo_utils .get_platforms_cpu_name (rctx )
420
+ os_name = repo_utils .get_platforms_os_name (mctx )
421
+ cpu_name = repo_utils .get_platforms_cpu_name (mctx )
418
422
return platform_info .os_name == os_name and platform_info .arch == cpu_name
419
423
420
424
def _one_or_the_same (first , second , * , onerror = None ):
0 commit comments