120-curl-fix-libressl-linking.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From: Jo-Philipp Wich <jo@mein.io>
  2. Date: Wed, 11 Jan 2017 03:36:04 +0100
  3. Subject: [PATCH] cmcurl: link librt
  4. When cmake is linked against LibreSSL, there might be an indirect
  5. dependency on librt on certain systems if LibreSSL's libcrypto uses
  6. clock_gettime() from librt:
  7. [ 28%] Linking C executable LIBCURL
  8. .../lib/libcrypto.a(getentropy_linux.o): In function `getentropy_fallback':
  9. getentropy_linux.c:(.text+0x16d): undefined reference to `clock_gettime'
  10. getentropy_linux.c:(.text+0x412): undefined reference to `clock_gettime'
  11. collect2: error: ld returned 1 exit status
  12. make[5]: *** [Utilities/cmcurl/LIBCURL] Error 1
  13. Modify the cmcurl CMakeLists.txt to check for clock_gettime() in librt
  14. and unconditionally link the rt library when the symbol is found.
  15. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  16. ---
  17. --- a/Utilities/cmcurl/CMakeLists.txt
  18. +++ b/Utilities/cmcurl/CMakeLists.txt
  19. @@ -611,6 +611,14 @@ if(CURL_USE_OPENSSL)
  20. endif()
  21. set(SSL_ENABLED ON)
  22. set(USE_OPENSSL ON)
  23. + check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
  24. + if(HAVE_LIBRT)
  25. + list(APPEND OPENSSL_LIBRARIES rt)
  26. + endif()
  27. + check_library_exists("pthread" pthread_once "" HAVE_PTHREAD)
  28. + if(HAVE_PTHREAD)
  29. + list(APPEND OPENSSL_LIBRARIES pthread)
  30. + endif()
  31. list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
  32. include_directories(${OPENSSL_INCLUDE_DIR})