Merge pull request #85776 from DougGregor/extern-global-variables-embedded

[Embedded] Only strip "external" from global variables that have definitions
This commit is contained in:
Doug Gregor
2025-12-01 22:25:50 -08:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@@ -522,7 +522,8 @@ void SILLinkerVisitor::visitGlobalAddrInst(GlobalAddrInst *GAI) {
// In Embedded Swift, we want to actually link globals from other modules too,
// so strip "external" from the linkage.
SILGlobalVariable *G = GAI->getReferencedGlobal();
G->setLinkage(stripExternalFromLinkage(G->getLinkage()));
if (G->isDefinition())
G->setLinkage(stripExternalFromLinkage(G->getLinkage()));
}
//===----------------------------------------------------------------------===//

View File

@@ -21,8 +21,12 @@ public func publicFuncInAModule() {
@usableFromInline
internal func internalFuncInAModule() {
some_c_api()
_ = globalVariable
}
@_extern(c)
var globalVariable: Int
// BEGIN Main.swift
import MyModule