From e1402a4c6981d5c7dfd9089b7932eb25c41155e7 Mon Sep 17 00:00:00 2001 From: xdev Date: Mon, 11 Sep 2023 17:02:05 +0200 Subject: [PATCH] Add macOS CC toolchain --- swift/internal/swift_autoconfiguration.bzl | 10 ++++++++++ swift/internal/swift_toolchain.bzl | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/swift/internal/swift_autoconfiguration.bzl b/swift/internal/swift_autoconfiguration.bzl index 6749a61bc..acfa8aad7 100644 --- a/swift/internal/swift_autoconfiguration.bzl +++ b/swift/internal/swift_autoconfiguration.bzl @@ -389,9 +389,13 @@ def _create_xcode_toolchain(repository_ctx): SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS, ] + path_to_swiftc = repository_ctx.which("swiftc") + toolchain_root = path_to_swiftc.dirname + repository_ctx.file( "BUILD", """ +load("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl", "cc_toolchain_config") load( "@build_bazel_rules_swift//swift/internal:xcode_swift_toolchain.bzl", "xcode_swift_toolchain", @@ -399,6 +403,11 @@ load( package(default_visibility = ["//visibility:public"]) +alias( + name = "current_swift_cc_toolchain", + actual = "@local_config_apple_cc//:toolchain" +) + xcode_swift_toolchain( name = "toolchain", features = [{feature_list}], @@ -408,6 +417,7 @@ xcode_swift_toolchain( '"{}"'.format(feature) for feature in feature_values ]), + toolchain_root = toolchain_root, ), ) diff --git a/swift/internal/swift_toolchain.bzl b/swift/internal/swift_toolchain.bzl index c0c9c9b3b..2f7f6f676 100644 --- a/swift/internal/swift_toolchain.bzl +++ b/swift/internal/swift_toolchain.bzl @@ -432,7 +432,7 @@ configuration options that are applied to targets on a per-package basis. allow_single_file = True, ), "_cc_toolchain": attr.label( - default = Label("@build_bazel_rules_swift_local_config//:current_swift_cc_toolchain"), + default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"), doc = """\ The C++ toolchain from which other tools needed by the Swift toolchain (such as `clang` and `ar`) will be retrieved.