0016-clang-llvm-cmake-Fix-configure-for-packages-using.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From 39f88370fb0d09b3ff544265076c70e8476014ee Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 9 Nov 2021 10:31:46 +0800
  4. Subject: [PATCH 16/34] clang,llvm: cmake: Fix configure for packages using
  5. find_package()
  6. Currently, when a package (i.e. bcc [https://github.com/iovisor/bcc.git])
  7. that depends on LLVM/Clang tries to run cmake find_package() during
  8. do_configure, it will fail with a similar error:
  9. | The imported target "llvm-tblgen" references the file
  10. | ".../recipe-sysroot/usr/bin/llvm-tblgen"
  11. |
  12. | but this file does not exist. Possible reasons include:
  13. | * The file was deleted, renamed, or moved to another location.
  14. | * An install or uninstall procedure did not complete successfully.
  15. | * The installation package was faulty and contained
  16. | ".../recipe-sysroot/usr/lib/cmake/LLVMExports.cmake"
  17. | but not all the files it references.
  18. This is due to the fact that currently the cmake scripts look for target
  19. binaries in sysroot. Work around this by not exporting the target binaries in
  20. Exports-* cmake files.
  21. Upstream-Status: Innapropriate [oe-specific]
  22. Rebased to LLVM 14.0.0 by Jun Yuan Tan
  23. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
  24. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  25. ---
  26. clang/cmake/modules/AddClang.cmake | 2 --
  27. llvm/cmake/modules/AddLLVM.cmake | 6 ------
  28. llvm/cmake/modules/TableGen.cmake | 7 -------
  29. 3 files changed, 15 deletions(-)
  30. diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
  31. index 5752f4277444..f40ea35faf46 100644
  32. --- a/clang/cmake/modules/AddClang.cmake
  33. +++ b/clang/cmake/modules/AddClang.cmake
  34. @@ -158,7 +158,6 @@ macro(add_clang_tool name)
  35. if (CLANG_BUILD_TOOLS)
  36. get_target_export_arg(${name} Clang export_to_clangtargets)
  37. install(TARGETS ${name}
  38. - ${export_to_clangtargets}
  39. RUNTIME DESTINATION bin
  40. COMPONENT ${name})
  41. @@ -167,7 +166,6 @@ macro(add_clang_tool name)
  42. DEPENDS ${name}
  43. COMPONENT ${name})
  44. endif()
  45. - set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
  46. endif()
  47. endmacro()
  48. diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
  49. index c5a9e0209f13..c824e69ba066 100644
  50. --- a/llvm/cmake/modules/AddLLVM.cmake
  51. +++ b/llvm/cmake/modules/AddLLVM.cmake
  52. @@ -1241,7 +1241,6 @@ macro(add_llvm_tool name)
  53. if( LLVM_BUILD_TOOLS )
  54. get_target_export_arg(${name} LLVM export_to_llvmexports)
  55. install(TARGETS ${name}
  56. - ${export_to_llvmexports}
  57. RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR}
  58. COMPONENT ${name})
  59. @@ -1252,9 +1251,6 @@ macro(add_llvm_tool name)
  60. endif()
  61. endif()
  62. endif()
  63. - if( LLVM_BUILD_TOOLS )
  64. - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
  65. - endif()
  66. set_target_properties(${name} PROPERTIES FOLDER "Tools")
  67. endmacro(add_llvm_tool name)
  68. @@ -1294,7 +1290,6 @@ macro(add_llvm_utility name)
  69. if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
  70. get_target_export_arg(${name} LLVM export_to_llvmexports)
  71. install(TARGETS ${name}
  72. - ${export_to_llvmexports}
  73. RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
  74. COMPONENT ${name})
  75. @@ -1303,7 +1298,6 @@ macro(add_llvm_utility name)
  76. DEPENDS ${name}
  77. COMPONENT ${name})
  78. endif()
  79. - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
  80. elseif(LLVM_BUILD_UTILS)
  81. set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY ${name})
  82. endif()
  83. diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
  84. index 5e9e2674405e..3c72df35b308 100644
  85. --- a/llvm/cmake/modules/TableGen.cmake
  86. +++ b/llvm/cmake/modules/TableGen.cmake
  87. @@ -179,14 +179,8 @@ macro(add_tablegen target project)
  88. endif()
  89. if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
  90. - set(export_to_llvmexports)
  91. - if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
  92. - NOT LLVM_DISTRIBUTION_COMPONENTS)
  93. - set(export_to_llvmexports EXPORT LLVMExports)
  94. - endif()
  95. install(TARGETS ${target}
  96. - ${export_to_llvmexports}
  97. COMPONENT ${target}
  98. RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR})
  99. if(NOT LLVM_ENABLE_IDE)
  100. @@ -195,5 +189,4 @@ macro(add_tablegen target project)
  101. COMPONENT ${target})
  102. endif()
  103. endif()
  104. - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
  105. endmacro()
  106. --
  107. 2.33.1