Skip to content

Commit fd5a4df

Browse files
allevatobrentleyjones
authored andcommitted
Move the C++ toolchain into its own execution group so that it does not have to be bound by the same constraints as the execution platform selected for the Swift toolchain.
PiperOrigin-RevId: 745988579 (cherry picked from commit bb0f38b) Signed-off-by: Brentley Jones <[email protected]>
1 parent 3dfbf33 commit fd5a4df

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

swift/toolchains/swift_toolchain.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
2525
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
2626
load(
2727
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
28-
"find_cpp_toolchain",
28+
"CPP_TOOLCHAIN_TYPE",
2929
"use_cpp_toolchain",
3030
)
3131
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
@@ -410,7 +410,7 @@ def _parse_target_system_name(*, arch, os, target_system_name):
410410

411411
def _swift_toolchain_impl(ctx):
412412
toolchain_root = ctx.attr.root
413-
cc_toolchain = find_cpp_toolchain(ctx)
413+
cc_toolchain = ctx.exec_groups["default"].toolchains[CPP_TOOLCHAIN_TYPE].cc
414414
target_system_name = _parse_target_system_name(
415415
arch = ctx.attr.arch,
416416
os = ctx.attr.os,
@@ -706,6 +706,14 @@ The version of XCTest that the toolchain packages.
706706
},
707707
),
708708
doc = "Represents a Swift compiler toolchain.",
709+
exec_groups = {
710+
# An execution group that has no specific platform requirements. This
711+
# ensures that the execution platform of this Swift toolchain does not
712+
# unnecessarily constrain the execution platform of the C++ toolchain.
713+
"default": exec_group(
714+
toolchains = use_cpp_toolchain(),
715+
),
716+
},
709717
fragments = [] if bazel_features.cc.swift_fragment_removed else ["swift"],
710718
toolchains = use_cpp_toolchain(),
711719
implementation = _swift_toolchain_impl,

swift/toolchains/xcode_swift_toolchain.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
2525
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
2626
load(
2727
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
28-
"find_cpp_toolchain",
28+
"CPP_TOOLCHAIN_TYPE",
2929
"use_cpp_toolchain",
3030
)
3131
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
@@ -626,7 +626,7 @@ def _dsym_provider(*, ctx):
626626
def _xcode_swift_toolchain_impl(ctx):
627627
cpp_fragment = ctx.fragments.cpp
628628
apple_toolchain = apple_common.apple_toolchain()
629-
cc_toolchain = find_cpp_toolchain(ctx)
629+
cc_toolchain = ctx.exec_groups["default"].toolchains[CPP_TOOLCHAIN_TYPE].cc
630630

631631
target_triple = ctx.var.get("CC_TARGET_TRIPLE") or target_triples.normalize_for_swift(
632632
target_triples.parse(cc_toolchain.target_gnu_system_name),
@@ -998,6 +998,14 @@ for incremental compilation using a persistent mode.
998998
},
999999
),
10001000
doc = "Represents a Swift compiler toolchain provided by Xcode.",
1001+
exec_groups = {
1002+
# An execution group that has no specific platform requirements. This
1003+
# ensures that the execution platform of this Swift toolchain does not
1004+
# unnecessarily constrain the execution platform of the C++ toolchain.
1005+
"default": exec_group(
1006+
toolchains = use_cpp_toolchain(),
1007+
),
1008+
},
10011009
fragments = [
10021010
"cpp",
10031011
"objc",

test/fixtures/linking/fake_framework.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
load(
44
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
5-
"find_cpp_toolchain",
5+
"CPP_TOOLCHAIN_TYPE",
66
"use_cpp_toolchain",
77
)
88
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
@@ -15,7 +15,7 @@ def _impl(ctx):
1515
binary2 = ctx.actions.declare_file("framework2.framework/framework2")
1616
ctx.actions.write(binary2, "empty")
1717

18-
cc_toolchain = find_cpp_toolchain(ctx)
18+
cc_toolchain = ctx.exec_groups["default"].toolchains[CPP_TOOLCHAIN_TYPE].cc
1919
feature_configuration = cc_common.configure_features(
2020
ctx = ctx,
2121
cc_toolchain = cc_toolchain,
@@ -56,6 +56,14 @@ fake_framework = rule(
5656
doc = "The C++ toolchain to use.",
5757
),
5858
},
59+
exec_groups = {
60+
# An execution group that has no specific platform requirements. This
61+
# ensures that the execution platform of this Swift toolchain does not
62+
# unnecessarily constrain the execution platform of the C++ toolchain.
63+
"default": exec_group(
64+
toolchains = use_cpp_toolchain(),
65+
),
66+
},
5967
toolchains = use_cpp_toolchain(),
6068
fragments = ["cpp"],
6169
)

0 commit comments

Comments
 (0)