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.
This commit is contained in:
Saleem Abdulrasool
2022-02-14 21:09:09 -08:00
parent 5cda4f46a4
commit 317c5167d3

View File

@@ -1350,6 +1350,8 @@ ModuleFileSharedCore::ModuleFileSharedCore(
bool shouldForceLink;
input_block::LinkLibraryLayout::readRecord(scratch, rawKind,
shouldForceLink);
if (Bits.IsStaticLibrary)
shouldForceLink = false;
if (auto libKind = getActualLibraryKind(rawKind))
LinkLibraries.push_back({blobData, *libKind, shouldForceLink});
// else ignore the dependency...it'll show up as a linker error.