[source] tools: cmake: link librt if needed (FS#381)

LEDE Commits lede-commits at lists.infradead.org
Tue Jan 10 18:48:37 PST 2017


jow pushed a commit to source.git, branch master:
https://git.lede-project.org/43d53399406b08bdfeb78727cd122578aee4894a

commit 43d53399406b08bdfeb78727cd122578aee4894a
Author: Jo-Philipp Wich <jo at mein.io>
AuthorDate: Wed Jan 11 03:41:10 2017 +0100

    tools: cmake: link librt if needed (FS#381)
    
    Patch cmakes cmcurl component to unconditionally link librt when we discover
    a clock_gettime() symbol in -lrt.
    
    This is required to sucessfully link LibreSSL's libcrypto which might or
    might not reqauire librt.
    
    Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
 tools/cmake/Makefile                               |  4 +--
 .../patches/140-curl-fix-libressl-linking.patch    | 32 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile
index 6214da7..a1137c5 100644
--- a/tools/cmake/Makefile
+++ b/tools/cmake/Makefile
@@ -20,9 +20,7 @@ HOST_CONFIGURE_PARALLEL:=1
 include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CONFIGURE_CMD := \
-	MAKEFLAGS="$(HOST_JOBS)" \
-	LDFLAGS="$$$$(pkg-config --static --libs libcrypto)" \
-		$(BASH) ./configure
+	MAKEFLAGS="$(HOST_JOBS)" $(BASH) ./configure
 
 HOST_CONFIGURE_VARS :=
 
diff --git a/tools/cmake/patches/140-curl-fix-libressl-linking.patch b/tools/cmake/patches/140-curl-fix-libressl-linking.patch
new file mode 100644
index 0000000..5b57172
--- /dev/null
+++ b/tools/cmake/patches/140-curl-fix-libressl-linking.patch
@@ -0,0 +1,32 @@
+From: Jo-Philipp Wich <jo at mein.io>
+Date: Wed, 11 Jan 2017 03:36:04 +0100
+Subject: [PATCH] cmcurl: link librt
+
+When cmake is linked against LibreSSL, there might be an indirect
+dependency on librt on certain systems if LibreSSL's libcrypto uses
+clock_gettime() from librt:
+
+    [ 28%] Linking C executable LIBCURL
+    .../lib/libcrypto.a(getentropy_linux.o): In function `getentropy_fallback':
+    getentropy_linux.c:(.text+0x16d): undefined reference to `clock_gettime'
+    getentropy_linux.c:(.text+0x412): undefined reference to `clock_gettime'
+    collect2: error: ld returned 1 exit status
+    make[5]: *** [Utilities/cmcurl/LIBCURL] Error 1
+
+Modify the cmcurl CMakeLists.txt to check for clock_gettime() in librt
+and unconditionally link the rt library when the symbol is found.
+
+Signed-off-by: Jo-Philipp Wich <jo at mein.io>
+--- a/Utilities/cmcurl/CMakeLists.txt
++++ b/Utilities/cmcurl/CMakeLists.txt
+@@ -362,6 +362,10 @@ set(HAVE_LIBSSL OFF)
+ if(CMAKE_USE_OPENSSL)
+   find_package(OpenSSL)
+   if(OPENSSL_FOUND)
++    check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
++    if(HAVE_LIBRT)
++      list(APPEND OPENSSL_LIBRARIES rt)
++    endif()
+     list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
+     set(USE_OPENSSL ON)
+     set(HAVE_LIBCRYPTO ON)



More information about the lede-commits mailing list