From dad1df573d71e46609f9ba2d8f16d93f09c9d2a7 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 10:51:58 +0300 Subject: [PATCH 1/4] runtime/CMakeLists.txt: Depend only on the full path to the ldc binary For custom commands that require a built ldc2 specify only an absolute path to compiler binary, not the target name. This is because cmake handles file paths and target dependencies differently. In the case of a target dependency the dependency doesn't actually apply to the `add_custom_command`, it only affects future targets. As an example, we want to built libruntime.a from a D file foo.d. What we need to describe is: 1. compile foo.o from foo.d (depends on LDC) 2. archive libruntime.a from foo.o If we use ${LDC_EXE} as a dependency (only the target name) cmake would generate: 1. compile foo.o from foo.d 2. archive libruntime.a from foo.o (depends on LDC) Using an absolute path for the LDC dependency does what we want it to do. Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index fcbed7e6c61..1b43b7b64b1 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -337,7 +337,7 @@ if(LDC_EXE) "$<$:${MULTILIB_DIR}>" ${conf_path}.in ${conf_path} - DEPENDS ${LDC_EXE} ${LDC_EXE_FULL} + DEPENDS ${LDC_EXE_FULL} ) add_custom_command(OUTPUT ${install_conf_path} VERBATIM COMMAND ${PROJECT_PARENT_DIR}/tools/add-multilib-section.sh @@ -347,7 +347,7 @@ if(LDC_EXE) "$<$:${MULTILIB_INSTALL_DIR}>" ${install_conf_path}.in ${install_conf_path} - DEPENDS ${LDC_EXE} ${LDC_EXE_FULL} + DEPENDS ${LDC_EXE_FULL} ) add_custom_target(add-multilib-section ALL DEPENDS ${conf_path} ${install_conf_path} @@ -437,7 +437,9 @@ macro(dc src_files src_basedir d_flags output_basedir emit_bc all_at_once single list(APPEND dc_flags -flto=thin --output-bc) endif() - set(dc_deps ${LDC_EXE} ${LDC_EXE_FULL} ${GCCBUILTINS}) + # dc_deps can only contain paths, otherwise cmake will ignore the dependency. + # See: https://github.com/ldc-developers/ldc/pull/4743#issuecomment-2323156173 + set(dc_deps ${LDC_EXE_FULL} ${GCCBUILTINS}) if(TARGET add-multilib-section) # Make sure the config files are available before invoking LDC. set(dc_deps ${dc_deps} add-multilib-section) From ee381a32d37c38997c40739c7b8a3045fcaa6299 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 10:53:18 +0300 Subject: [PATCH 2/4] runtime/CMakeLists.txt: Call cmake_minimum_required before project() Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 1b43b7b64b1..13492948947 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,6 +1,5 @@ -project(runtime C ASM) - cmake_minimum_required(VERSION 3.4.3) +project(runtime C ASM) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) From dcf855579b746b9f2b6a2700395ff05881dfd97e Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 11:03:57 +0300 Subject: [PATCH 3/4] runtime/CMakeLists.txt: add call to enable_testing() Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 13492948947..2d2d7e81309 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -906,6 +906,7 @@ install(FILES ${GCCBUILTINS} DESTINATION ${INCLUDE_INSTALL_DIR}/ldc) # # Test targets. # +enable_testing() # Build the "test runner" executables containing the druntime and Phobos unit # tests. They are invoked with the modules to test later. From 0dcf778931d2ac22b4886af686cc1bef0ddb9398 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 11:46:31 +0300 Subject: [PATCH 4/4] runtime/DRuntimeIntegrationTests.cmake: Pass D_EXTRA_FLAGS to ldmd D_EXTRA_FLAGS is the intended way to pass flags like -m32 to ldc so make sure that its value is respected during the druntime tests. Signed-off-by: Andrei Horodniceanu --- runtime/DRuntimeIntegrationTests.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index a10b5607593..782ae9358ae 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -56,6 +56,8 @@ else() list(REMOVE_ITEM testnames uuid) endif() +string(REPLACE ";" " " LDMD_CMD "${LDMD_EXE_FULL} ${D_EXTRA_FLAGS}") + foreach(name ${testnames}) foreach(build debug release) set(druntime_path_build ${druntime_path}) @@ -72,7 +74,7 @@ foreach(name ${testnames}) ) add_test(NAME ${fullname} COMMAND ${GNU_MAKE_BIN} -C ${PROJECT_SOURCE_DIR}/druntime/test/${name} - ROOT=${outdir} DMD=${LDMD_EXE_FULL} BUILD=${build} + ROOT=${outdir} DMD=${LDMD_CMD} BUILD=${build} DRUNTIME=${druntime_path_build} DRUNTIMESO=${shared_druntime_path_build} SHARED=1 ${cflags_base} ${linkdl} )