Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/3-build-cross/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ runs:
--buildDir="build-cross-libs" \
--dFlags="${DFLAGS// /;}" \
--ldcSrcDir="$PWD/ldc" \
CMAKE_INSTALL_PREFIX="$PWD/install" \
INCLUDE_INSTALL_DIR="$PWD/install/import" \
"${flags[@]}"

- name: Cross-compile LDC executables
Expand All @@ -155,4 +157,3 @@ runs:
${{ inputs.cmake_flags }}
${{ inputs.with_pgo == 'true' && '-DDFLAGS_LDC=-fprofile-use=../pgo-ldc/merged.profdata' || '' }}
${{ env.CROSS_CMAKE_FLAGS }}
build_targets: ldc2 ldmd2 ldc-build-runtime ldc-build-plugin ldc-profdata ldc-profgen ldc-prune-cache timetrace2txt
24 changes: 12 additions & 12 deletions .github/actions/5-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ runs:
if [[ '${{ inputs.cross_compiling }}' != true ]]; then
ninja -C build install >/dev/null
else
mkdir -p install/bin
cp build-cross/bin/{ldc2,ldmd2,ldc-build-runtime,ldc-profdata,ldc-profgen,ldc-prune-cache,timetrace2txt} install/bin/
cp build-cross/bin/ldc-build-plugin install/bin/ || true
# populate first subdirs by installing the cross-compiled compiler:
# * bin/: executables
# * lib/: LTO plugin and compiler-rt libs only
# * etc/bash_completion.d/
# * import/: missing ldc/gccbuiltins_*.di
ninja -C build-cross install

cp -R build-cross-libs/lib install/
cp build-cross/lib/{libldc_rt.*,libLTO.dylib,LLVMgold-ldc.so} install/lib/ || true
# install the cross-compiled libs to populate:
# * lib/: runtime library artifacts
# * etc/ldc2.conf
ninja -C build-cross-libs install

mkdir install/etc
cp build-cross/bin/ldc2_install.conf install/etc/ldc2.conf
cp -R ldc/packaging/bash_completion.d install/etc/

# use imports from installed bootstrap compiler
ninja -C bootstrap-ldc install >/dev/null
mv bootstrap-install/import install/
# copy gccbuiltins from bootstrap compiler
cp bootstrap-ldc/import/ldc/gccbuiltins_*.di install/import/ldc/
fi

cp ldc/LICENSE install/
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@ jobs:
arch: x86_64
- name: Build bootstrap LDC
uses: ./.github/actions/2-build-bootstrap
with:
# prepare for installing the bootstrap compiler to ../bootstrap-install/
cmake_flags: >-
-DCMAKE_INSTALL_PREFIX="$PWD/../bootstrap-install"
-DINCLUDE_INSTALL_DIR="$PWD/../bootstrap-install/import"
- name: Build LDC with PGO instrumentation & gather profile from compiling default libs
if: matrix.with_pgo
uses: ./.github/actions/2a-build-pgo
Expand Down
64 changes: 59 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ endif()
set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
set(CONF_INST_DIR ${SYSCONF_INSTALL_DIR} CACHE PATH "Directory ldc.conf is installed to")
set(CONF_INST_DIR ${SYSCONF_INSTALL_DIR} CACHE PATH "Directory ldc2.conf is installed to")
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/d CACHE PATH "Path to install D modules to")

# Note: LIB_SUFFIX should perhaps be renamed to LDC_LIBDIR_SUFFIX.
set(LIB_SUFFIX "" CACHE STRING "Appended to the library installation directory. Set to '64' to install libraries into ${PREFIX}/lib64.")
Expand Down Expand Up @@ -720,7 +721,7 @@ if(MSVC_IDE)
# the IDE generator is a multi-config one
# so copy the config file into the correct bin subfolder
# (different outputs no longer feasible for custom commands, so disabled)
# add_custom_command(TARGET ${LDC_EXE} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.conf $<TARGET_FILE_DIR:${LDC_EXE}> COMMENT "Copy config file ${LDC_EXE}.conf")
# add_custom_command(TARGET ${LDC_EXE} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/etc/${LDC_EXE}.conf $<TARGET_FILE_DIR:${LDC_EXE}> COMMENT "Copy config file ${LDC_EXE}.conf")
endif()


Expand Down Expand Up @@ -910,6 +911,42 @@ endif()
#
add_subdirectory(utils)

# auto-generate ldc/gccbuiltins_*.di headers, depending on LLVM version and enabled LLVM backends
set(GCCBUILTINS "")
if(TARGET gen_gccbuiltins)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/import/ldc")

function(gen_gccbuiltins name)
set(module "${PROJECT_BINARY_DIR}/import/ldc/gccbuiltins_${name}.di")
if (GCCBUILTINS STREQUAL "")
set(GCCBUILTINS "${module}" PARENT_SCOPE)
else()
set(GCCBUILTINS "${GCCBUILTINS};${module}" PARENT_SCOPE)
endif()
add_custom_command(
OUTPUT ${module}
COMMAND gen_gccbuiltins ${module} "${name}"
DEPENDS gen_gccbuiltins
)
endfunction()

set(target_arch "AArch64;AMDGPU;ARM;Mips;RISCV;NVPTX;PowerPC;SystemZ;X86")
set(target_name "aarch64;amdgcn;arm;mips;riscv;nvvm;ppc;s390;x86")

foreach(target ${LLVM_TARGETS_TO_BUILD})
list(FIND target_arch ${target} idx)
if(idx GREATER -1)
list(GET target_name ${idx} name)
gen_gccbuiltins(${name})
endif()
endforeach()

add_custom_target(gccbuiltins DEPENDS ${GCCBUILTINS})

# make sure they are generated when building the compiler (as link-time dependency)
add_dependencies(${LDC_EXE} gccbuiltins)
endif()

#
# Auxiliary tools.
#
Expand Down Expand Up @@ -939,11 +976,18 @@ add_test(NAME build-ldc2-unittest COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BIN
add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)

if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
set(_LDC_BUILD_RUNTIME_DEFAULT ON)
if(CMAKE_CROSSCOMPILING)
set(_LDC_BUILD_RUNTIME_DEFAULT OFF)
endif()
option(LDC_BUILD_RUNTIME "Build the runtime libraries" ${_LDC_BUILD_RUNTIME_DEFAULT})

if(LDC_BUILD_RUNTIME)
add_subdirectory(runtime)
else()
message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
message(STATUS "NOT building the runtime libraries (LDC_BUILD_RUNTIME=OFF)")
endif()

if(D_VERSION EQUAL 2)
add_subdirectory(tests/dmd)
endif()
Expand Down Expand Up @@ -978,7 +1022,6 @@ if(${BUILD_SHARED})
# as well, for the time being this just bloats the normal packages.
install(TARGETS ${LDC_LIB} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
endif()
install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.conf DESTINATION ${CONF_INST_DIR} RENAME ${LDC_EXE}.conf)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(NOT DEFINED BASH_COMPLETION_COMPLETIONSDIR)
Expand All @@ -993,6 +1036,17 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(DIRECTORY packaging/bash_completion.d/ DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR})
endif()

# imports/includes
install(FILES runtime/druntime/src/object.d runtime/druntime/src/__importc_builtins.di runtime/druntime/src/importc.h DESTINATION ${INCLUDE_INSTALL_DIR})
foreach(p core etc ldc)
install(DIRECTORY runtime/druntime/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
install(DIRECTORY runtime/druntime/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
endforeach()
install(DIRECTORY runtime/phobos/std DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
install(DIRECTORY runtime/phobos/etc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
install(DIRECTORY runtime/jit-rt/d/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
install(FILES ${GCCBUILTINS} DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)

#
# Packaging
#
Expand Down
2 changes: 1 addition & 1 deletion ldc2.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ default:
// default switches appended after all explicit command-line switches
post-switches = [
"-I@RUNTIME_DIR@/src",
"-I@LDC_BUILD_IMPORT_DIR@",
"-I@LDC_GCCBUILTINS_IMPORT_DIR@",
"-I@JITRT_DIR@/d",
];
// default directories to be searched for libraries when linking
Expand Down
2 changes: 1 addition & 1 deletion ldc2_phobos.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ default:
// default switches appended after all explicit command-line switches
post-switches = [
"-I@RUNTIME_DIR@/src",
"-I@LDC_BUILD_IMPORT_DIR@",
"-I@LDC_GCCBUILTINS_IMPORT_DIR@",
"-I@JITRT_DIR@/d",
"-I@PHOBOS2_DIR@",
];
Expand Down
Loading
Loading