Merge branch 'master' into merge-2.067

This commit is contained in:
David Nadlinger 2015-07-11 18:10:43 +02:00
commit 21d1bab114
6 changed files with 138 additions and 22 deletions

View file

@ -327,9 +327,7 @@ if(MSVC)
string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_definitions(-D_HAS_EXCEPTIONS=0) add_definitions(-D_HAS_EXCEPTIONS=0)
set(EXTRA_CXXFLAGS "/GF /GR- /EHs-c- /MP") set(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} /GF /GR- /EHs-c- /MP")
else()
set(EXTRA_CXXFLAGS "")
endif() endif()
# if llvm was built with assertions we have to do the same # if llvm was built with assertions we have to do the same

View file

@ -38,7 +38,9 @@
* so nothing would be compatible anyway. * so nothing would be compatible anyway.
*/ */
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || IN_LLVM #if !IN_LLVM
//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
#endif
/* /*
* Follows Itanium C++ ABI 1.86 * Follows Itanium C++ ABI 1.86
@ -176,7 +178,11 @@ class CppMangleVisitor : public Visitor
else else
{ {
s->error("Internal Compiler Error: C++ %s template value parameter is not supported", tv->valType->toChars()); s->error("Internal Compiler Error: C++ %s template value parameter is not supported", tv->valType->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
else if (!tp || tp->isTemplateTypeParameter()) else if (!tp || tp->isTemplateTypeParameter())
@ -192,7 +198,11 @@ class CppMangleVisitor : public Visitor
if (!d && !e) if (!d && !e)
{ {
s->error("Internal Compiler Error: %s is unsupported parameter for C++ template: (%s)", o->toChars()); s->error("Internal Compiler Error: %s is unsupported parameter for C++ template: (%s)", o->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
if (d && d->isFuncDeclaration()) if (d && d->isFuncDeclaration())
{ {
@ -220,14 +230,22 @@ class CppMangleVisitor : public Visitor
else else
{ {
s->error("Internal Compiler Error: %s is unsupported parameter for C++ template", o->toChars()); s->error("Internal Compiler Error: %s is unsupported parameter for C++ template", o->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
else else
{ {
s->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters"); s->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
if (is_var_arg) if (is_var_arg)
@ -400,7 +418,11 @@ class CppMangleVisitor : public Visitor
if (!(d->storage_class & (STCextern | STCgshared))) if (!(d->storage_class & (STCextern | STCgshared)))
{ {
d->error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported"); d->error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
Dsymbol *p = d->toParent(); Dsymbol *p = d->toParent();
@ -525,7 +547,11 @@ class CppMangleVisitor : public Visitor
// Mangle static arrays as pointers // Mangle static arrays as pointers
t->error(Loc(), "Internal Compiler Error: unable to pass static array to extern(C++) function."); t->error(Loc(), "Internal Compiler Error: unable to pass static array to extern(C++) function.");
t->error(Loc(), "Use pointer instead."); t->error(Loc(), "Use pointer instead.");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
//t = t->nextOf()->pointerTo(); //t = t->nextOf()->pointerTo();
} }
@ -587,7 +613,11 @@ public:
{ {
t->error(Loc(), "Internal Compiler Error: unsupported type %s\n", t->toChars()); t->error(Loc(), "Internal Compiler Error: unsupported type %s\n", t->toChars());
} }
#if IN_LLVM
fatal();
#else
assert(0); //Assert, because this error should be handled in frontend assert(0); //Assert, because this error should be handled in frontend
#endif
} }
void visit(TypeBasic *t) void visit(TypeBasic *t)
@ -892,14 +922,18 @@ public:
} }
}; };
#if !IN_LLVM
char *toCppMangle(Dsymbol *s) char *toCppMangle(Dsymbol *s)
{ {
//printf("toCppMangle(%s)\n", s->toChars()); //printf("toCppMangle(%s)\n", s->toChars());
CppMangleVisitor v; CppMangleVisitor v;
return v.mangleOf(s); return v.mangleOf(s);
} }
#endif
#elif TARGET_WINDOS #if !IN_LLVM
//#elif TARGET_WINDOS
#endif
// Windows DMC and Microsoft Visual C++ mangling // Windows DMC and Microsoft Visual C++ mangling
#define VC_SAVED_TYPE_CNT 10 #define VC_SAVED_TYPE_CNT 10
@ -960,7 +994,11 @@ public:
{ {
type->error(Loc(), "Internal Compiler Error: unsupported type %s\n", type->toChars()); type->error(Loc(), "Internal Compiler Error: unsupported type %s\n", type->toChars());
} }
#if IN_LLVM
fatal();
#else
assert(0); // Assert, because this error should be handled in frontend assert(0); // Assert, because this error should be handled in frontend
#endif
} }
void visit(TypeBasic *type) void visit(TypeBasic *type)
@ -1375,7 +1413,11 @@ private:
if (!(d->storage_class & (STCextern | STCgshared))) if (!(d->storage_class & (STCextern | STCgshared)))
{ {
d->error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported"); d->error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
buf.writeByte('?'); buf.writeByte('?');
mangleIdent(d); mangleIdent(d);
@ -1513,7 +1555,11 @@ private:
else else
{ {
sym->error("Internal Compiler Error: C++ %s template value parameter is not supported", tv->valType->toChars()); sym->error("Internal Compiler Error: C++ %s template value parameter is not supported", tv->valType->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
else if (!tp || tp->isTemplateTypeParameter()) else if (!tp || tp->isTemplateTypeParameter())
@ -1529,7 +1575,11 @@ private:
if (!d && !e) if (!d && !e)
{ {
sym->error("Internal Compiler Error: %s is unsupported parameter for C++ template", o->toChars()); sym->error("Internal Compiler Error: %s is unsupported parameter for C++ template", o->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
if (d && d->isFuncDeclaration()) if (d && d->isFuncDeclaration())
{ {
@ -1571,7 +1621,11 @@ private:
else else
{ {
sym->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters"); sym->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
tmp.mangleIdent(d); tmp.mangleIdent(d);
@ -1579,14 +1633,22 @@ private:
else else
{ {
sym->error("Internal Compiler Error: %s is unsupported parameter for C++ template: (%s)", o->toChars()); sym->error("Internal Compiler Error: %s is unsupported parameter for C++ template: (%s)", o->toChars());
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
else else
{ {
sym->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters"); sym->error("Internal Compiler Error: C++ templates support only integral value, type parameters, alias templates and alias function parameters");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
} }
name = tmp.buf.extractString(); name = tmp.buf.extractString();
@ -1884,7 +1946,11 @@ private:
{ {
t->error(Loc(), "Internal Compiler Error: unable to pass static array to extern(C++) function."); t->error(Loc(), "Internal Compiler Error: unable to pass static array to extern(C++) function.");
t->error(Loc(), "Use pointer instead."); t->error(Loc(), "Use pointer instead.");
#if IN_LLVM
fatal();
#else
assert(0); assert(0);
#endif
} }
flags &= ~IS_NOT_TOP_TYPE; flags &= ~IS_NOT_TOP_TYPE;
flags &= ~IGNORE_CONST; flags &= ~IGNORE_CONST;
@ -1892,12 +1958,35 @@ private:
} }
}; };
#if IN_LLVM
char *toCppMangle(Dsymbol *s)
{
#if LDC_LLVM_VER >= 305
const bool isTargetWindowsMSVC = global.params.targetTriple.isWindowsMSVCEnvironment();
#else
const bool isTargetWindowsMSVC = global.params.targetTriple.getOS() == llvm::Triple::Win32;
#endif
if (isTargetWindowsMSVC)
{
VisualCPPMangler v(!global.params.is64bit);
return v.mangleOf(s);
}
else
{
CppMangleVisitor v;
return v.mangleOf(s);
}
}
#else
char *toCppMangle(Dsymbol *s) char *toCppMangle(Dsymbol *s)
{ {
VisualCPPMangler v(!global.params.mscoff); VisualCPPMangler v(!global.params.mscoff);
return v.mangleOf(s); return v.mangleOf(s);
} }
#endif
#else
#error "fix this" #if !IN_LLVM
//#else
//#error "fix this"
//#endif
#endif #endif

View file

@ -7756,11 +7756,14 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
} }
StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems); StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems);
#if IN_DMD
/* Copy from the initializer symbol for larger symbols, /* Copy from the initializer symbol for larger symbols,
* otherwise the literals expressed as code get excessively large. * otherwise the literals expressed as code get excessively large.
*/ */
if (size(loc) > Target::ptrsize * 4 && !needsNested()) if (size(loc) > Target::ptrsize * 4 && !needsNested())
#if IN_LLVM
structinit->sinit = static_cast<SymbolDeclaration *>(
static_cast<VarExp *>(defaultInit(loc))->var);
#else
structinit->sinit = toInitializer(sym); structinit->sinit = toInitializer(sym);
#endif #endif

View file

@ -2413,7 +2413,15 @@ namespace AsmParserx8664
{ {
case Float_Ptr: type_suffix = 's'; break; case Float_Ptr: type_suffix = 's'; break;
case Double_Ptr: type_suffix = 'l'; break; case Double_Ptr: type_suffix = 'l'; break;
case Extended_Ptr: type_suffix = 't'; break; case Extended_Ptr:
#if LDC_LLVM_VER >= 305
// MS C runtime: real = 64-bit double
if (global.params.targetTriple.isWindowsMSVCEnvironment())
type_suffix = 'l';
else
#endif
type_suffix = 't';
break;
default: default:
return false; return false;
} }

View file

@ -943,7 +943,11 @@ void DtoResolveVariable(VarDeclaration* vd)
Logger::println("parent: null"); Logger::println("parent: null");
} }
const bool isLLConst = (vd->isConst() || vd->isImmutable()) && vd->init; // If a const/immutable value has a proper initializer (not "= void"),
// it cannot be assigned again in a static constructor. Thus, we can
// emit it as read-only data.
const bool isLLConst = (vd->isConst() || vd->isImmutable()) &&
vd->init && !vd->init->isVoidInitializer();
assert(!vd->ir.isInitialized()); assert(!vd->ir.isInitialized());
if (gIR->dmodule) if (gIR->dmodule)

View file

@ -125,6 +125,7 @@ elseif(WIN32)
list(REMOVE_ITEM LDC_D ${RUNTIME_DIR}/src/ldc/eh2.d) list(REMOVE_ITEM LDC_D ${RUNTIME_DIR}/src/ldc/eh2.d)
endif() endif()
list(REMOVE_ITEM DCRT_C ${RUNTIME_DIR}/src/rt/monitor.c) list(REMOVE_ITEM DCRT_C ${RUNTIME_DIR}/src/rt/monitor.c)
list(REMOVE_ITEM DCRT_C ${RUNTIME_DIR}/src/rt/bss_section.c)
endif() endif()
list(APPEND CORE_D ${CORE_D_INTERNAL} ${CORE_D_SYNC} ${CORE_D_SYS} ${CORE_D_STDC}) list(APPEND CORE_D ${CORE_D_INTERNAL} ${CORE_D_SYNC} ${CORE_D_SYS} ${CORE_D_STDC})
list(APPEND CORE_D ${LDC_D} ${RUNTIME_DIR}/src/object_.d) list(APPEND CORE_D ${LDC_D} ${RUNTIME_DIR}/src/object_.d)
@ -226,6 +227,29 @@ add_custom_command(
COMMAND gen_gccbuiltins ${GCCBUILTINS} "x86" COMMAND gen_gccbuiltins ${GCCBUILTINS} "x86"
) )
if(MSVC)
if(NOT LINK_WITH_MSVCRT)
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
foreach(variable ${variables})
if(${variable} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
endif()
endforeach()
endif()
# /wd4996: suppress deprecation warnings about zlib using POSIX names
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
set(CMAKE_C_FLAGS_DEBUG "")
endif()
# Always build zlib and other C parts of the runtime in release mode, regardless # Always build zlib and other C parts of the runtime in release mode, regardless
# of what the user chose for LDC itself. # of what the user chose for LDC itself.
set(cfiles "${CORE_C};${DCRT_C}") set(cfiles "${CORE_C};${DCRT_C}")
@ -490,17 +514,7 @@ endmacro()
# Set up build targets. # Set up build targets.
# #
if(MSVC) set(RT_CFLAGS "")
# /wd4996: suppress deprecation warnings about zlib using POSIX names
if (LINK_WITH_MSVCRT)
set(RT_CFLAGS "/wd4996 /MD")
else()
set(RT_CFLAGS "/wd4996 /MT")
endif()
else()
set(RT_CFLAGS "")
endif()
# This is a bit of a mess as we need to join the two libraries together on # This is a bit of a mess as we need to join the two libraries together on
# OS X before installing them. After this has run, LIBS_TO_INSTALL contains # OS X before installing them. After this has run, LIBS_TO_INSTALL contains