Description
Previous ID | SR-2637 |
Radar | None |
Original Reporter | dmishe (JIRA User) |
Type | Bug |
Status | Closed |
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 | LLDB for Swift |
Labels | Bug |
Assignee | @trfiala |
Priority | Medium |
md5: b76ab4f38b9543ef86bb7f211e8dd45d
cloned to:
- SR-2660 Teach the driver to accept multiple swiftmodules as linker inputs, for static linking
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.