diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index b360140d7bf..739e270f29a 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -682,6 +682,8 @@ void CWriter::printModule(Module *M) { if (I->hasInternalLinkage()) Out << "static "; printType(Out, I->getType()->getElementType(), getValueName(I)); + if (I->hasLinkOnceLinkage()) + Out << " __attribute__((common))"; if (!I->getInitializer()->isNullValue()) { Out << " = " ; writeOperand(I->getInitializer()); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index b360140d7bf..739e270f29a 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -682,6 +682,8 @@ void CWriter::printModule(Module *M) { if (I->hasInternalLinkage()) Out << "static "; printType(Out, I->getType()->getElementType(), getValueName(I)); + if (I->hasLinkOnceLinkage()) + Out << " __attribute__((common))"; if (!I->getInitializer()->isNullValue()) { Out << " = " ; writeOperand(I->getInitializer());