[llvm] r319620 - [cmake] Re-commit: Remove redundant call to cmake when building host tools.
Don Hinton via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 2 11:12:38 PST 2017
Author: dhinton
Date: Sat Dec 2 11:12:38 2017
New Revision: 319620
URL: http://llvm.org/viewvc/llvm-project?rev=319620&view=rev
Log:
[cmake] Re-commit: Remove redundant call to cmake when building host tools.
Also pass CMAKE_(C|CXX)_COMPILER to add_custom_command.
Summary:
Remove the redundant, config-time call to cmake when
building host tools for cross compiles or optimized tablegen..
The config-time call to cmake is redundant because it will always get
called again when the CONFIGURE_LLVM_${target_name} target fires at
build-time. This speeds up initial configuration, but has no affect
on build behavior.
Differential Revision: https://reviews.llvm.org/D40229
Modified:
llvm/trunk/cmake/modules/CrossCompile.cmake
Modified: llvm/trunk/cmake/modules/CrossCompile.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CrossCompile.cmake?rev=319620&r1=319619&r2=319620&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/CrossCompile.cmake (original)
+++ llvm/trunk/cmake/modules/CrossCompile.cmake Sat Dec 2 11:12:38 2017
@@ -12,6 +12,17 @@ function(llvm_create_cross_target_intern
CACHE STRING "Toolchain file for ${target_name}")
endif()
+ if (buildtype)
+ set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
+ endif()
+ if (LLVM_USE_LINKER AND NOT CMAKE_CROSSCOMPILING)
+ set(linker_flag "-DLLVM_USE_LINKER=${LLVM_USE_LINKER}")
+ endif()
+ if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
+ # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
+ set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
+ endif()
+
add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}
COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_${target_name}_BUILD}
COMMENT "Creating ${LLVM_${target_name}_BUILD}...")
@@ -23,6 +34,10 @@ function(llvm_create_cross_target_intern
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DLLVM_TARGETS_TO_BUILD=Native
+ ${build_type_flags} ${linker_flag} ${external_clang_dir}
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
DEPENDS CREATE_LLVM_${target_name}
COMMENT "Configuring ${target_name} LLVM...")
@@ -30,34 +45,6 @@ function(llvm_create_cross_target_intern
add_custom_target(CONFIGURE_LLVM_${target_name}
DEPENDS ${LLVM_${target_name}_BUILD}/CMakeCache.txt)
- set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
- ${LLVM_${target_name}_BUILD})
-
- if(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
-
- message(STATUS "Configuring ${target_name} build...")
- execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
- ${LLVM_${target_name}_BUILD} )
-
- message(STATUS "Configuring ${target_name} targets...")
- if (buildtype)
- set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
- endif()
- if (LLVM_USE_LINKER AND NOT CMAKE_CROSSCOMPILING)
- set(linker_flag "-DLLVM_USE_LINKER=${LLVM_USE_LINKER}")
- endif()
- if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
- # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
- set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
- endif()
- execute_process(COMMAND ${CMAKE_COMMAND} ${build_type_flags}
- -G "${CMAKE_GENERATOR}" -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
- ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
- -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
- ${external_clang_dir} ${linker_flag}
- WORKING_DIRECTORY ${LLVM_${target_name}_BUILD} )
- endif(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
-
endfunction()
function(llvm_create_cross_target target_name sysroot)
More information about the llvm-commits
mailing list