Skip to content

Commit

Permalink
Support -debug-prefix-map for Xcode 10.2 (Swift 5.0) and higher.
Browse files Browse the repository at this point in the history
RELNOTES: When building with Xcode 10.2 (Swift 5.0) or higher, the compiler now passes `-debug-prefix-map` to the compiler to remap the working directory to `"."`, removing absolute source paths from the generated debug info.
PiperOrigin-RevId: 244941132
  • Loading branch information
allevato authored and swiple-rules-gardener committed Apr 23, 2019
1 parent c420d7d commit 4390010
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions swift/internal/api.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ load(
"SWIFT_FEATURE_AUTOLINK_EXTRACT",
"SWIFT_FEATURE_COVERAGE",
"SWIFT_FEATURE_DBG",
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_ENABLE_TESTING",
"SWIFT_FEATURE_FASTBUILD",
Expand Down Expand Up @@ -520,6 +521,12 @@ def _compile_as_objects(
else:
wrapper_args.add("-Xwrapped-swift=-ephemeral-module-cache")

if swift_common.is_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_DEBUG_PREFIX_MAP,
):
wrapper_args.add("-Xwrapped-swift=-debug-prefix-pwd-is-dot")

compile_args = actions.args()
if swift_common.is_enabled(
feature_configuration = feature_configuration,
Expand Down
5 changes: 4 additions & 1 deletion swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ load(
":features.bzl",
"SWIFT_FEATURE_AUTOLINK_EXTRACT",
"SWIFT_FEATURE_BUNDLED_XCTESTS",
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
"SWIFT_FEATURE_USE_RESPONSE_FILES",
Expand Down Expand Up @@ -496,7 +497,9 @@ def _xcode_swift_toolchain_impl(ctx):
requested_features.append(SWIFT_FEATURE_ENABLE_BATCH_MODE)
requested_features.append(SWIFT_FEATURE_USE_RESPONSE_FILES)

# TODO(#35): Add SWIFT_FEATURE_DEBUG_PREFIX_MAP based on Xcode version.
# Xcode 10.2 implies Swift 5.0.
if _is_xcode_at_least_version(xcode_config, "10.2"):
requested_features.append(SWIFT_FEATURE_DEBUG_PREFIX_MAP)

command_line_copts = _command_line_objc_copts(ctx.fragments.objc) + ctx.fragments.swift.copts()

Expand Down
3 changes: 3 additions & 0 deletions tools/wrappers/swift_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ for ARG in "$@" ; do
--persistent_worker)
USE_WORKER=1
;;
-Xwrapped-swift=-debug-prefix-pwd-is-dot)
ARGS+=(-debug-prefix-map "$PWD=.")
;;
-Xwrapped-swift=-ephemeral-module-cache)
MODULE_CACHE_DIR="$(mktemp -d "${TMPDIR%/}/wrapped_swift_module_cache.XXXXXXXXXX")"
ARGS+=(-module-cache-path "$MODULE_CACHE_DIR")
Expand Down

0 comments on commit 4390010

Please sign in to comment.