[cmake-developers] speed up package with mingw on Windows host

laurent laurent at mbdsys.com
Sat Jun 18 12:10:12 EDT 2016


Hello,

I would like to share my experience about speed up package with BundleUtilities on Windows host using mingw32 env.
My test setup :
	- Windows 7
	- cmake 3.4.1
	- msys2 i686-20160205
	
Currently my project take about 40 min to package. This is not acceptable. The main reason is about deep dependencies analyse with objdump.

1/ There is already a patch trying to resolve this issue : https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f01a8823 <https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f01a8823>
But this patch use grep. grep is a unix utility not provided by Windows.
grep could be replaced by findstr on Windows. This way we can achieve the same level of filtering with the same criteria.


2/ Regarding fixup_bundle flow, we can observe multi recursive analyse call to the same library. This is an huge time consumer. 
This simple patch disable analyse of already processed libraries. (The time to package my project drop down to 4 min with this patch)

--- GetPrerequisites.cmake	2016-04-15 15:41:21.000000000 +0200
+++ GetPrerequisites.cmake.new	2016-06-18 17:36:19.000000000 +0200

@@ -727,7 +727,11 @@
     set(gp_regex_fallback "")
     set(gp_regex_cmp_count 1)
     # objdump generaates copious output so we create a grep filter to pre-filter results
-    find_program(gp_grep_cmd grep)
+    if(WIN32)
+      find_program(gp_grep_cmd findstr)
+    else()
+      find_program(gp_grep_cmd grep)
+    endif()
     if(gp_grep_cmd)
       set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "^[[:blank:]]*DLL Name: ")
     endif()
@@ -920,9 +924,18 @@
     list(SORT ${prerequisites_var})
   endif()
   if(${recurse})
+    GET_PROPERTY(MyLocalVariable GLOBAL PROPERTY MY_PREREQUISE)
+    list(APPEND analysed ${MyLocalVariable} ${target})
+    list(REMOVE_DUPLICATES analysed)	 
+    SET_PROPERTY(GLOBAL PROPERTY MY_PREREQUISE ${analysed})
+
     set(more_inputs ${unseen_prereqs})
     foreach(input ${more_inputs})
-      get_prerequisites("${input}" ${prerequisites_var} ${exclude_system} ${recurse} "${exepath}" "${dirs}" "${rpaths}")
+      GET_PROPERTY(MyTmp GLOBAL PROPERTY MY_PREREQUISE)
+      list (FIND MyTmp ${input} is_found)
+      if(${is_found} EQUAL -1)
+      	get_prerequisites("${input}" ${prerequisites_var} ${exclude_system} ${recurse} "${exepath}" "${dirs}" "${rpaths}")
+      endif()
     endforeach()
   endif()
 
Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160618/592d1a70/attachment.html>


More information about the cmake-developers mailing list