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
@@ -983,6 +983,8 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
M.setABIName(Ctx.getIdentifier(loadedModuleFile->getModuleABIName()));
if (!loadedModuleFile->getPublicModuleName().empty())
M.setPublicModuleName(Ctx.getIdentifier(loadedModuleFile->getPublicModuleName()));
if (!loadedModuleFile->getOSLogStringSectionName().empty())
Ctx.LangOpts.OSLogStringSectionName = loadedModuleFile->getOSLogStringSectionName();
if (loadedModuleFile->isConcurrencyChecked())
M.setIsConcurrencyChecked();
if (loadedModuleFile->strictMemorySafety())