0003-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 548cd5eb4f45de4ec71b3421a98c9462aed75c91 Mon Sep 17 00:00:00 2001
  2. From: Eric Fiselier <eric@efcs.ca>
  3. Date: Fri, 10 Feb 2017 01:59:20 +0000
  4. Subject: [PATCH] [CMake] Fix pthread handling for out-of-tree builds
  5. LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects
  6. to correctly link the threading library when needed. Unfortunately
  7. `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed
  8. and therefore can't be used when configuring out-of-tree builds. This causes
  9. such builds to fail since `pthread` isn't being correctly linked.
  10. This patch attempts to fix that problem by renaming and exporting
  11. `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB`
  12. because It seemed likely to cause collisions with downstream users of
  13. `LLVMConfig.cmake`.
  14. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@294690 91177308-0d34-0410-b5e6-96231b3b80d8
  15. ---
  16. COFF/CMakeLists.txt | 2 +-
  17. ELF/CMakeLists.txt | 2 +-
  18. lib/ReaderWriter/MachO/CMakeLists.txt | 2 +-
  19. unittests/CoreTests/CMakeLists.txt | 2 +-
  20. 4 files changed, 4 insertions(+), 4 deletions(-)
  21. diff --git a/COFF/CMakeLists.txt b/COFF/CMakeLists.txt
  22. index 0eebe9348..8f24e36c0 100644
  23. --- a/COFF/CMakeLists.txt
  24. +++ b/COFF/CMakeLists.txt
  25. @@ -43,7 +43,7 @@ add_lld_library(lldCOFF
  26. LINK_LIBS
  27. lldCore
  28. - ${PTHREAD_LIB}
  29. + ${LLVM_PTHREAD_LIB}
  30. DEPENDS
  31. COFFOptionsTableGen
  32. diff --git a/ELF/CMakeLists.txt b/ELF/CMakeLists.txt
  33. index 5652b9351..0d1e5b214 100644
  34. --- a/ELF/CMakeLists.txt
  35. +++ b/ELF/CMakeLists.txt
  36. @@ -54,7 +54,7 @@ add_lld_library(lldELF
  37. LINK_LIBS
  38. lldConfig
  39. lldCore
  40. - ${PTHREAD_LIB}
  41. + ${LLVM_PTHREAD_LIB}
  42. DEPENDS
  43. ELFOptionsTableGen
  44. diff --git a/lib/ReaderWriter/MachO/CMakeLists.txt b/lib/ReaderWriter/MachO/CMakeLists.txt
  45. index 3b0698525..5a96d87f1 100644
  46. --- a/lib/ReaderWriter/MachO/CMakeLists.txt
  47. +++ b/lib/ReaderWriter/MachO/CMakeLists.txt
  48. @@ -28,7 +28,7 @@ add_lld_library(lldMachO
  49. LINK_LIBS
  50. lldCore
  51. lldYAML
  52. - ${PTHREAD_LIB}
  53. + ${LLVM_PTHREAD_LIB}
  54. )
  55. include_directories(.)
  56. diff --git a/unittests/CoreTests/CMakeLists.txt b/unittests/CoreTests/CMakeLists.txt
  57. index 98405d5c7..72e7c443f 100644
  58. --- a/unittests/CoreTests/CMakeLists.txt
  59. +++ b/unittests/CoreTests/CMakeLists.txt
  60. @@ -3,5 +3,5 @@ add_lld_unittest(CoreTests
  61. )
  62. target_link_libraries(CoreTests
  63. - ${PTHREAD_LIB}
  64. + ${LLVM_PTHREAD_LIB}
  65. )
  66. --
  67. 2.12.2