Skip to content

Commit 6d92157

Browse files
committed
[Explicit Module Builds] Write '-clang-target' to serialized debugging options
Otherwise LLDB's ClangImporter instance will be instantiated against a mismatching triple.
1 parent aecc10e commit 6d92157

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
208208
} else {
209209
serializationOpts.ExtraClangOptions = getClangImporterOptions().ExtraArgs;
210210
}
211+
if (LangOpts.ClangTarget) {
212+
serializationOpts.ExtraClangOptions.push_back("-triple");
213+
serializationOpts.ExtraClangOptions.push_back(LangOpts.ClangTarget->str());
214+
}
211215

212216
serializationOpts.PluginSearchOptions =
213217
getSearchPathOptions().PluginSearchOpts;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -module-name ClangTargetModule -emit-module-path %t/has_clang_target.swiftmodule -parse-as-library -serialize-debugging-options -clang-target arm64e-apple-macos12.12 %s
3+
4+
// Check the serialized flags paths.
5+
// RUN: llvm-bcanalyzer -dump %t/has_clang_target.swiftmodule > %t/has_clang_target.swiftmodule.txt
6+
// RUN: %FileCheck %s < %t/has_clang_target.swiftmodule.txt
7+
8+
// CHECK-LABEL: <OPTIONS_BLOCK
9+
// CHECK: <XCC abbrevid={{[0-9]+}}/> blob data = '-triple'
10+
// CHECK-NEXT: <XCC abbrevid={{[0-9]+}}/> blob data = 'arm64e-apple-macos12.12'
11+
// CHECK: </OPTIONS_BLOCK>

0 commit comments

Comments
 (0)