mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
Merge branch 'master' into merge-2.070
Conflicts: CMakeLists.txt runtime/druntime runtime/phobos tests/d2/dmd-testsuite
This commit is contained in:
commit
c02f4e7d08
15 changed files with 207 additions and 210 deletions
|
@ -1 +1,2 @@
|
|||
BasedOnStyle: LLVM
|
||||
SortIncludes: false
|
||||
|
|
232
CMakeLists.txt
232
CMakeLists.txt
|
@ -109,82 +109,55 @@ endif()
|
|||
# Setup D compiler flags and linker flags for phobos (system linker) etc. We use
|
||||
# DMD syntax for all the flags so we can work with both DMD and LDMD.
|
||||
set(DDMD_DFLAGS "-wi")
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
append("-g" DDMD_DFLAGS)
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
append("-g -link-debuglib" DDMD_FLAGS)
|
||||
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
|
||||
append("-g -O -inline -release" DDMD_DFLAGS)
|
||||
else()
|
||||
append("-O -release" DDMD_DFLAGS)
|
||||
endif()
|
||||
set(Dcode_LDFLAGS)
|
||||
get_filename_component(D_COMPILER_REALPATH "${D_COMPILER}" REALPATH)
|
||||
get_filename_component(D_COMPILER_PATH "${D_COMPILER_REALPATH}" PATH)
|
||||
if (WIN32)
|
||||
STRING(REGEX REPLACE "/" "\\\\" D_COMPILER_PATH "${D_COMPILER_PATH}")
|
||||
# Default to a Release build type
|
||||
append("-O -inline -release" DDMD_DFLAGS)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
if(${D_COMPILER_ID} STREQUAL "DigitalMars")
|
||||
append("-L${D_COMPILER_PATH}/../lib" Dcode_LDFLAGS)
|
||||
append("-lphobos2" Dcode_LDFLAGS)
|
||||
elseif(${D_COMPILER_ID} STREQUAL "LDMD")
|
||||
append("-L${D_COMPILER_PATH}/../lib" Dcode_LDFLAGS)
|
||||
append("-lphobos2-ldc" Dcode_LDFLAGS)
|
||||
append("-ldruntime-ldc" Dcode_LDFLAGS)
|
||||
append("-ldl -lpthread -lm" Dcode_LDFLAGS)
|
||||
else()
|
||||
message(WARNING "Compiler ID not supported: probably not good!")
|
||||
endif()
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
if(${D_COMPILER_ID} STREQUAL "DigitalMars")
|
||||
append("-L${D_COMPILER_PATH}/../lib64" Dcode_LDFLAGS)
|
||||
append("-L${D_COMPILER_PATH}/../lib32" Dcode_LDFLAGS)
|
||||
append("-lphobos2 -lrt" Dcode_LDFLAGS)
|
||||
elseif(${D_COMPILER_ID} STREQUAL "LDMD")
|
||||
append("-L${D_COMPILER_PATH}/../lib" Dcode_LDFLAGS)
|
||||
append("-lphobos2-ldc" Dcode_LDFLAGS)
|
||||
append("-ldruntime-ldc" Dcode_LDFLAGS)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES ".*BSD" OR CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
append("-lrt -lpthread -lm" Dcode_LDFLAGS)
|
||||
else()
|
||||
append("-lrt -ldl -lpthread -lm" Dcode_LDFLAGS)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Compiler ID not supported: probably not good!")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if(MSVC)
|
||||
if(${D_COMPILER_ID} STREQUAL "DigitalMars")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Let DMD output 64bit object files")
|
||||
append("-m64" DDMD_DFLAGS)
|
||||
append("${D_COMPILER_PATH}\\..\\lib64\\phobos64.lib" Dcode_LDFLAGS)
|
||||
else()
|
||||
message(STATUS "Let DMD output 32bit COFF object files")
|
||||
append("-m32mscoff" DDMD_DFLAGS)
|
||||
append("${D_COMPILER_PATH}\\..\\lib32mscoff\\phobos32mscoff.lib" Dcode_LDFLAGS)
|
||||
endif()
|
||||
elseif(${D_COMPILER_ID} STREQUAL "LDMD")
|
||||
append("${D_COMPILER_PATH}\\..\\lib\\druntime-ldc.lib" Dcode_LDFLAGS)
|
||||
append("${D_COMPILER_PATH}\\..\\lib\\phobos2-ldc.lib" Dcode_LDFLAGS)
|
||||
else()
|
||||
message(WARNING "Compiler ID not supported: probably not good!")
|
||||
|
||||
if(MSVC_VERSION GREATER 1800) # VS 2015+
|
||||
append("-Llegacy_stdio_definitions.lib" DDMD_DFLAGS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# LDC and LDMD are both linked against the dynamic MSVC runtime by
|
||||
# default (due to default CMAKE_C[XX]_FLAGS_*).
|
||||
# Host DMD/LDMD will default to linking against the static MSVC runtime.
|
||||
# So disable some default libs based on CMAKE_C_FLAGS_RELEASE.
|
||||
if(CMAKE_C_FLAGS_RELEASE MATCHES "(^| )[/-]MD( |$)")
|
||||
append("-L/DEFAULTLIB:msvcrt -L/NODEFAULTLIB:libcmt" DDMD_DFLAGS)
|
||||
if(MSVC_VERSION GREATER 1800) # VS 2015+
|
||||
append("-L/NODEFAULTLIB:libvcruntime" DDMD_DFLAGS)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Platform not supported: probably not good!")
|
||||
append("-L/DEFAULTLIB:libcmt -L/NODEFAULTLIB:msvcrt" DDMD_DFLAGS)
|
||||
if(MSVC_VERSION GREATER 1800) # VS 2015+
|
||||
append("-L/NODEFAULTLIB:vcruntime" DDMD_DFLAGS)
|
||||
endif()
|
||||
if(MSVC)
|
||||
append("legacy_stdio_definitions.lib" Dcode_LDFLAGS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
append("-J${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}" DDMD_DFLAGS) # Needed for importing text files
|
||||
string(STRIP "${Dcode_LDFLAGS}" Dcode_LDFLAGS)
|
||||
string(STRIP "${DDMD_DFLAGS}" DDMD_DFLAGS)
|
||||
|
||||
# Use separate compiler flags for the frontend and for the LDC-specific parts,
|
||||
# as enabling warnings on the DMD frontend only leads to a lot of clutter in
|
||||
# the output (LLVM_CXXFLAGS sometimes already includes -Wall).
|
||||
set(DMD_CXXFLAGS)
|
||||
set(LDC_CXXFLAGS)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
|
||||
append("-w" DMD_CXXFLAGS)
|
||||
|
||||
# Disable some noisy warnings:
|
||||
# * -Wunused-parameter triggers for LLVM headers
|
||||
# * -Wmissing-field-initializer leads to reams of warnings in gen/asm-*.h
|
||||
|
@ -218,24 +191,23 @@ elseif(MSVC)
|
|||
# warning C4624: destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted
|
||||
# warning C4800: forcing value to bool 'true' or 'false' (performance warning)
|
||||
# warning C4996: we're not using Microsoft's secure stringOp_s() functions
|
||||
append("/wd4018 /wd4101 /wd4102 /wd4146 /wd4244 /wd4267 /wd4456 /wd4457 /wd4458 /wd4459 /wd4624 /wd4800 /wd4996" DMD_CXXFLAGS LDC_CXXFLAGS)
|
||||
append("/wd4018 /wd4101 /wd4102 /wd4146 /wd4244 /wd4267 /wd4456 /wd4457 /wd4458 /wd4459 /wd4624 /wd4800 /wd4996" LDC_CXXFLAGS)
|
||||
if(LDC_LLVM_VER GREATER 307)
|
||||
# Suppress noisy warning C4141 'modifier' used more than once', because of __forceinline combined with inline in LLVM headers
|
||||
append("/wd4141" DMD_CXXFLAGS LDC_CXXFLAGS)
|
||||
append("/wd4141" LDC_CXXFLAGS)
|
||||
endif()
|
||||
endif()
|
||||
# Append -mminimal-toc for gcc 4.0.x - 4.5.x on ppc64
|
||||
if( CMAKE_COMPILER_IS_GNUCXX
|
||||
AND CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64"
|
||||
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6.0" )
|
||||
append("-mminimal-toc" DMD_CXXFLAGS LDC_CXXFLAGS)
|
||||
append("-mminimal-toc" LDC_CXXFLAGS)
|
||||
endif()
|
||||
# Do not use doubledouble on ppc
|
||||
if( CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|powerpc")
|
||||
append("-mlong-double-64" DMD_CXXFLAGS LDC_CXXFLAGS)
|
||||
append("-mlong-double-64" LDC_CXXFLAGS)
|
||||
endif()
|
||||
if(UNIX)
|
||||
append("-DPOSIX -DLDC_POSIX" DMD_CXXFLAGS)
|
||||
append("-DLDC_POSIX" LDC_CXXFLAGS)
|
||||
endif()
|
||||
set(SANITIZE_CXXFLAGS)
|
||||
|
@ -248,7 +220,6 @@ if(SANITIZE)
|
|||
message(WARNING "Option SANITIZE specified but compiler is not clang.")
|
||||
endif()
|
||||
endif()
|
||||
append("${SANITIZE_CXXFLAGS}" DMD_CXXFLAGS)
|
||||
append("${SANITIZE_CXXFLAGS}" LDC_CXXFLAGS)
|
||||
# LLVM_CXXFLAGS may contain -Werror which causes compile errors with dmd source
|
||||
string(REPLACE "-Werror " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
||||
|
@ -265,13 +236,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||
string(REPLACE "-fcolor-diagnostics " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
||||
endif()
|
||||
|
||||
# Issue 1297
|
||||
# The default system-allocated stack size is 8MB on Linux and Mac, but only 1MB on Windows
|
||||
# Set LDC's stack to 8MB also on Windows:
|
||||
if(WIN32)
|
||||
set(WINDOWS_STACK_SIZE "/STACK:8388608")
|
||||
endif()
|
||||
|
||||
|
||||
# Compiles the given D module into an object file.
|
||||
macro(Dcompile input_d output_dir extra_d_flags outlist_o extra_deps)
|
||||
|
@ -419,12 +383,15 @@ set(DRV_HDR
|
|||
driver/toobj.h
|
||||
driver/tool.h
|
||||
)
|
||||
# exclude idgen, dummy_main, and man.d
|
||||
# exclude idgen and man.d
|
||||
list(REMOVE_ITEM FE_SRC_D
|
||||
${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}/idgen.d
|
||||
${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}/root/dummy_main.d
|
||||
${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}/root/man.d
|
||||
)
|
||||
# exclude ldmd.d from ldc
|
||||
list(REMOVE_ITEM DRV_SRC_D
|
||||
${PROJECT_SOURCE_DIR}/driver/ldmd.d
|
||||
)
|
||||
set(LDC_CXX_SOURCE_FILES
|
||||
${LDC_CXX_GENERATED}
|
||||
${FE_HDR}
|
||||
|
@ -441,20 +408,6 @@ set(LDC_D_SOURCE_FILES
|
|||
${IR_SRC_D}
|
||||
)
|
||||
|
||||
# DMD source files have a .c extension, but are actually C++ code.
|
||||
foreach(file ${LDC_CXX_SOURCE_FILES} ${DRV_SRC} ${DRV_HDR})
|
||||
if(file MATCHES ".*\\.c$")
|
||||
set_source_files_properties(${file} PROPERTIES
|
||||
LANGUAGE CXX
|
||||
COMPILE_FLAGS "${DMD_CXXFLAGS}"
|
||||
)
|
||||
else()
|
||||
set_source_files_properties(${file} PROPERTIES
|
||||
COMPILE_FLAGS "${LDC_CXXFLAGS}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
source_group("Source Files\\${DDMDFE_PATH}" FILES ${FE_SRC_D})
|
||||
source_group("Header Files\\${DDMDFE_PATH}" FILES ${FE_HDR})
|
||||
source_group("Source Files\\gen" FILES ${GEN_SRC})
|
||||
|
@ -561,23 +514,12 @@ set(TEST_COVERAGE OFF CACHE BOOL "instrument compiler for code coverage analysis
|
|||
if(TEST_COVERAGE)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
|
||||
append("-O0 -g -fprofile-arcs -ftest-coverage" EXTRA_CXXFLAGS)
|
||||
append("--coverage" LLVM_LDFLAGS)
|
||||
append("-lgcov" LLVM_LDFLAGS)
|
||||
else()
|
||||
message(WARNING "Coverage testing is not available.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Work around a terrible C++-D interop problem on Windows
|
||||
# See http://forum.dlang.org/post/caowrljxijchgmyyrtlr@forum.dlang.org
|
||||
# ${DMD_DUMMY_MAIN_FOR_EH_SYMBOLS} has to be added to add_executable listing, see e.g. for LDMD
|
||||
#
|
||||
if (WIN32)
|
||||
Dcompilelib(${DDMDFE_PATH}/root/dummy_main.d ${PROJECT_SOURCE_DIR} ${DDMD_DFLAGS} DMD_DUMMY_MAIN_FOR_EH_SYMBOLS)
|
||||
else()
|
||||
set(DMD_DUMMY_MAIN_FOR_EH_SYMBOLS)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Set up the main ldc/ldc2 target.
|
||||
#
|
||||
|
@ -587,29 +529,8 @@ else()
|
|||
set(LDC_LIB_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
# build D source in separate lib
|
||||
set(LDC_D_LIB LDC_D_Shared)
|
||||
foreach(f ${LDC_D_SOURCE_FILES})
|
||||
Dcompile(${f} ${PROJECT_SOURCE_DIR} ${DDMD_DFLAGS} LDC_D_SOURCE_FILES_o "${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d")
|
||||
endforeach()
|
||||
add_library(${LDC_D_LIB} STATIC ${LDC_D_SOURCE_FILES_o})
|
||||
set_target_properties(
|
||||
${LDC_D_LIB} PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
ARCHIVE_OUTPUT_NAME ldcD
|
||||
LIBRARY_OUTPUT_NAME ldcD
|
||||
RUNTIME_OUTPUT_NAME ldcD
|
||||
LINK_FLAGS "${Dcode_LDFLAGS} ${SANITIZE_LDFLAGS}"
|
||||
)
|
||||
if (UNIX)
|
||||
target_link_libraries(${LDC_D_LIB} ${Dcode_LDFLAGS})
|
||||
endif()
|
||||
|
||||
set(LDC_LIB LDCShared)
|
||||
add_library(${LDC_LIB} ${LDC_LIB_TYPE} ${LDC_CXX_SOURCE_FILES})
|
||||
add_library(${LDC_LIB} ${LDC_LIB_TYPE} ${LDC_CXX_SOURCE_FILES} ${DRV_SRC} ${DRV_HDR})
|
||||
set_target_properties(
|
||||
${LDC_LIB} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
|
||||
|
@ -618,10 +539,9 @@ set_target_properties(
|
|||
ARCHIVE_OUTPUT_NAME ldc
|
||||
LIBRARY_OUTPUT_NAME ldc
|
||||
RUNTIME_OUTPUT_NAME ldc
|
||||
COMPILE_FLAGS "${LLVM_CXXFLAGS} ${EXTRA_CXXFLAGS}"
|
||||
COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS} ${EXTRA_CXXFLAGS}"
|
||||
LINK_FLAGS "${SANITIZE_LDFLAGS}"
|
||||
)
|
||||
|
||||
# LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems
|
||||
target_link_libraries(${LDC_LIB} ${LLVM_LIBRARIES} ${PTHREAD_LIBS} ${TERMINFO_LIBS} "${LLVM_LDFLAGS}")
|
||||
if(WIN32)
|
||||
|
@ -630,16 +550,37 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|||
target_link_libraries(${LDC_LIB} dl)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(EXECUTABLE_EXTENSION ".exe")
|
||||
endif()
|
||||
set(LDC_EXE_FULL ${PROJECT_BINARY_DIR}/bin/${LDC_EXE_NAME}${EXECUTABLE_EXTENSION})
|
||||
set(LDMD_EXE_FULL ${PROJECT_BINARY_DIR}/bin/${LDMD_EXE_NAME}${EXECUTABLE_EXTENSION})
|
||||
add_custom_target(${LDC_EXE} ALL DEPENDS ${LDC_EXE_FULL})
|
||||
add_custom_target(${LDMD_EXE} ALL DEPENDS ${LDMD_EXE_FULL})
|
||||
string (REPLACE ";" " " LDC_LINKERFLAG_LIST "${SANITIZE_LDFLAGS} ${WINDOWS_STACK_SIZE} ${LIBCONFIG_LIBRARY} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS}")
|
||||
string (REPLACE "-Wl," "" LDC_LINKERFLAG_LIST ${LDC_LINKERFLAG_LIST})
|
||||
separate_arguments(LDC_LINKERFLAG_LIST WINDOWS_COMMAND ${LDC_LINKERFLAG_LIST})
|
||||
set(tempVar "")
|
||||
FOREACH(f ${LDC_LINKERFLAG_LIST})
|
||||
append("-L${f}" tempVar)
|
||||
ENDFOREACH(f)
|
||||
if(MSVC)
|
||||
# Issue 1297
|
||||
# The default system-allocated stack size is 8MB on Linux and Mac, but only 1MB on Windows
|
||||
# Set LDC's stack to 8MB also on Windows:
|
||||
append("-L/STACK:8388608" tempVar)
|
||||
else()
|
||||
append("-L-lstdc++" tempVar)
|
||||
endif()
|
||||
|
||||
add_executable(${LDC_EXE} ${DRV_SRC} ${DRV_HDR})
|
||||
set_target_properties(
|
||||
${LDC_EXE} PROPERTIES
|
||||
OUTPUT_NAME ${LDC_EXE_NAME}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
|
||||
COMPILE_FLAGS "${LLVM_CXXFLAGS} ${EXTRA_CXXFLAGS}"
|
||||
LINK_FLAGS "${Dcode_LDFLAGS} ${SANITIZE_LDFLAGS} ${WINDOWS_STACK_SIZE}"
|
||||
separate_arguments(LDC_FLAG_LIST WINDOWS_COMMAND "${tempVar} ${D_COMPILER_FLAGS} ${DDMD_DFLAGS}")
|
||||
add_custom_command(
|
||||
OUTPUT ${LDC_EXE_FULL}
|
||||
COMMAND ${D_COMPILER} -L$<TARGET_LINKER_FILE:${LDC_LIB}> ${LDC_FLAG_LIST} -I${PROJECT_SOURCE_DIR}/${DDMDFE_PATH} -of${LDC_EXE_FULL} ${LDC_D_SOURCE_FILES}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
DEPENDS ${LDC_D_SOURCE_FILES} ${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d ${LDC_LIB}
|
||||
)
|
||||
target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LDC_D_LIB} ${LDC_LIB} ${LIBCONFIG_LIBRARY} ${PTHREAD_LIBS} ${CMAKE_DL_LIBS} ${TERMINFO_LIBS} ${DMD_DUMMY_MAIN_FOR_EH_SYMBOLS})
|
||||
|
||||
|
||||
if(MSVC_IDE)
|
||||
# the IDE generator is a multi-config one
|
||||
|
@ -714,26 +655,24 @@ endif()
|
|||
|
||||
set_source_files_properties(driver/exe_path.cpp driver/ldmd.cpp driver/response.cpp PROPERTIES
|
||||
COMPILE_FLAGS "${LDC_CXXFLAGS} ${LLVM_CXXFLAGS}"
|
||||
)
|
||||
|
||||
Dcompile(${DDMDFE_PATH}/root/man.d ${PROJECT_SOURCE_DIR} ${DDMD_DFLAGS} LDMD_D_o "")
|
||||
|
||||
add_executable(${LDMD_EXE} driver/exe_path.cpp driver/ldmd.cpp driver/response.cpp driver/exe_path.h ${LDMD_D_o} ${DMD_DUMMY_MAIN_FOR_EH_SYMBOLS})
|
||||
set_target_properties(${LDMD_EXE} PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
COMPILE_DEFINITIONS LDC_EXE_NAME="${LDC_EXE_NAME}"
|
||||
LINK_FLAGS "${Dcode_LDFLAGS} ${SANITIZE_LDFLAGS}"
|
||||
OUTPUT_NAME "${LDMD_EXE_NAME}"
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
|
||||
)
|
||||
# Same as above, LLVM_LDFLAGS should really be in LINK_FLAGS, but the LLVM libs
|
||||
# use symbols from libdl, ..., so LLVM_LDFLAGS must come _after_ them in the
|
||||
# command line. Maybe this could be improved using library groups, at least with
|
||||
# GNU ld.
|
||||
target_link_libraries(${LDMD_EXE} ${LLVM_LIBRARIES} ${PTHREAD_LIBS} ${TERMINFO_LIBS} ${CMAKE_DL_LIBS} "${LLVM_LDFLAGS}" ${DMD_DUMMY_MAIN_FOR_EH_SYMBOLS})
|
||||
if (UNIX)
|
||||
target_link_libraries(${LDMD_EXE} "${Dcode_LDFLAGS}")
|
||||
endif()
|
||||
|
||||
add_library(LDMD_CXX_LIB ${LDC_LIB_TYPE} driver/exe_path.cpp driver/ldmd.cpp driver/response.cpp driver/exe_path.h)
|
||||
set_target_properties(
|
||||
LDMD_CXX_LIB PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
ARCHIVE_OUTPUT_NAME ldmd
|
||||
LIBRARY_OUTPUT_NAME ldmd
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${LDMD_EXE_FULL}
|
||||
COMMAND ${D_COMPILER} -L$<TARGET_LINKER_FILE:LDMD_CXX_LIB> ${LDC_FLAG_LIST} -I${PROJECT_SOURCE_DIR}/${DDMDFE_PATH} -of${LDMD_EXE_FULL} ${DDMDFE_PATH}/root/man.d driver/ldmd.d
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
DEPENDS LDMD_CXX_LIB ${LDC_LIB}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Test and runtime targets. Note that enable_testing() is order-sensitive!
|
||||
|
@ -749,9 +688,10 @@ add_subdirectory(tests)
|
|||
# Install target.
|
||||
#
|
||||
|
||||
install(TARGETS ${LDC_EXE} ${LDMD_EXE} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(PROGRAMS ${LDC_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(PROGRAMS ${LDMD_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
if(${BUILD_SHARED})
|
||||
# For now, only install libldc if explicitely building the shared library.
|
||||
# For now, only install libldc if explicitly building the shared library.
|
||||
# While it might theoretically be possible to use LDC as a static library
|
||||
# as well, for the time being this just bloats the normal packages.
|
||||
install(TARGETS ${LDC_LIB} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
|
|
|
@ -45,10 +45,6 @@ install:
|
|||
- cd libconfig
|
||||
- git checkout 7585cf6
|
||||
- cd ..
|
||||
# dmd-testsuite: Merge `windows` branch
|
||||
- cd ldc\tests\d2\dmd-testsuite
|
||||
- git merge origin/windows
|
||||
- cd ..\..\..\..
|
||||
# Download & extract libcurl
|
||||
- ps: Start-FileDownload 'http://d.darktech.org/libcurl-7.47.0-WinSSL-zlib-x86-x64.zip' -FileName 'libcurl.zip'
|
||||
- md libcurl
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// A MASSIVE hack imho.
|
||||
// See http://forum.dlang.org/post/caowrljxijchgmyyrtlr@forum.dlang.org
|
||||
// This is needed on Windows to solve unresolved external symbol _deh_beg and _deh_end linker errors.
|
||||
version (Windows)
|
||||
{
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1044,7 +1044,10 @@ static size_t addStrlen(size_t acc, const char *str) {
|
|||
return acc + strlen(str);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// In driver/main.d
|
||||
int main(int argc, char **argv);
|
||||
|
||||
int cppmain(int argc, char **argv) {
|
||||
exe_path::initialize(argv[0], reinterpret_cast<void *>(main));
|
||||
|
||||
std::string ldcExeName = LDC_EXE_NAME;
|
||||
|
|
30
driver/ldmd.d
Normal file
30
driver/ldmd.d
Normal file
|
@ -0,0 +1,30 @@
|
|||
//===-- driver/ldmd.d - General LLVM codegen helpers ----------*- D -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Startup code for driver/ldmd.cpp
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// In driver/ldmd.cpp
|
||||
extern(C++) int cppmain(int argc, char **argv);
|
||||
|
||||
/+ Having a main() in D-source solves a few issues with building/linking with
|
||||
+ DMD on Windows, with the extra benefit of implicitly initializing the D runtime.
|
||||
+/
|
||||
int main()
|
||||
{
|
||||
// For now, even just the frontend does not work with GC enabled, so we need
|
||||
// to disable it entirely.
|
||||
import core.memory;
|
||||
GC.disable();
|
||||
|
||||
import core.runtime;
|
||||
auto args = Runtime.cArgs();
|
||||
return cppmain(args.argc, cast(char**)args.argv);
|
||||
}
|
|
@ -72,7 +72,6 @@ int rt_init();
|
|||
void gendocfile(Module *m);
|
||||
|
||||
// In driver/main.d
|
||||
void disableGC();
|
||||
void writeModuleDependencyFile();
|
||||
|
||||
using namespace opts;
|
||||
|
@ -283,6 +282,7 @@ static void hideLLVMOptions() {
|
|||
#endif
|
||||
}
|
||||
|
||||
// In driver/main.d
|
||||
int main(int argc, char **argv);
|
||||
|
||||
static const char *tryGetExplicitConfFile(int argc, char **argv) {
|
||||
|
@ -912,18 +912,9 @@ static void emitJson(Modules &modules) {
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int cppmain(int argc, char **argv) {
|
||||
llvm::sys::PrintStackTraceOnErrorSignal();
|
||||
|
||||
// Initialize the D runtime.
|
||||
// TODO: We might want to call rt_term() using an atexit handler or so to
|
||||
// run module destructors, etc.
|
||||
rt_init();
|
||||
|
||||
// For now, even just the frontend does not work with GC enabled, so we need
|
||||
// to disable it entirely.
|
||||
disableGC();
|
||||
|
||||
exe_path::initialize(argv[0], reinterpret_cast<void *>(main));
|
||||
|
||||
global._init();
|
||||
|
|
|
@ -17,12 +17,6 @@ import ddmd.globals;
|
|||
import ddmd.root.file;
|
||||
import ddmd.root.outbuffer;
|
||||
|
||||
extern (C++) void disableGC()
|
||||
{
|
||||
import core.memory;
|
||||
GC.disable();
|
||||
}
|
||||
|
||||
extern (C++) void writeModuleDependencyFile()
|
||||
{
|
||||
if (global.params.moduleDepsFile !is null)
|
||||
|
@ -33,3 +27,21 @@ extern (C++) void writeModuleDependencyFile()
|
|||
deps.write();
|
||||
}
|
||||
}
|
||||
|
||||
// In driver/main.cpp
|
||||
extern(C++) int cppmain(int argc, char **argv);
|
||||
|
||||
/+ Having a main() in D-source solves a few issues with building/linking with
|
||||
+ DMD on Windows, with the extra benefit of implicitly initializing the D runtime.
|
||||
+/
|
||||
int main()
|
||||
{
|
||||
// For now, even just the frontend does not work with GC enabled, so we need
|
||||
// to disable it entirely.
|
||||
import core.memory;
|
||||
GC.disable();
|
||||
|
||||
import core.runtime;
|
||||
auto args = Runtime.cArgs();
|
||||
return cppmain(args.argc, cast(char**)args.argv);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "enum.h"
|
||||
#include "id.h"
|
||||
#include "init.h"
|
||||
#include "nspace.h"
|
||||
#include "rmem.h"
|
||||
#include "template.h"
|
||||
#include "gen/classes.h"
|
||||
|
@ -133,6 +134,18 @@ public:
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void visit(Nspace *ns) LLVM_OVERRIDE {
|
||||
IF_LOG Logger::println("Nspace::codegen for %s", ns->toPrettyChars());
|
||||
LOG_SCOPE
|
||||
|
||||
if (!isError(ns) && ns->members) {
|
||||
for (auto sym : *ns->members)
|
||||
sym->accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void visit(InterfaceDeclaration *decl) LLVM_OVERRIDE {
|
||||
IF_LOG Logger::println("InterfaceDeclaration::codegen: '%s'",
|
||||
decl->toPrettyChars());
|
||||
|
|
|
@ -10,12 +10,6 @@
|
|||
#include "gen/runtime.h"
|
||||
#include "aggregate.h"
|
||||
#include "dsymbol.h"
|
||||
#include "tokens.h"
|
||||
#include "ldcbindings.h"
|
||||
#include "mars.h"
|
||||
#include "module.h"
|
||||
#include "mtype.h"
|
||||
#include "root.h"
|
||||
#include "gen/abi.h"
|
||||
#include "gen/attributes.h"
|
||||
#include "gen/functions.h"
|
||||
|
@ -27,11 +21,17 @@
|
|||
#include "ir/irfunction.h"
|
||||
#include "ir/irtype.h"
|
||||
#include "ir/irtypefunction.h"
|
||||
#include "ldcbindings.h"
|
||||
#include "mars.h"
|
||||
#include "module.h"
|
||||
#include "mtype.h"
|
||||
#include "root.h"
|
||||
#include "tokens.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -254,6 +254,13 @@ static void createFwdDecl(LINK linkage, Type *returntype,
|
|||
|
||||
fn->setAttributes(attrs);
|
||||
|
||||
// On x86_64, always set 'uwtable' for System V ABI compatibility.
|
||||
// FIXME: Move to better place (abi-x86-64.cpp?)
|
||||
// NOTE: There are several occurances if this line.
|
||||
if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) {
|
||||
fn->addFnAttr(LLAttribute::UWTable);
|
||||
}
|
||||
|
||||
fn->setCallingConv(gABI->callingConv(fn->getFunctionType(), linkage));
|
||||
}
|
||||
}
|
||||
|
@ -298,10 +305,18 @@ static void buildRuntimeModule() {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Construct some attribute lists used below (possibly multiple times)
|
||||
AttrSet NoAttrs, Attr_NoAlias(NoAttrs, 0, llvm::Attribute::NoAlias),
|
||||
Attr_NoUnwind(NoAttrs, ~0U, llvm::Attribute::NoUnwind),
|
||||
Attr_ReadOnly(NoAttrs, ~0U, llvm::Attribute::ReadOnly),
|
||||
Attr_ReadOnly_NoUnwind(Attr_ReadOnly, ~0U, llvm::Attribute::NoUnwind),
|
||||
AttrSet NoAttrs, Attr_NoAlias(NoAttrs, llvm::AttributeSet::ReturnIndex,
|
||||
llvm::Attribute::NoAlias),
|
||||
Attr_NoUnwind(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::NoUnwind),
|
||||
Attr_ReadOnly(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::ReadOnly),
|
||||
Attr_Cold(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::Cold),
|
||||
Attr_Cold_NoReturn(Attr_Cold, llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::NoReturn),
|
||||
Attr_ReadOnly_NoUnwind(Attr_ReadOnly, llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::NoUnwind),
|
||||
Attr_ReadOnly_1_NoCapture(Attr_ReadOnly, 1, llvm::Attribute::NoCapture),
|
||||
Attr_ReadOnly_1_3_NoCapture(Attr_ReadOnly_1_NoCapture, 3,
|
||||
llvm::Attribute::NoCapture),
|
||||
|
@ -321,17 +336,18 @@ static void buildRuntimeModule() {
|
|||
// void _d_assert(string file, uint line)
|
||||
// void _d_arraybounds(string file, uint line)
|
||||
createFwdDecl(LINKc, Type::tvoid, {"_d_assert", "_d_arraybounds"},
|
||||
{stringTy, uintTy});
|
||||
{stringTy, uintTy}, {}, Attr_Cold_NoReturn);
|
||||
|
||||
// void _d_assert_msg(string msg, string file, uint line)
|
||||
createFwdDecl(LINKc, voidTy, {"_d_assert_msg"}, {stringTy, stringTy, uintTy});
|
||||
createFwdDecl(LINKc, voidTy, {"_d_assert_msg"}, {stringTy, stringTy, uintTy},
|
||||
{}, Attr_Cold_NoReturn);
|
||||
|
||||
// void _d_assertm(immutable(ModuleInfo)* m, uint line)
|
||||
// void _d_array_bounds(immutable(ModuleInfo)* m, uint line)
|
||||
// void _d_switch_error(immutable(ModuleInfo)* m, uint line)
|
||||
createFwdDecl(LINKc, voidTy,
|
||||
{"_d_assertm", "_d_array_bounds", "_d_switch_error"},
|
||||
{moduleInfoPtrTy, uintTy}, {STCimmutable, 0});
|
||||
createFwdDecl(
|
||||
LINKc, voidTy, {"_d_assertm", "_d_array_bounds", "_d_switch_error"},
|
||||
{moduleInfoPtrTy, uintTy}, {STCimmutable, 0}, Attr_Cold_NoReturn);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -16,7 +16,7 @@ set(D_FLAGS -w;-d CACHE STRING
|
|||
set(D_FLAGS_DEBUG -g;-link-debuglib CACHE STRING "Runtime build flags (debug libraries), separated by ;")
|
||||
set(D_FLAGS_RELEASE -O3;-release CACHE STRING "Runtime build flags (release libraries), separated by ;")
|
||||
if(MSVC)
|
||||
set(LINK_WITH_MSVCRT ON CACHE BOOL "Link with MSVCRT.lib (DLL) instead of LIBCMT.lib (static)")
|
||||
set(LINK_WITH_MSVCRT OFF CACHE BOOL "Link with MSVCRT.lib (DLL) instead of LIBCMT.lib (static)")
|
||||
endif()
|
||||
|
||||
# Note: In the below building helpers, this is more fittingly called
|
||||
|
@ -254,6 +254,11 @@ if(MSVC)
|
|||
if(NOT CMAKE_C_FLAGS_RELEASE MATCHES "(^| )[/-]MT( |$)")
|
||||
append("/MT" CMAKE_C_FLAGS_RELEASE)
|
||||
endif()
|
||||
else()
|
||||
string(REGEX REPLACE "(^| )[/-]MT( |$)" "\\2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
if(NOT CMAKE_C_FLAGS_RELEASE MATCHES "(^| )[/-]MD( |$)")
|
||||
append("/MD" CMAKE_C_FLAGS_RELEASE)
|
||||
endif()
|
||||
endif()
|
||||
# warning C4996: zlib uses 'deprecated' POSIX names
|
||||
append("/wd4996" CMAKE_C_FLAGS_RELEASE)
|
||||
|
@ -301,10 +306,11 @@ macro(dc input_d d_flags output_dir output_suffix outlist_o outlist_bc)
|
|||
add_custom_command(
|
||||
OUTPUT
|
||||
${outfiles}
|
||||
COMMAND ${LDC_EXE} ${dc_flags} -c -I${RUNTIME_DIR}/src -I${RUNTIME_DIR}/src/gc ${input_d} -of${output_o} ${d_flags}
|
||||
COMMAND ${LDC_EXE_FULL} ${dc_flags} -c -I${RUNTIME_DIR}/src -I${RUNTIME_DIR}/src/gc ${input_d} -of${output_o} ${d_flags}
|
||||
WORKING_DIRECTORY ${PROJECT_PARENT_DIR}
|
||||
DEPENDS ${input_d}
|
||||
${LDC_EXE}
|
||||
${LDC_EXE_FULL}
|
||||
${GCCBUILTINS}
|
||||
${PROJECT_BINARY_DIR}/../bin/${LDC_EXE}.conf
|
||||
)
|
||||
|
@ -617,7 +623,7 @@ macro(build_test_runner name_suffix d_flags c_flags)
|
|||
|
||||
set(libarg "druntime-ldc-unittest${name_suffix}")
|
||||
add_test(NAME build-druntime-test-runner${name_suffix}
|
||||
COMMAND ${LDC_EXE}
|
||||
COMMAND ${LDC_EXE_FULL}
|
||||
-of${PROJECT_BINARY_DIR}/druntime-test-runner${name_suffix}${CMAKE_EXECUTABLE_SUFFIX}
|
||||
-defaultlib=${libarg} -debuglib=${libarg}
|
||||
-singleobj ${flags} ${RUNTIME_DIR}/src/test_runner.d
|
||||
|
@ -628,7 +634,7 @@ macro(build_test_runner name_suffix d_flags c_flags)
|
|||
if(PHOBOS2_DIR)
|
||||
set(libarg "phobos2-ldc-unittest${name_suffix},druntime-ldc-unittest${name_suffix}")
|
||||
add_test(NAME build-phobos2-test-runner${name_suffix}
|
||||
COMMAND ${LDC_EXE}
|
||||
COMMAND ${LDC_EXE_FULL}
|
||||
-of${PROJECT_BINARY_DIR}/phobos2-test-runner${name_suffix}${CMAKE_EXECUTABLE_SUFFIX}
|
||||
-L--no-as-needed -defaultlib=${libarg} -debuglib=${libarg}
|
||||
-singleobj ${flags} ${RUNTIME_DIR}/src/test_runner.d
|
||||
|
@ -665,7 +671,7 @@ macro(build_test_runner name_suffix d_flags c_flags)
|
|||
--build ${CMAKE_BINARY_DIR} --target druntime-ldc-unittest${name_suffix})
|
||||
|
||||
add_test(NAME build-druntime-test-runner${name_suffix}
|
||||
COMMAND ${LDC_EXE}
|
||||
COMMAND ${LDC_EXE_FULL}
|
||||
-of${PROJECT_BINARY_DIR}/druntime-test-runner${name_suffix}${CMAKE_EXECUTABLE_SUFFIX}
|
||||
-defaultlib=${druntime-casm} -debuglib=${druntime-casm}
|
||||
-singleobj ${flags} ${druntime_o} ${RUNTIME_DIR}/src/test_runner.d
|
||||
|
@ -696,7 +702,7 @@ macro(build_test_runner name_suffix d_flags c_flags)
|
|||
--build ${CMAKE_BINARY_DIR} --target phobos2-ldc-unittest${name_suffix})
|
||||
|
||||
add_test(NAME build-phobos2-test-runner${name_suffix}
|
||||
COMMAND ${LDC_EXE}
|
||||
COMMAND ${LDC_EXE_FULL}
|
||||
-of${PROJECT_BINARY_DIR}/phobos2-test-runner${name_suffix}${CMAKE_EXECUTABLE_SUFFIX}
|
||||
-defaultlib=druntime-ldc,${phobos2-casm} -debuglib=druntime-ldc,${phobos2-casm}
|
||||
-singleobj ${flags} ${phobos2_o} ${RUNTIME_DIR}/src/test_runner.d
|
||||
|
@ -761,7 +767,6 @@ endif()
|
|||
# Add the standalone druntime tests.
|
||||
# TODO: Add test/excetions and test/init_fini.
|
||||
if(BUILD_SHARED_LIBS)
|
||||
get_property(ldmd_path TARGET ldmd2 PROPERTY LOCATION)
|
||||
get_property(druntime_path TARGET druntime-ldc PROPERTY LOCATION)
|
||||
set(outdir ${PROJECT_BINARY_DIR}/druntime-test-shared)
|
||||
|
||||
|
@ -769,7 +774,7 @@ if(BUILD_SHARED_LIBS)
|
|||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${outdir})
|
||||
add_test(NAME druntime-test-shared
|
||||
COMMAND make -C ${PROJECT_SOURCE_DIR}/druntime/test/shared
|
||||
ROOT=${outdir} DMD=${ldmd_path} MODEL=default DRUNTIMESO=${druntime_path}
|
||||
ROOT=${outdir} DMD=${LDMD_EXE_FULL} MODEL=default DRUNTIMESO=${druntime_path}
|
||||
CFLAGS=-Wall\ -Wl,-rpath,${CMAKE_BINARY_DIR}/lib LINKDL=-L-ldl
|
||||
)
|
||||
set_tests_properties(druntime-test-shared PROPERTIES DEPENDS clean-druntime-test-shared)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 15750052ac97f4c1ac3ecb526da2068a90337a42
|
||||
Subproject commit 8438312451713a6e80f53efde0adb17ff3d0a535
|
|
@ -1 +1 @@
|
|||
Subproject commit 02fdbce62c8c62813b61df10267ad31ed05208f7
|
||||
Subproject commit 85ffe9dd02a228db502e65dca29ed9d28adef221
|
|
@ -17,7 +17,7 @@ function(add_testsuite config_name dflags model)
|
|||
# testsuite build system provides no way to run the test cases with a
|
||||
# given set of flags without trying all combinations of them.
|
||||
add_test(NAME ${name}
|
||||
COMMAND make -k -C ${PROJECT_SOURCE_DIR}/tests/d2/dmd-testsuite RESULTS_DIR=${outdir} DMD=$<TARGET_FILE:ldmd2> DFLAGS=${dflags} MODEL=${model} quick
|
||||
COMMAND make -k -C ${PROJECT_SOURCE_DIR}/tests/d2/dmd-testsuite RESULTS_DIR=${outdir} DMD=${LDMD_EXE_FULL} DFLAGS=${dflags} MODEL=${model} quick
|
||||
)
|
||||
set_tests_properties(${name} PROPERTIES DEPENDS clean-${name})
|
||||
endfunction()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f5cbe7532f9ce5049ab8eb803f414f6009e00e6
|
||||
Subproject commit d006abf3c861c6f07069e1004ea545d7a464961a
|
Loading…
Add table
Add a link
Reference in a new issue