Skip to content

Commit abc35e5

Browse files
committed
Don't emit the FORCE_LOAD symbols when the compiler is running
on behalf of the debugger. The debugger will read the LinkLibrary's from all the modules it sees, and hand load all the required dependencies, and since the symbol is weak it doesn't even tell us whether a required dependency is missing. So it serves no purpose in this case. <rdar://problem/51463642>
1 parent 8221c67 commit abc35e5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,12 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
10331033
}
10341034
}
10351035

1036-
if (linkLib.shouldForceLoad()) {
1036+
// Don't emit the FORCE_LOAD symbols when the compiler is running
1037+
// on behalf of the debugger. The debugger will read the LinkLibrary's
1038+
// from all the modules it sees, and hand load all the required dependencies,
1039+
// and since the symbol is weak it doesn't even tell us whether a
1040+
// required dependency is missing. So it serves no purpose in this case.
1041+
if (linkLib.shouldForceLoad() && !Context.LangOpts.DebuggerSupport) {
10371042
llvm::SmallString<64> buf;
10381043
encodeForceLoadSymbolName(buf, linkLib.getName());
10391044
auto ForceImportThunk =

test/Serialization/autolinking.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
// RUN: %FileCheck %s < %t/force-load.txt
1616
// RUN: %FileCheck -check-prefix FORCE-LOAD-CLIENT -check-prefix FORCE-LOAD-CLIENT-%target-object-format %s < %t/force-load.txt
1717

18+
// RUN: %target-swift-frontend -runtime-compatibility-version none -emit-ir -debugger-support -lmagic %s -I %t > %t/force-load.txt
19+
// RUN: %FileCheck %s < %t/force-load.txt
20+
// RUN: %FileCheck -check-prefix NO-FORCE-LOAD-CLIENT %s < %t/force-load.txt
21+
1822
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version none -emit-ir -parse-stdlib -module-name someModule -module-link-name module %S/../Inputs/empty.swift | %FileCheck --check-prefix=NO-FORCE-LOAD %s
1923
// RUN: %target-swift-frontend -runtime-compatibility-version none -emit-ir -parse-stdlib -module-name someModule -module-link-name module %S/../Inputs/empty.swift -autolink-force-load | %FileCheck --check-prefix=FORCE-LOAD %s
2024
// RUN: %target-swift-frontend -runtime-compatibility-version none -emit-ir -parse-stdlib -module-name someModule -module-link-name 0module %S/../Inputs/empty.swift -autolink-force-load | %FileCheck --check-prefix=FORCE-LOAD-HEX %s
@@ -42,6 +46,7 @@ import someModule
4246
// FORCE-LOAD-HEX: ret void
4347
// FORCE-LOAD-HEX: }
4448

49+
// NO-FORCE-LOAD-CLIENT-NOT: FORCE_LOAD
4550
// FORCE-LOAD-CLIENT: @"_swift_FORCE_LOAD_$_module_$_autolinking" = weak_odr hidden constant void ()* @"_swift_FORCE_LOAD_$_module"
4651
// FORCE-LOAD-CLIENT: @llvm.used = appending global [{{[0-9]+}} x i8*] [
4752
// FORCE-LOAD-CLIENT: i8* bitcast (void ()** @"_swift_FORCE_LOAD_$_module_$_autolinking" to i8*)

0 commit comments

Comments
 (0)