Skip to content

Commit 317c516

Browse files
committed
Serialization: remove force linked symbols for static libs
This adjusts the IRGen to avoid the force load symbol for static linking. When static linking, we can elide the force load symbol as it exists to ensure that the shared library is loaded at runtime unconditionally. However, the symbol will not preserve the library and it will be DCE'd appropriately. This resolves the unresolved force load symbol when statically linking on Windows.
1 parent 5cda4f4 commit 317c516

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,8 @@ ModuleFileSharedCore::ModuleFileSharedCore(
13501350
bool shouldForceLink;
13511351
input_block::LinkLibraryLayout::readRecord(scratch, rawKind,
13521352
shouldForceLink);
1353+
if (Bits.IsStaticLibrary)
1354+
shouldForceLink = false;
13531355
if (auto libKind = getActualLibraryKind(rawKind))
13541356
LinkLibraries.push_back({blobData, *libKind, shouldForceLink});
13551357
// else ignore the dependency...it'll show up as a linker error.

0 commit comments

Comments
 (0)