Allow the OSLog module to specify the log string section name

When building the `OSLog` module, look for a variable named
`osLogStringSectionName`. It must have a string literal as its
initializer, which provides the section name where the log strings
should be emitted. The `OSLog` module should contain something like
this:

    let osLogStringSectionName = "__TEXT,__logit"

When not present, the compiler will default to
`__TEXT,__oslogstring,cstring_literals`, which was previously the
hardcoded section name. Now, OSLog can customize the name.

Implements rdar://171571056
This commit is contained in:
Doug Gregor
2026-03-09 10:27:54 -07:00
parent 1dc9eb05dc
commit 454237a083
19 changed files with 134 additions and 3 deletions
@@ -231,6 +231,9 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
case options_block::DEFERRED_CODE_GEN:
extendedInfo.setDeferredCodeGen(true);
break;
case options_block::OSLOG_STRING_SECTION_NAME:
extendedInfo.setOSLogStringSectionName(blobData);
break;
default:
// Unknown options record, possibly for use by a future version of the
// module format.
@@ -1591,6 +1594,8 @@ ModuleFileSharedCore::ModuleFileSharedCore(
ModulePackageName = extInfo.getModulePackageName();
ModuleExportAsName = extInfo.getExportAsName();
PublicModuleName = extInfo.getPublicModuleName();
OSLogStringSectionName = extInfo.getOSLogStringSectionName();
SwiftInterfaceCompilerVersion =
extInfo.getSwiftInterfaceCompilerVersion();