File tree Expand file tree Collapse file tree 11 files changed +70
-0
lines changed Expand file tree Collapse file tree 11 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ class ModuleListProperties : public Properties {
86
86
bool GetSwiftLoadConformances () const ;
87
87
SwiftModuleLoadingMode GetSwiftModuleLoadingMode () const ;
88
88
bool SetSwiftModuleLoadingMode (SwiftModuleLoadingMode);
89
+ bool GetSwiftPreferSerializedBridgingHeader () const ;
89
90
90
91
bool GetEnableSwiftMetadataCache () const ;
91
92
uint64_t GetSwiftMetadataCacheMaxByteSize ();
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ let Definition = "modulelist" in {
40
40
DefaultEnumValue<"eSwiftModuleLoadingModePreferSerialized">,
41
41
EnumValues<"OptionEnumValues(g_swift_module_loading_mode_enums)">,
42
42
Desc<"The module loading mode to use when loading modules for Swift.">;
43
+ def SwiftPreferSerializedBridgingHeader: Property<"swift-prefer-serialized-bridging-header", "Boolean">,
44
+ DefaultTrue,
45
+ Desc<"Prefer serialized preprocessed bridging headers in Swift modules over on-disk headers.">;
43
46
def EnableSwiftMetadataCache: Property<"enable-swift-metadata-cache", "Boolean">,
44
47
Global,
45
48
DefaultTrue,
Original file line number Diff line number Diff line change @@ -224,6 +224,12 @@ bool ModuleListProperties::SetSwiftModuleLoadingMode(SwiftModuleLoadingMode mode
224
224
return SetPropertyAtIndex (idx, mode);
225
225
}
226
226
227
+ bool ModuleListProperties::GetSwiftPreferSerializedBridgingHeader () const {
228
+ const uint32_t idx = ePropertySwiftPreferSerializedBridgingHeader;
229
+ return GetPropertyAtIndexAs<bool >(
230
+ idx, g_modulelist_properties[idx].default_uint_value != 0 );
231
+ }
232
+
227
233
FileSpec ModuleListProperties::GetSwiftMetadataCachePath () const {
228
234
return m_collection_sp
229
235
->GetPropertyAtIndexAsOptionValueFileSpec (ePropertySwiftMetadataCachePath)
Original file line number Diff line number Diff line change @@ -3472,6 +3472,8 @@ swift::ClangImporterOptions &SwiftASTContext::GetClangImporterOptions() {
3472
3472
if (FileSystem::Instance ().Exists (clang_dir_spec))
3473
3473
clang_importer_options.OverrideResourceDir = clang_dir_spec.GetPath ();
3474
3474
clang_importer_options.DebuggerSupport = true ;
3475
+ clang_importer_options.PreferSerializedBridgingHeader =
3476
+ props.GetSwiftPreferSerializedBridgingHeader ();
3475
3477
3476
3478
clang_importer_options.DisableSourceImport =
3477
3479
!props.GetUseSwiftClangImporter ();
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ def test_extra_clang_flags(self):
29
29
# Because the bridging header isn't precompiled or in a module
30
30
# we don't have DWARF type information for the types it contains.
31
31
self .expect ("settings set symbols.swift-typesystem-compiler-fallback true" )
32
+ self .expect ("settings set symbols.swift-prefer-serialized-bridging-header false" )
32
33
33
34
# FIXME: this doesn't work if LLDB's build dir contains a space.
34
35
overlay = self .getBuildArtifact ('overlay.yaml' )
@@ -71,6 +72,7 @@ def test_invalid_extra_clang_flags(self):
71
72
self .addTearDownHook (
72
73
lambda : self .runCmd ("settings clear target.swift-extra-clang-flags" ))
73
74
75
+ self .expect ("settings set symbols.swift-prefer-serialized-bridging-header false" )
74
76
self .expect ('settings set target.swift-extra-clang-flags -- -v' )
75
77
76
78
lldbutil .run_to_source_breakpoint (self , "break here" ,
Original file line number Diff line number Diff line change
1
+ struct M { int j ; };
Original file line number Diff line number Diff line change
1
+ SWIFT_SOURCES := main.swift
2
+ SWIFT_ENABLE_EXPLICIT_MODULES := Yes
3
+ SWIFT_BRIDGING_HEADER := bridging.h
4
+ SWIFTFLAGS_EXTRAS = -Xcc -I$(BUILDDIR ) /secret
5
+
6
+ all : secret.h $(EXE )
7
+
8
+ include Makefile.rules
9
+
10
+ .PHONY : secret.h
11
+
12
+ secret.h :
13
+ mkdir -p $(BUILDDIR ) /secret
14
+ echo " struct S { int i; };" > $(BUILDDIR ) /secret/secret.h
Original file line number Diff line number Diff line change
1
+ import lldb
2
+ from lldbsuite .test .decorators import *
3
+ import lldbsuite .test .lldbtest as lldbtest
4
+ import lldbsuite .test .lldbutil as lldbutil
5
+
6
+
7
+ class TestSwiftExplicitModules (lldbtest .TestBase ):
8
+ NO_DEBUG_INFO_TESTCASE = True
9
+ @swiftTest
10
+ def test (self ):
11
+ """Test explicit Swift modules with bridging headers"""
12
+ self .build ()
13
+ secret = self .getBuildArtifact ("secret" )
14
+ import shutil
15
+ shutil .rmtree (secret )
16
+
17
+ target , process , thread , bkpt = lldbutil .run_to_source_breakpoint (
18
+ self , 'Set breakpoint here' , lldb .SBFileSpec ('main.swift' ))
19
+ log = self .getBuildArtifact ("types.log" )
20
+ self .expect ('log enable lldb types -f "%s"' % log )
21
+
22
+ self .expect ("frame variable s" , substrs = ['i = 23' ])
23
+ self .expect ("frame variable m" , substrs = ['j = 42' ])
24
+ self .expect ("expression s" , substrs = ['i = 23' ])
25
+ self .expect ("expression m" , substrs = ['j = 42' ])
26
+ self .filecheck ('platform shell cat "%s"' % log , __file__ )
27
+ # CHECK: LogConfiguration
28
+ # CHECK-NOT: secret
29
+ # CHECK: Import
Original file line number Diff line number Diff line change
1
+ // A non-modular header.
2
+ #include "secret.h"
3
+ // A modular header.
4
+ #include "M.h"
Original file line number Diff line number Diff line change
1
+ func main( ) {
2
+ let s = S ( i: 23 )
3
+ let m = M ( j: 42 )
4
+ print ( s) // Set breakpoint here
5
+ }
6
+
7
+ main ( )
You can’t perform that action at this time.
0 commit comments