From 0628a1f9f3b189fceafaa2e370e72d2b9710def6 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 8 Dec 2013 15:24:42 +0100 Subject: [PATCH 1/4] Exclude threadasm.S from build if CMake version is less than 2.8.5. Assembler support was rewritten in CMake 2.8.5. The new functionality is required to assemble the file, otherwise a bunch of error messages is generated. The solution is to exclude the file from the build. This is only a problem for non-x86 platforms (PPC, Mips). General advise is to use at least CMake 2.8.5. This fixes #464. --- runtime/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index f5fd158f..e10d9de2 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -102,7 +102,18 @@ if(UNIX) if(${CMAKE_SYSTEM} MATCHES "Linux") list(APPEND CORE_D_SYS ${CORE_D_LINUX}) endif() - list(APPEND DCRT_ASM ${RUNTIME_DIR}/src/core/threadasm.S) + # Assembler support was rewritten in CMake 2.8.5. + # The assembler file must be passed to gcc but prior to this + # version it is passed to as. This results in a bunch of + # error message. This is only critical for non-x86 platforms. + # On x86/x86-64 the file can safely be ignored. + if("${CMAKE_VERSION}" MATCHES "^2\\.8\\.[01234]($|\\..*)") + message(WARNING "Excluding core/threadasm.S from build because of missing CMake support.") + message(WARNING "This file is required for certain non-x86 platforms.") + message(WARNING "Please consider updating CMake to at least 2.8.5.") + else() + list(APPEND DCRT_ASM ${RUNTIME_DIR}/src/core/threadasm.S) + endif() if(APPLE) list(APPEND CORE_D_SYS ${CORE_D_OSX}) endif() From a2d7c9f3ed680f774685e25016574defd3bfda6d Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 8 Dec 2013 15:29:10 +0100 Subject: [PATCH 2/4] Only define version Android if compiling for this environment. Android is a variant of Linux. In order to simplify the version coding, only version Android is defined (version linux and version Posix are not). --- driver/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/driver/main.cpp b/driver/main.cpp index 38fe9236..b18be485 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -568,14 +568,17 @@ static void registerPredefinedTargetVersions() { VersionCondition::addPredefinedGlobalIdent("Cygwin"); break; case llvm::Triple::Linux: - VersionCondition::addPredefinedGlobalIdent("linux"); - VersionCondition::addPredefinedGlobalIdent("Posix"); #if LDC_LLVM_VER >= 302 if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) { VersionCondition::addPredefinedGlobalIdent("Android"); } + else #endif + { + VersionCondition::addPredefinedGlobalIdent("linux"); + VersionCondition::addPredefinedGlobalIdent("Posix"); + } break; case llvm::Triple::Haiku: VersionCondition::addPredefinedGlobalIdent("Haiku"); @@ -620,8 +623,6 @@ static void registerPredefinedTargetVersions() { #if LDC_LLVM_VER >= 302 case llvm::Triple::Android: VersionCondition::addPredefinedGlobalIdent("Android"); - VersionCondition::addPredefinedGlobalIdent("linux"); - VersionCondition::addPredefinedGlobalIdent("Posix"); break; #endif default: From 43acc1f9c87f21d1aed8725d9d591977c3be5ae6 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 8 Dec 2013 17:30:02 +0100 Subject: [PATCH 3/4] Check if basic types are read from object.di before usage. If object.di was not read or is incomplete then basic types may be missing. This results in a crash if they are used during runtime initialization. This fixes #551. --- gen/runtime.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 60b748f1..57d76ad8 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -168,6 +168,18 @@ static LLType* rt_dg2() return LLStructType::get(gIR->context(), types, false); } +template +static void ensureDecl(DECL *decl, const char *msg) +{ + if (!decl || !decl->type) + { + Logger::println("Missing class declaration: %s\n", msg); + error(Loc(), "Missing class declaration: %s", msg); + errorSupplemental(Loc(), "Please check that object.di is included and valid"); + fatal(); + } +} + static void LLVM_D_BuildRuntimeModule() { Logger::println("building runtime module"); @@ -187,10 +199,16 @@ static void LLVM_D_BuildRuntimeModule() LLType* wstringTy = DtoType(Type::twchar->arrayOf()); LLType* dstringTy = DtoType(Type::tdchar->arrayOf()); + ensureDecl(ClassDeclaration::object, "Object"); LLType* objectTy = DtoType(ClassDeclaration::object->type); + ensureDecl(ClassDeclaration::classinfo, "ClassInfo"); LLType* classInfoTy = DtoType(ClassDeclaration::classinfo->type); + ensureDecl(Type::typeinfo, "TypeInfo"); LLType* typeInfoTy = DtoType(Type::typeinfo->type); + ensureDecl(Type::typeinfoassociativearray, "TypeInfo_AssociativeArray"); LLType* aaTypeInfoTy = DtoType(Type::typeinfoassociativearray->type); + ensureDecl(Module::moduleinfo, "ModuleInfo"); + LLType* moduleInfoPtr = getPtrToType(DtoType(Module::moduleinfo->type)); LLType* aaTy = rt_ptr(LLStructType::get(gIR->context())); @@ -306,7 +324,7 @@ static void LLVM_D_BuildRuntimeModule() llvm::StringRef fname("_d_array_bounds"); llvm::StringRef fname2("_d_switch_error"); LLType *types[] = { - getPtrToType(DtoType(Module::moduleinfo->type)), + moduleInfoPtr, intTy }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); From aeba90b9f935418fd1d5dba3312041346baab618 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 8 Dec 2013 18:59:17 +0100 Subject: [PATCH 4/4] Fix a clang warning --- gen/nested.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/nested.cpp b/gen/nested.cpp index 41d5ad12..ee21459c 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -223,7 +223,7 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym) return llvm::ConstantPointerNull::get(getVoidPtrType()); } - struct FuncDeclaration* frameToPass = 0; + FuncDeclaration* frameToPass = 0; if (AggregateDeclaration *ad = sym->isAggregateDeclaration()) { // If sym is a nested struct or a nested class, pass the frame // of the function where sym is declared.