Skip to content

Commit c2cde97

Browse files
committed
[DebuggingTheCompiler.md] Show how to use -Rmodule-loading and SWIFT_FORCE_MODULE_LOADING to debug module/swiftinterface loading issues.
Just had to do this recently and realized I had forgotten how to do it. Placing it in DebuggingTheCompiler.md so I can look it up from here again after I forget how to do it again.
1 parent fc25044 commit c2cde97

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/DebuggingTheCompiler.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ benefit of all Swift developers.
3838
- [Reducing SIL test cases using bug_reducer](#reducing-sil-test-cases-using-bug_reducer)
3939
- [Disabling PCH Verification](#disabling-pch-verification)
4040
- [Diagnosing LSAN Failures in the Compiler](#diagnosing-lsan-failures-in-the-compiler)
41+
- [Diagnosing the modules and swiftinterface files that the Compiler is loading](#diagnosing-the-modules-and-swiftinterface-files-that-the-compiler-is-loading)
4142
- [Debugging the Compiler Build](#debugging-the-compiler-build)
4243
- [Build Dry Run](#build-dry-run)
4344
- [Debugging the Compiler Driver](#debugging-the-compiler-driver-build)
@@ -937,6 +938,34 @@ $ apt update
937938
$ apt install vim
938939
```
939940

941+
## Diagnosing the modules and swiftinterface files that the Compiler is loading
942+
943+
In order to determine which swiftinterface files or modules a compiler is
944+
loading, one can pass in the `-Rmodule-loading` flag to the compiler. This will
945+
cause the compiler to emit diagnostics that show where it is loading modules
946+
from. E.x.:
947+
948+
```
949+
<unknown>:0: remark: 'Swift' has a required transitive dependency on 'SwiftShims'
950+
<unknown>:0: remark: loaded module 'SwiftShims'; source: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/shims/module.modulemap', loaded: '2HUHAYXMA6V6X/SwiftShims-2VJU34GCOR4TK.pcm'
951+
<unknown>:0: remark: loaded module 'Swift'; source: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/Swift.swiftmodule/arm64e-apple-macos.swiftinterface', loaded: '$MODULE_CACHE_PATH/Swift-145L0LE2COJMJ.swiftmodule'
952+
<unknown>:0: remark: '_StringProcessing' has a required transitive dependency on 'Swift'
953+
<unknown>:0: remark: loaded module '_StringProcessing'; source: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/_StringProcessing.swiftmodule/arm64e-apple-macos.swiftinterface', loaded: '$MODULE_CACHE_PATH/_StringProcessing-GDUC793JZ4FG.swiftmodule'
954+
<unknown>:0: remark: loaded module '_SwiftConcurrencyShims'; source: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/shims/module.modulemap', loaded: '$MODULE_CACHE_PATH/2HUHAYXMA6V6X/_SwiftConcurrencyShims-2VJU34GCOR4TK.pcm'
955+
<unknown>:0: remark: '_Concurrency' has a required transitive dependency on 'Swift'
956+
<unknown>:0: remark: '_Concurrency' has a required transitive dependency on 'SwiftShims'
957+
<unknown>:0: remark: loaded module '_Concurrency'; source: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/_Concurrency.swiftmodule/arm64e-apple-macos.swiftinterface', loaded: '$MODULE_CACHE_PATH/_Concurrency-2F0RT3BEWY3IN.swiftmodule'
958+
```
959+
960+
One can also control whether or not the compiler prefers the interface or
961+
serialized version of a module by using the environment variable
962+
`SWIFT_FORCE_MODULE_LOADING`. The supported options are:
963+
964+
* prefer-interface
965+
* prefer-serialized
966+
* only-interface
967+
* only-serialized
968+
940969
# Debugging the Compiler Build
941970

942971
## Build Dry Run

0 commit comments

Comments
 (0)