Serialization: serialize if the module is a static library

If the `-static` option is specified, store that in the generated
swiftmodule file.  When de-serializing, recover this information in the
representative SILModule.

This will be used for code generation on Windows.  It is the missing
piece to allow static linking to function properly.  It additionally
opens the path to additional optimization on ELF-ish targets - GOT, PLT
references can be avoided when the linked module is known to be static.

Co-authored by: Saleem Abdulrasool <compnerd@compnerd.org>
This commit is contained in:
Erik Eckstein
2021-04-30 14:04:39 +02:00
committed by Saleem Abdulrasool
parent fba9d8342f
commit 762e9c7882
14 changed files with 50 additions and 2 deletions

View File

@@ -131,6 +131,9 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
options_block::IsSIBLayout::readRecord(scratch, IsSIB);
extendedInfo.setIsSIB(IsSIB);
break;
case options_block::IS_STATIC_LIBRARY:
extendedInfo.setIsStaticLibrary(true);
break;
case options_block::IS_TESTABLE:
extendedInfo.setIsTestable(true);
break;
@@ -1180,6 +1183,7 @@ ModuleFileSharedCore::ModuleFileSharedCore(
UserModuleVersion = info.userModuleVersion;
Bits.ArePrivateImportsEnabled = extInfo.arePrivateImportsEnabled();
Bits.IsSIB = extInfo.isSIB();
Bits.IsStaticLibrary = extInfo.isStaticLibrary();
Bits.IsTestable = extInfo.isTestable();
Bits.ResilienceStrategy = unsigned(extInfo.getResilienceStrategy());
Bits.IsImplicitDynamicEnabled = extInfo.isImplicitDynamicEnabled();