[pkg-d-commits] [ldc] 86/95: CMake: Fix racey Phobos compilation when building static+shared libs

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta1
in repository ldc.

commit 5a2d48d4f1cbb970728749bea060aa446f4340fc
Author: Martin <noone at nowhere.com>
Date:   Thu Apr 20 21:08:50 2017 +0200

    CMake: Fix racey Phobos compilation when building static+shared libs
---
 runtime/CMakeLists.txt | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 7520314..66f34ef 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -465,8 +465,8 @@ endmacro()
 
 # Builds a static and/or shared copy of druntime/Phobos.
 macro(build_runtime_variant d_flags c_flags ld_flags lib_suffix path_suffix outlist_targets)
-    # Only build Phobos module once. If a shared Phobos lib is generated (too),
-    # compile explicitly with `-relocation-model=pic`.
+    # Only compile Phobos modules once for static+shared libs.
+    # If a shared Phobos lib is generated (too), compile explicitly with `-relocation-model=pic`.
     set(phobos2_d_flags "${d_flags}")
     if(NOT ${BUILD_SHARED_LIBS} STREQUAL "OFF")
         list(APPEND ${phobos2_d_flags} -relocation-model=pic)
@@ -476,6 +476,13 @@ macro(build_runtime_variant d_flags c_flags ld_flags lib_suffix path_suffix outl
     set(phobos2_bc "")
     compile_phobos2("${phobos2_d_flags}" "${lib_suffix}" "${path_suffix}" phobos2_o phobos2_bc)
 
+    # Use a dummy custom target ('phobos2-ldc…-common') depending solely on the Phobos D objects
+    # (custom commands) as dependency for static+shared Phobos libs.
+    # Otherwise building both libs in parallel may result in conflicting Phobos module compilations
+    # (at least with the make generator), a known CMake issue.
+    set(phobos2_common phobos2-ldc${target_suffix}-common)
+    add_custom_target(${phobos2_common} DEPENDS ${phobos2_o} ${phobos2_bc})
+
     # static druntime/Phobos
     if(NOT ${BUILD_SHARED_LIBS} STREQUAL "ON")
         set(druntime_o "")
@@ -485,6 +492,7 @@ macro(build_runtime_variant d_flags c_flags ld_flags lib_suffix path_suffix outl
         build_runtime_libs("${druntime_o}" "${druntime_bc}" "${phobos2_o}" "${phobos2_bc}"
                            "${c_flags}" "${ld_flags}" "${lib_suffix}" "${path_suffix}" "OFF"
                            ${outlist_targets})
+        add_dependencies(phobos2-ldc${target_suffix} ${phobos2_common})
     endif()
     # shared druntime/Phobos
     if(NOT ${BUILD_SHARED_LIBS} STREQUAL "OFF")
@@ -495,6 +503,7 @@ macro(build_runtime_variant d_flags c_flags ld_flags lib_suffix path_suffix outl
         build_runtime_libs("${druntime_o}" "${druntime_bc}" "${phobos2_o}" "${phobos2_bc}"
                            "${c_flags}" "${ld_flags}" "${lib_suffix}${SHARED_LIB_SUFFIX}" "${path_suffix}" "ON"
                            ${outlist_targets})
+        add_dependencies(phobos2-ldc${target_suffix} ${phobos2_common})
     endif()
 endmacro()
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list