Serialize library level into .swiftmodule binary format

Add a LIBRARY_LEVEL record to the .swiftmodule options block so the
declared -library-level value survives across compilations. Without
this, imported modules have to always fell back to a path heuristic
that could only distinguish API vs SPI and never returned IPI.

rdar://174255626
This commit is contained in:
Sam Pyankov
2026-04-07 14:57:38 -07:00
parent abdfecea08
commit a09cf04718
16 changed files with 129 additions and 19 deletions
@@ -237,6 +237,12 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
case options_block::AGGRESSIVE_CMO:
extendedInfo.setAggressiveCMOEnabled(true);
break;
case options_block::LIBRARY_LEVEL: {
unsigned rawLevel;
options_block::LibraryLevelLayout::readRecord(scratch, rawLevel);
extendedInfo.setLibraryLevel(LibraryLevel(rawLevel));
break;
}
default:
// Unknown options record, possibly for use by a future version of the
// module format.
@@ -1605,6 +1611,7 @@ ModuleFileSharedCore::ModuleFileSharedCore(
Bits.StrictMemorySafety = extInfo.strictMemorySafety();
Bits.DeferredCodeGen = extInfo.deferredCodeGen();
Bits.AggressiveCMOEnabled = extInfo.isAggressiveCMOEnabled();
Bits.LibraryLevel = unsigned(extInfo.getLibraryLevel());
MiscVersion = info.miscVersion;
SDKVersion = info.sdkVersion;
ModuleABIName = extInfo.getModuleABIName();