Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add swift.disable_clang_spi feature and enable it by default #1372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE = "swift._force_alwayslink_true"
# enables runtime checking of exclusive memory access on mutation.
SWIFT_FEATURE_CHECKED_EXCLUSIVITY = "swift.checked_exclusivity"

# If enabled, requests the `-disable-clang-spi` swiftc flag. Disables importing
# Clang SPIs as Swift SPIs.
SWIFT_FEATURE_DISABLE_CLANG_SPI = "swift.disable_clang_spi"

# Disables Swift sandbox which prevents issues with nested sandboxing when Swift code contains system-provided macros.
# If enabled '#Preview' macro provided by SwiftUI fails to build and probably other system-provided macros.
# Enabled by default for Swift 5.10+ on macOS.
Expand Down
10 changes: 10 additions & 0 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ load(
"SWIFT_FEATURE_COVERAGE_PREFIX_MAP",
"SWIFT_FEATURE_DBG",
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_DISABLE_CLANG_SPI",
"SWIFT_FEATURE_DISABLE_SWIFT_SANDBOX",
"SWIFT_FEATURE_DISABLE_SYSTEM_INDEX",
"SWIFT_FEATURE_EMIT_BC",
Expand Down Expand Up @@ -1115,6 +1116,15 @@ def compile_action_configs(
configurators = [add_arg("-enable-bare-slash-regex")],
features = [SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX],
),
ActionConfigInfo(
actions = [
SWIFT_ACTION_COMPILE,
],
configurators = [add_arg("-Xfrontend", "-disable-clang-spi")],
features = [
SWIFT_FEATURE_DISABLE_CLANG_SPI,
],
),
]

# NOTE: The positions of these action configs in the list are important,
Expand Down
2 changes: 2 additions & 0 deletions swift/toolchains/swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ load(
"SWIFT_FEATURE_CACHEABLE_SWIFTMODULES",
"SWIFT_FEATURE_COVERAGE_PREFIX_MAP",
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_DISABLE_CLANG_SPI",
"SWIFT_FEATURE_DISABLE_SYSTEM_INDEX",
"SWIFT_FEATURE_EMIT_SWIFTDOC",
"SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO",
Expand Down Expand Up @@ -464,6 +465,7 @@ def _swift_toolchain_impl(ctx):
SWIFT_FEATURE_CACHEABLE_SWIFTMODULES,
SWIFT_FEATURE_COVERAGE_PREFIX_MAP,
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
SWIFT_FEATURE_DISABLE_CLANG_SPI,
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
SWIFT_FEATURE_EMIT_SWIFTDOC,
SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
Expand Down
2 changes: 2 additions & 0 deletions swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ load(
"SWIFT_FEATURE_COVERAGE",
"SWIFT_FEATURE_COVERAGE_PREFIX_MAP",
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_DISABLE_CLANG_SPI",
"SWIFT_FEATURE_DISABLE_SWIFT_SANDBOX",
"SWIFT_FEATURE_DISABLE_SYSTEM_INDEX",
"SWIFT_FEATURE_EMIT_SWIFTDOC",
Expand Down Expand Up @@ -711,6 +712,7 @@ def _xcode_swift_toolchain_impl(ctx):
SWIFT_FEATURE_CHECKED_EXCLUSIVITY,
SWIFT_FEATURE_COVERAGE_PREFIX_MAP,
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
SWIFT_FEATURE_DISABLE_CLANG_SPI,
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
SWIFT_FEATURE_EMIT_SWIFTDOC,
SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
Expand Down