Skip to content

Commit

Permalink
Capture macro expansions in an output group named macro_expansions
Browse files Browse the repository at this point in the history
…during debug builds

LLDB wants these files to be present on the file system to step into macro expansions, because their file paths are recorded in debug info. The compiler uses `TMPDIR` (if set) as the location for those files, so we can have the worker set `TMPDIR` to a target-specific location before spawning `swiftc`. If this location is workspace-relative, then those file paths are also remapped via `-debug-prefix-map`—an added bonus.

The `macro_expansions` group will contain a tree (directory) artifact that contains a `swift-generated-sources` subdirectory (the compiler forces that name), which contains one or more `.swift` files representing the expanded macro buffers.

PiperOrigin-RevId: 549932429
(cherry picked from commit 69349ee)

Cherry-pick notes: We already included most of this in c9d1f5f. This just restricts `_macro_expansion_configurator` to debug builds.

Signed-off-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
allevato authored and brentleyjones committed Oct 7, 2024
1 parent cc73cd8 commit 8a21c7c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,10 @@ def compile_action_configs(
SWIFT_ACTION_DERIVE_FILES,
],
configurators = [_macro_expansion_configurator],
# The compiler only generates these in debug builds, unless we pass
# additional frontend flags. At the current time, we only want to
# capture these for debug builds.
not_features = [SWIFT_FEATURE_OPT],
),

# swift-symbolgraph-extract doesn't yet support explicit Swift module
Expand Down

0 comments on commit 8a21c7c

Please sign in to comment.