Parallelize optimization and code generation for link time optimization.
This parallelizes the `-flto` feature resulting in parallel optimization and code generation for link time optimization based on the number of logical processors available. Note: this has the side-effect of using more memory during linking. References: - https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html (see: -flto) - http://www.cmake.org/cmake/help/v3.0/module/ProcessorCount.htmMC
This commit is contained in:
		
							parent
							
								
									17d8e65c64
								
							
						
					
					
						commit
						941483c14d
					
				@ -124,14 +124,16 @@ endif()
 | 
				
			|||||||
if(CMAKE_BUILD_TYPE MATCHES Release)
 | 
					if(CMAKE_BUILD_TYPE MATCHES Release)
 | 
				
			||||||
  message(STATUS "Configuring OSRM in release mode")
 | 
					  message(STATUS "Configuring OSRM in release mode")
 | 
				
			||||||
  # Check if LTO is available
 | 
					  # Check if LTO is available
 | 
				
			||||||
 | 
					  include(ProcessorCount)
 | 
				
			||||||
 | 
					  ProcessorCount(NPROC)
 | 
				
			||||||
  set(LTO_FLAGS "")
 | 
					  set(LTO_FLAGS "")
 | 
				
			||||||
  check_cxx_compiler_flag("-flto" LTO_AVAILABLE)
 | 
					  check_cxx_compiler_flag("-flto=${NPROC}" LTO_AVAILABLE)
 | 
				
			||||||
  if(LTO_AVAILABLE)
 | 
					  if(LTO_AVAILABLE)
 | 
				
			||||||
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
 | 
					    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=${NPROC}")
 | 
				
			||||||
    set(CHECK_LTO_SRC "int main(){return 0;}")
 | 
					    set(CHECK_LTO_SRC "int main(){return 0;}")
 | 
				
			||||||
    check_cxx_source_compiles("${CHECK_LTO_SRC}" LTO_WORKS)
 | 
					    check_cxx_source_compiles("${CHECK_LTO_SRC}" LTO_WORKS)
 | 
				
			||||||
    if(LTO_WORKS)
 | 
					    if(LTO_WORKS)
 | 
				
			||||||
      message(STATUS "LTO working")
 | 
					    message(STATUS "LTO working")
 | 
				
			||||||
    else()
 | 
					    else()
 | 
				
			||||||
      message(STATUS "LTO broken")
 | 
					      message(STATUS "LTO broken")
 | 
				
			||||||
      set(CMAKE_CXX_FLAGS "${OLD_CXX_FLAGS}")
 | 
					      set(CMAKE_CXX_FLAGS "${OLD_CXX_FLAGS}")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user