From 81eded2eced83b22ef02c1ffacf369181db1c5cf Mon Sep 17 00:00:00 2001 From: elrood Date: Sun, 30 Nov 2008 19:19:39 +0100 Subject: [PATCH] when building the runtime pass -fPIC for shared libs and -disable-invariants for gc --- bin/ldc2.conf | 2 -- ldc2.conf.in | 2 -- runtime/CMakeLists.txt | 19 +++++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bin/ldc2.conf b/bin/ldc2.conf index 5acb7251..414f6711 100644 --- a/bin/ldc2.conf +++ b/bin/ldc2.conf @@ -1,4 +1,2 @@ - [Environment] - DFLAGS=-I%@P%/../druntime/import -L-L%@P%/../druntime/lib diff --git a/ldc2.conf.in b/ldc2.conf.in index 23043052..b0955e65 100644 --- a/ldc2.conf.in +++ b/ldc2.conf.in @@ -1,4 +1,2 @@ - [Environment] - DFLAGS=-I@RUNTIME_DIR@/import -L-L@RUNTIME_DIR@/lib diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 7a741e5b..f9272664 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -12,6 +12,11 @@ option(BUILD_BC_LIBS "build the runtime as bytecode libraries") option(BUILD_SINGLE_LIB "build single runtime library" ON) set(D_FLAGS -g -w -d CACHE STRING "runtime build flags, separated by ;") +if(BUILD_SHARED_LIBS) + list(APPEND D_FLAGS -fPIC) +endif(BUILD_SHARED_LIBS) + +# build tango for D1, druntime for D2 if(D_VERSION EQUAL 1) set(RUNTIME tango) elseif(D_VERSION EQUAL 2) @@ -23,7 +28,6 @@ get_directory_property(PROJECT_PARENT_DIR DIRECTORY ${PROJECT_SOURCE_DIR} PARENT set(RUNTIME_DIR ${PROJECT_PARENT_DIR}/${RUNTIME} CACHE PATH "runtime source dir" FORCE) if(D_VERSION EQUAL 1) - # build tango for D1, druntime for D2 set(LDC_EXE ldc) # copy imports to runtime dir add_custom_command( @@ -53,8 +57,6 @@ elseif(D_VERSION EQUAL 2) set(RUNTIME_GC_DIR ${RUNTIME_DIR}/src/gc/basic) file(GLOB CORE_D ${RUNTIME_DIR}/src/common/core/*.d) file(GLOB CORE_C ${RUNTIME_DIR}/src/common/core/stdc/*.c) -else(D_VERSION EQUAL 1) - message(FATAL_ERROR "set d version to 1 or 2") endif(D_VERSION EQUAL 1) # should only be necessary if run independently from ldc cmake project @@ -85,6 +87,7 @@ else(NOT PATCH_EXE) COMMAND ${PATCH_EXE} -t -N -p0 -i ${PROJECT_SOURCE_DIR}/${LDC_EXE}.diff WORKING_DIRECTORY ${RUNTIME_DIR} ) + # rebuild cache to include sources added by patch add_custom_command( OUTPUT recache COMMAND ${CMAKE_COMMAND} -H${PROJECT_PARENT_DIR} -B${PROJECT_BINARY_DIR}/.. @@ -97,7 +100,7 @@ file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d) file(GLOB DCRT_C ${RUNTIME_DC_DIR}/*.c) # compile d file into outdir, include incdir, and append names of generated .o and .bc to outlist_o and _bc -macro(dc INPUT_D OUTLIST_O OUTLIST_BC OUTDIR INCDIR) +macro(dc INPUT_D OUTLIST_O OUTLIST_BC OUTDIR INCDIR MOREFLAGS) get_filename_component(BASENAME ${INPUT_D} NAME_WE) set(OUTPUT_O ${PROJECT_BINARY_DIR}/${OUTDIR}/${BASENAME}.o) set(OUTPUT_BC ${PROJECT_BINARY_DIR}/${OUTDIR}/${BASENAME}.bc) @@ -107,22 +110,22 @@ macro(dc INPUT_D OUTLIST_O OUTLIST_BC OUTDIR INCDIR) OUTPUT ${OUTPUT_O} ${OUTPUT_BC} - COMMAND ${LDC_LOC} -c -I${INCDIR} -output-bc ${INPUT_D} -of${OUTPUT_O} ${D_FLAGS} + COMMAND ${LDC_LOC} -c -I${INCDIR} -output-bc ${INPUT_D} -of${OUTPUT_O} ${D_FLAGS} ${MOREFLAGS} DEPENDS ${LDC_LOC} ) endmacro(dc) # dc_dir include for core and gc only necessary with druntime foreach(f ${CORE_D}) - dc(${f} CORE_O CORE_BC core ${RUNTIME_DC_DIR}) + dc(${f} CORE_O CORE_BC core ${RUNTIME_DC_DIR} "") endforeach(f) foreach(f ${GC_D}) - dc(${f} GC_O GC_BC gc "${RUNTIME_GC_DIR} ${RUNTIME_DC_DIR}") + dc(${f} GC_O GC_BC gc "${RUNTIME_GC_DIR} ${RUNTIME_DC_DIR}" "-disable-invariants") endforeach(f) foreach(f ${DCRT_D}) - dc(${f} DCRT_O DCRT_BC dcrt ${RUNTIME_DC_DIR}) + dc(${f} DCRT_O DCRT_BC dcrt ${RUNTIME_DC_DIR} "") endforeach(f) if(BUILD_SINGLE_LIB)