diff --git a/llvm/cmake/modules/LLVM-Build.cmake b/llvm/cmake/modules/LLVM-Build.cmake index 746f09b09019f..ce56273c5a1da 100644 --- a/llvm/cmake/modules/LLVM-Build.cmake +++ b/llvm/cmake/modules/LLVM-Build.cmake @@ -81,13 +81,21 @@ endfunction() # Resolve cross-component dependencies, for each available component. function(LLVMBuildResolveComponentsLink) - get_property(llvm_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS) - get_property(llvm_has_jit_native TARGET ${LLVM_NATIVE_ARCH} PROPERTY LLVM_HAS_JIT) + + # the native target may not be enabled when cross compiling + if(TARGET ${LLVM_NATIVE_ARCH}) + get_property(llvm_has_jit_native TARGET ${LLVM_NATIVE_ARCH} PROPERTY LLVM_HAS_JIT) + else() + set(llvm_has_jit_native OFF) + endif() + if(llvm_has_jit_native) set_property(TARGET Engine APPEND PROPERTY LLVM_LINK_COMPONENTS "MCJIT" "Native") else() set_property(TARGET Engine APPEND PROPERTY LLVM_LINK_COMPONENTS "Interpreter") endif() + + get_property(llvm_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS) foreach(llvm_component ${llvm_components}) get_property(link_components TARGET ${llvm_component} PROPERTY LLVM_LINK_COMPONENTS) llvm_map_components_to_libnames(llvm_libs ${link_components}) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 9425efab94a91..e2093f1dd3272 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -1,13 +1,5 @@ include(LLVM-Build) -# Special components which don't have any source attached but aggregate other -# components -add_llvm_component_group(all-targets LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD}) -add_llvm_component_group(Engine) -add_llvm_component_group(Native LINK_COMPONENTS ${LLVM_NATIVE_ARCH}) -add_llvm_component_group(NativeCodeGen LINK_COMPONENTS ${LLVM_NATIVE_ARCH}CodeGen) - - # `Demangle', `Support' and `TableGen' libraries are added on the top-level # CMakeLists.txt @@ -50,5 +42,20 @@ add_subdirectory(WindowsManifest) set(LLVMCONFIGLIBRARYDEPENDENCIESINC "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc") +# Special components which don't have any source attached but aggregate other +# components +add_llvm_component_group(all-targets LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD}) +add_llvm_component_group(Engine) + +# The native target may not be enabled when cross compiling +if(TARGET ${LLVM_NATIVE_ARCH}) + add_llvm_component_group(Native LINK_COMPONENTS ${LLVM_NATIVE_ARCH}) + add_llvm_component_group(NativeCodeGen LINK_COMPONENTS ${LLVM_NATIVE_ARCH}CodeGen) +else() + add_llvm_component_group(Native) + add_llvm_component_group(NativeCodeGen) +endif() + +# Component post-processing LLVMBuildResolveComponentsLink() LLVMBuildGenerateCFragment(OUTPUT ${LLVMCONFIGLIBRARYDEPENDENCIESINC})