mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-15 12:23:13 +01:00
Fix building of the runtime as a shared library
This commit is contained in:
@@ -522,9 +522,11 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
|
||||
LLGlobalVariable* thismref = new LLGlobalVariable(*gIR->module, modulerefTy, false, LLGlobalValue::InternalLinkage, thismrefinit, thismrefname);
|
||||
|
||||
// make sure _Dmodule_ref is declared
|
||||
LLGlobalVariable* mref = gIR->module->getNamedGlobal("_Dmodule_ref");
|
||||
LLConstant* mref = gIR->module->getNamedGlobal("_Dmodule_ref");
|
||||
const LLType *modulerefPtrTy = getPtrToType(modulerefTy);
|
||||
if (!mref)
|
||||
mref = new LLGlobalVariable(*gIR->module, getPtrToType(modulerefTy), false, LLGlobalValue::ExternalLinkage, NULL, "_Dmodule_ref");
|
||||
mref = new LLGlobalVariable(*gIR->module, modulerefPtrTy, false, LLGlobalValue::ExternalLinkage, NULL, "_Dmodule_ref");
|
||||
mref = DtoBitCast(mref, getPtrToType(modulerefPtrTy));
|
||||
|
||||
// make the function insert this moduleinfo as the beginning of the _Dmodule_ref linked list
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "moduleinfoCtorEntry", ctor);
|
||||
|
||||
@@ -9,6 +9,10 @@ set(D_FLAGS -g -w -d CACHE STRING "runtime build flags, separated by ;")
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
list(APPEND D_FLAGS -relocation-model=pic)
|
||||
set(D_LIBRARY_TYPE SHARED)
|
||||
else(BUILD_SHARED_LIBS)
|
||||
set(D_LIBRARY_TYPE STATIC)
|
||||
set(CXX_COMPILE_FLAGS " ")
|
||||
endif(BUILD_SHARED_LIBS)
|
||||
|
||||
# build tango for D1, druntime for D2
|
||||
@@ -81,12 +85,15 @@ elseif(D_VERSION EQUAL 2)
|
||||
${RUNTIME_DC_DIR}/arrayfloat.d
|
||||
${RUNTIME_DC_DIR}/arrayreal.d
|
||||
${RUNTIME_DC_DIR}/arrayshort.d
|
||||
${RUNTIME_DC_DIR}/critical_.d
|
||||
${RUNTIME_DC_DIR}/deh.d
|
||||
${RUNTIME_DC_DIR}/deh2.d
|
||||
${RUNTIME_DC_DIR}/llmath.d
|
||||
${RUNTIME_DC_DIR}/qsort2.d
|
||||
${RUNTIME_DC_DIR}/trace.d
|
||||
)
|
||||
file(GLOB DCRT_C ${RUNTIME_DC_DIR}/*.c)
|
||||
list(REMOVE_ITEM DCRT_C ${RUNTIME_DC_DIR}/deh.c ${RUNTIME_DC_DIR}/memory_osx.c)
|
||||
list(REMOVE_ITEM DCRT_C ${RUNTIME_DC_DIR}/deh.c ${RUNTIME_DC_DIR}/memory_osx.c ${RUNTIME_DC_DIR}/dylib_fixes.c)
|
||||
if(UNIX)
|
||||
file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/posix/*.d)
|
||||
elseif(WIN32)
|
||||
@@ -131,6 +138,9 @@ elseif(D_VERSION EQUAL 2)
|
||||
${PHOBOS2_DIR}/etc/c/zlib.d
|
||||
${PHOBOS2_DIR}/crc32.d
|
||||
)
|
||||
list(REMOVE_ITEM PHOBOS2_D
|
||||
${PHOBOS2_DIR}/std/intrinsic.d
|
||||
)
|
||||
set(CONFIG_NAME ${LDC_EXE}_phobos)
|
||||
else(PHOBOS2_DIR)
|
||||
set(CONFIG_NAME ${LDC_EXE})
|
||||
@@ -233,12 +243,12 @@ foreach(f ${DCRT_D})
|
||||
endforeach(f)
|
||||
|
||||
if(BUILD_SINGLE_LIB)
|
||||
add_library(${RUNTIME_AIO} ${CORE_O} ${CORE_C} ${GC_O} ${DCRT_O} ${DCRT_C})
|
||||
add_library(${RUNTIME_AIO} ${D_LIBRARY_TYPE} ${CORE_O} ${CORE_C} ${GC_O} ${DCRT_O} ${DCRT_C})
|
||||
set(LIBS ${RUNTIME_AIO})
|
||||
else(BUILD_SINGLE_LIB)
|
||||
add_library(${RUNTIME_CC} ${CORE_O} ${CORE_C})
|
||||
add_library(${RUNTIME_GC} ${GC_O})
|
||||
add_library(${RUNTIME_DC} ${DCRT_O} ${DCRT_C})
|
||||
add_library(${RUNTIME_CC} ${D_LIBRARY_TYPE} ${CORE_O} ${CORE_C})
|
||||
add_library(${RUNTIME_GC} ${D_LIBRARY_TYPE} ${GC_O})
|
||||
add_library(${RUNTIME_DC} ${D_LIBRARY_TYPE} ${DCRT_O} ${DCRT_C})
|
||||
set(LIBS
|
||||
${RUNTIME_CC}
|
||||
${RUNTIME_GC}
|
||||
@@ -289,7 +299,15 @@ if(PHOBOS2_DIR)
|
||||
dc(${f} PHOBOS2_O PHOBOS2_BC ${RUNTIME_DIR}/src/ "-I${PHOBOS2_DIR}" ${PHOBOS2_DIR})
|
||||
endforeach(f)
|
||||
|
||||
add_library(phobos2 ${ZLIB_C} ${PHOBOS2_O} ${CORE_O} ${CORE_C} ${GC_O} ${DCRT_O} ${DCRT_C})
|
||||
add_library(phobos2 ${D_LIBRARY_TYPE}
|
||||
${ZLIB_C}
|
||||
${PHOBOS2_O}
|
||||
${CORE_O}
|
||||
${CORE_C}
|
||||
${GC_O}
|
||||
${DCRT_O}
|
||||
${DCRT_C}
|
||||
)
|
||||
add_dependencies(phobos2 runtime)
|
||||
set_target_properties(
|
||||
phobos2 PROPERTIES
|
||||
|
||||
Reference in New Issue
Block a user