[llvm] r320413 - [cmake] Pass TARGETS_TO_BUILD through to host tools build

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 11:53:23 PST 2017


Author: bogner
Date: Mon Dec 11 11:53:23 2017
New Revision: 320413

URL: http://llvm.org/viewvc/llvm-project?rev=320413&view=rev
Log:
[cmake] Pass TARGETS_TO_BUILD through to host tools build

In r319620, the host build was changed to use Native for
TARGETS_TO_BUILD because passing semicolons through add_custom_command
is surprisingly difficult. However, Native really doesn't make any
sense here, and it only works because we don't technically do any
codegen in the host tools so pretty well anything will "work".

The problem here is that passing something other than the correct
value is very fragile - as evidence note how the llvm-config in the
host tools acts differently than the target one now, and misreports
the targets to build. Similarly, if there is any logic conditional on
the targets in tablegen (now or in the future), it will do the wrong
thing.

To fix this, we need to escape the semicolons in the targets string
and pass it through to the child cmake invocation.

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=320413&r1=320412&r2=320413&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/CrossCompile.cmake (original)
+++ llvm/trunk/cmake/modules/CrossCompile.cmake Mon Dec 11 11:53:23 2017
@@ -36,11 +36,16 @@ function(llvm_create_cross_target_intern
   add_custom_target(CREATE_LLVM_${target_name}
                     DEPENDS ${LLVM_${target_name}_BUILD})
 
+  # Escape semicolons in the targets list so that cmake doesn't expand
+  # them to spaces.
+  string(REPLACE ";" "$<SEMICOLON>" targets_to_build_arg
+         "${LLVM_TARGETS_TO_BUILD}")
+
   add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt
     COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
         ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
         -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
-        -DLLVM_TARGETS_TO_BUILD=Native
+        -DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
         ${build_type_flags} ${linker_flag} ${external_clang_dir}
     WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
     DEPENDS CREATE_LLVM_${target_name}




More information about the llvm-commits mailing list