mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Embedded] Only strip "external" from global variables that have definitions
Embedded Swift ends up rewriting the linkage of global variables as part of linking together all of the Swift modules. Doing so for extern global variables (e.g., ones meant to be implemented in C) breaks the LLVM module, because they will never have definitions. Only make this change when the global variable is a definition.
This commit is contained in:
@@ -522,6 +522,7 @@ 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();
|
||||
if (G->isDefinition())
|
||||
G->setLinkage(stripExternalFromLinkage(G->getLinkage()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user