Fix linking errors of export(cpp) symbols on OSX.

This commit is contained in:
Dmitri Makarov 2015-04-05 21:21:29 +02:00
parent 346cff4b54
commit 5ae8ef92cc
2 changed files with 14 additions and 11 deletions

View file

@ -406,7 +406,11 @@ class CppMangleVisitor : public Visitor
Dsymbol *p = d->toParent(); Dsymbol *p = d->toParent();
if (p && !p->isModule()) //for example: char Namespace1::beta[6] should be mangled as "_ZN10Namespace14betaE" if (p && !p->isModule()) //for example: char Namespace1::beta[6] should be mangled as "_ZN10Namespace14betaE"
{ {
#if IN_LLVM
buf.writestring("_ZN");
#else
buf.writestring(global.params.isOSX ? "__ZN" : "_ZN"); // "__Z" for OSX, "_Z" for other buf.writestring(global.params.isOSX ? "__ZN" : "_ZN"); // "__Z" for OSX, "_Z" for other
#endif
prefix_name(p); prefix_name(p);
source_name(d); source_name(d);
buf.writeByte('E'); buf.writeByte('E');
@ -415,13 +419,19 @@ class CppMangleVisitor : public Visitor
{ {
if (!is_temp_arg_ref) if (!is_temp_arg_ref)
{ {
#if !IN_LLVM
if (global.params.isOSX) if (global.params.isOSX)
buf.writeByte('_'); buf.writeByte('_');
#endif
buf.writestring(d->ident->toChars()); buf.writestring(d->ident->toChars());
} }
else else
{ {
#if IN_LLVM
buf.writestring("_Z");
#else
buf.writestring(global.params.isOSX ? "__Z" : "_Z"); buf.writestring(global.params.isOSX ? "__Z" : "_Z");
#endif
source_name(d); source_name(d);
} }
} }
@ -438,7 +448,11 @@ class CppMangleVisitor : public Visitor
*/ */
TypeFunction *tf = (TypeFunction *)d->type; TypeFunction *tf = (TypeFunction *)d->type;
#if IN_LLVM
buf.writestring("_Z");
#else
buf.writestring(global.params.isOSX ? "__Z" : "_Z"); // "__Z" for OSX, "_Z" for other buf.writestring(global.params.isOSX ? "__Z" : "_Z"); // "__Z" for OSX, "_Z" for other
#endif
Dsymbol *p = d->toParent(); Dsymbol *p = d->toParent();
if (p && !p->isModule() && tf->linkage == LINKcpp) if (p && !p->isModule() && tf->linkage == LINKcpp)
{ {

View file

@ -486,14 +486,3 @@ DValue * DtoInlineAsmExpr(Loc& loc, FuncDeclaration * fd, Expressions * argument
// return call as im value // return call as im value
return new DImValue(fd->type->nextOf(), rv); return new DImValue(fd->type->nextOf(), rv);
} }