llvmbuildectomy - support disabled native target
authorserge-sans-paille <sguelton@redhat.com>
Fri, 13 Nov 2020 14:49:27 +0000 (15:49 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Fri, 13 Nov 2020 14:50:13 +0000 (15:50 +0100)
llvm/cmake/modules/LLVM-Build.cmake
llvm/lib/CMakeLists.txt

index 746f09b..ce56273 100644 (file)
@@ -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})
index 9425efa..e2093f1 100644 (file)
@@ -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})