Description
Previous ID | SR-2660 |
Radar | rdar://problem/34795599 |
Original Reporter | @trfiala |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Environment
Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, Driver, StarterBug |
Assignee | @JDevlieghere |
Priority | Medium |
md5: 6b6c547b0589245db749baf930bc2e1b
blocks:
- SR-3280 Package manager should link main swiftmodule in executables
cloned from:
- SR-2637 Issue with debugging programs that contain multiple Swift modules
is duplicated by:
- SR-3863 swift emits a temporary swiftmodule when swiftmodule of main module is passed with -emit-executable
Issue Description:
Suppose we have an Objective-C program that uses two Swift modules. We would like to debug this program with LLDB without having a dSYM for faster builds.
┌───────┐
┌──│ Swift │
┌───────┐ ┌───────┐ │ └───────┘
│ Bin │◀──│ ObjC │◀┤
└───────┘ └───────┘ │ ┌───────┐
└──│ Swift │
└───────┘
Each Swift module consist of a .swiftmodule
, .o
, and the .h
header.
swiftc -c -g src/foo.swift \
-module-name Foo \
-emit-module-path out/Foo.swiftmodule \
-emit-objc-header-path out/Foo-Swift.h \
...
We then link the two Swift objects and Objective-C objects into the final binary. It looks like LLDB needs to have .swiftmodule information for debugging, so we include references as AST entries.
clang src/main.m -fobjc-arc -o out/main out/foo.o out/bar.o \
-Xlinker -add_ast_path -Xlinker out/Foo.swiftmodule \
-Xlinker -add_ast_path -Xlinker out/Bar.swiftmodule
...
When we run LLDB on this binary and set breakpoints inside of the code for Foo and Bar modules, only the Foo types are picked up by LLDB. It only reads the first AST reference, ignoring others. If we swap the order of add_ast_path options we get symbols from the other module.
The full build is in attached zip file. Unpack and run build.sh. In its output, you will see that frame variable self
command only correctly prints the variable for one module, not both.