Skip to content
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 @@ -325,6 +325,10 @@ SWIFT_FEATURE_OBJC_LINK_FLAGS = "swift.objc_link_flag"
# all Swift compilations to always be linked.
SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE = "swift._force_alwayslink_true"

# If enabled, requests the `-enforce-exclusivity=checked` swiftc flag which
# enables runtime checking of exclusive memory access on mutation.
SWIFT_FEATURE_CHECKED_EXCLUSIVITY = "swift.checked_exclusivity"

# 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
8 changes: 8 additions & 0 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ load(
load(
"//swift/internal:feature_names.bzl",
"SWIFT_FEATURE_CACHEABLE_SWIFTMODULES",
"SWIFT_FEATURE_CHECKED_EXCLUSIVITY",
"SWIFT_FEATURE_CODEVIEW_DEBUG_INFO",
"SWIFT_FEATURE_COVERAGE",
"SWIFT_FEATURE_COVERAGE_PREFIX_MAP",
Expand Down Expand Up @@ -249,6 +250,13 @@ def compile_action_configs(
configurators = [_emit_objc_header_path_configurator],
),

# Configure enforce exclusivity checks if enabled.
ActionConfigInfo(
actions = [SWIFT_ACTION_COMPILE],
configurators = [add_arg("-enforce-exclusivity=checked")],
features = [SWIFT_FEATURE_CHECKED_EXCLUSIVITY],
),

# Configure Const value extraction.
ActionConfigInfo(
actions = [SWIFT_ACTION_COMPILE],
Expand Down