aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2006-12-01 00:25:12 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2006-12-01 00:25:12 +0000
commit78ee7b78c3c47b71c4b7a1475438d6574216a64b (patch)
tree95741db67fdcf0223e347e9448bc8baf7997cf84 /lib/Target/CBackend/Writer.cpp
parent44c030a7ee8ea2bbc9482313313480eb1795a63f (diff)
Introducing external weak linkage. Darwin codegen should be added later.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend/Writer.cpp')
-rw-r--r--lib/Target/CBackend/Writer.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index fa869db6aa..6d83aeb85d 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -1157,8 +1157,6 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#define __attribute__(X)\n"
<< "#endif\n\n";
-#if 0
- // At some point, we should support "external weak" vs. "weak" linkages.
// On Mac OS X, "external weak" is spelled "__attribute__((weak_import))".
Out << "#if defined(__GNUC__) && defined(__APPLE_CC__)\n"
<< "#define __EXTERNAL_WEAK__ __attribute__((weak_import))\n"
@@ -1167,7 +1165,6 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#else\n"
<< "#define __EXTERNAL_WEAK__\n"
<< "#endif\n\n";
-#endif
// For now, turn off the weak linkage attribute on Mac OS X. (See above.)
Out << "#if defined(__GNUC__) && defined(__APPLE_CC__)\n"
@@ -1357,7 +1354,11 @@ bool CWriter::doInitialization(Module &M) {
Out << "__declspec(dllimport) ";
printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
Out << ";\n";
- }
+ } else if (I->hasExternalWeakLinkage()) {
+ Out << "extern ";
+ printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
+ Out << " __EXTERNAL_WEAK__ ;\n";
+ }
}
}
@@ -1370,9 +1371,13 @@ bool CWriter::doInitialization(Module &M) {
// Don't print declarations for intrinsic functions.
if (!I->getIntrinsicID() && I->getName() != "setjmp" &&
I->getName() != "longjmp" && I->getName() != "_setjmp") {
+ if (I->hasExternalWeakLinkage())
+ Out << "extern ";
printFunctionSignature(I, true);
if (I->hasWeakLinkage() || I->hasLinkOnceLinkage())
Out << " __ATTRIBUTE_WEAK__";
+ if (I->hasExternalWeakLinkage())
+ Out << " __EXTERNAL_WEAK__";
if (StaticCtors.count(I))
Out << " __ATTRIBUTE_CTOR__";
if (StaticDtors.count(I))
@@ -1405,6 +1410,8 @@ bool CWriter::doInitialization(Module &M) {
Out << " __attribute__((common))";
else if (I->hasWeakLinkage())
Out << " __ATTRIBUTE_WEAK__";
+ else if (I->hasExternalWeakLinkage())
+ Out << " __EXTERNAL_WEAK__";
Out << ";\n";
}
}