diff --git a/.hgignore b/.hgignore index 71eab2df..849cb42f 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,7 @@ syntax: glob *.a *.s *.so +*.swp *.rej Makefile CMakeFiles diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fc24d60..f2757939 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,12 @@ option(GENERATE_OFFTI "generate complete ClassInfo.offTi arrays") if(D_VERSION EQUAL 1) set(DMDFE_PATH dmd) set(LDC_EXE ldc) + set(LDMD_EXE ldmd) add_definitions(-DDMDV1) elseif(D_VERSION EQUAL 2) set(DMDFE_PATH dmd2) set(LDC_EXE ldc2) + set(LDMD_EXE ldmd2) add_definitions(-DDMDV2) else(D_VERSION EQUAL 1) message(FATAL_ERROR "unsupported D version") @@ -230,7 +232,7 @@ get_target_property(LDC_LOC ${LDC_EXE} LOCATION) # TODO: testrun install(TARGETS ${LDC_EXE} DESTINATION bin) -install(FILES ${PROJECT_SOURCE_DIR}/bin/ldmd DESTINATION bin) +install(FILES ${PROJECT_SOURCE_DIR}/bin/${LDMD_EXE} DESTINATION bin) install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.conf DESTINATION ${CONF_INST_DIR}) install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.rebuild.conf DESTINATION ${CONF_INST_DIR}) install(DIRECTORY ${PROJECT_BINARY_DIR}/lib DESTINATION . USE_SOURCE_PERMISSIONS) diff --git a/bin/ldmd2 b/bin/ldmd2 new file mode 100755 index 00000000..959586c9 --- /dev/null +++ b/bin/ldmd2 @@ -0,0 +1,43 @@ +#! /usr/bin/env bash + +# Default to 'ldc' next to this file +LDC=`basename "$0"`/ldc2 +if [ ! -x "$LDC" ]; then + # If that doesn't work, assume this script was called via $PATH + # and do the same for ldc + if which ldc2 &> /dev/null; then + LDC=ldc2 + else + echo 'ldc not found, check your installation' >/dev/stderr + exit 1 + fi +fi + +declare -a ARGS +IDX=0 +for arg; do + case "$arg" in + -C*) + # turn -Cfoo into -foo. + # Useful for passing -inline to ldc, for instance. + arg="-${arg:2}" + ;; + -debug|-debug=*|-version=*) + arg="-d$arg" + ;; + -inline) + arg="-enable-inlining" + ;; + -fPIC) + arg="-relocation-model=pic" + ;; + --a|--b|--c|--f|--r|--w|--x|--y) + # "Hidden debug switches" + # Are these ever used? + arg="-hidden-debug${arg:1}" + ;; + esac + ARGS[IDX++]="$arg" +done + +exec "$LDC" "${ARGS[@]}" diff --git a/dmd2/idgen b/dmd2/idgen index b880dfba..ff2f8880 100755 Binary files a/dmd2/idgen and b/dmd2/idgen differ diff --git a/dmd2/impcnvgen b/dmd2/impcnvgen index ad385c12..eb6e70b4 100755 Binary files a/dmd2/impcnvgen and b/dmd2/impcnvgen differ diff --git a/gen/classes.cpp b/gen/classes.cpp index 2ac7be9f..c88bdcba 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -672,6 +672,8 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) // ClassInfo *base; // base class // void *destructor; // void *invariant; // class invariant +// version(D_Version2) +// void *xgetMembers; // uint flags; // void *deallocator; // OffsetTypeInfo[] offTi; @@ -690,7 +692,11 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) ClassDeclaration* cinfo = ClassDeclaration::classinfo; +#if DMDV2 + if (cinfo->fields.dim != 13) +#else if (cinfo->fields.dim != 12) +#endif { error("object.d ClassInfo class is incorrect"); fatal(); diff --git a/gen/toobj.cpp b/gen/toobj.cpp index 93f31411..eb9094e2 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -620,7 +620,11 @@ void Module::genmoduleinfo() fatal(); } // check for patch +#if DMDV2 + else if (moduleinfo->fields.dim != 10) +#else else if (moduleinfo->fields.dim != 9) +#endif { error("object.d ModuleInfo class is incorrect"); fatal(); diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 4ec5f601..c6759971 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -178,12 +178,10 @@ LLConstant * IrStruct::getVtblInit() // build the constant struct constVtbl = llvm::ConstantStruct::get(constants, false); - // sanity check #if 0 - IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; - IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl; + IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; + IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl; #endif - assert(constVtbl->getType() == type->irtype->isClass()->getVtbl() && "vtbl initializer type mismatch");