From 62cd358fab32e90e7e4fb16b76805533d32c451c Mon Sep 17 00:00:00 2001 From: devgianlu Date: Fri, 14 Feb 2025 09:34:33 +0100 Subject: [PATCH] Meta: Link with OpenSSL explicitly Explicitly link final targets with OpenSSL to ensure that the vcpkg version is loaded instead of the system one. Before this change we would inherit `libcrypto.so` and `libssl.so` from other dependencies, like Qt, that do not have their RPATH rewritten. This would cause the loader to prefer the system libraries over the vcpkg ones causing all sorts of version mismatch issues. The effectiveness of this change can be verified with `readelf -d ./bin/Ladybird` showing `libcrypto.so` and `libssl.so` as direct dependencies, before they would not appear. Additionally, `ldd` will show `libcrypto.so` and `libssl.so` pointing to the vcpkg builds. --- CMakeLists.txt | 3 +++ Services/RequestServer/CMakeLists.txt | 1 + Services/WebContent/CMakeLists.txt | 1 + Services/WebDriver/CMakeLists.txt | 1 + Services/WebWorker/CMakeLists.txt | 1 + UI/CMakeLists.txt | 1 + 6 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0ea4b55068..34720190ad6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,9 @@ if (ENABLE_QT AND ENABLE_GUI_TARGETS) find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network) endif() +# We need to find OpenSSL in order to link it explicitly with all targets. +find_package(OpenSSL REQUIRED) + include(CTest) # for BUILD_TESTING option, default ON if (ENABLE_GUI_TARGETS) diff --git a/Services/RequestServer/CMakeLists.txt b/Services/RequestServer/CMakeLists.txt index b074b41c8f9..4d983f422e6 100644 --- a/Services/RequestServer/CMakeLists.txt +++ b/Services/RequestServer/CMakeLists.txt @@ -26,6 +26,7 @@ target_include_directories(requestserverservice PRIVATE ${LADYBIRD_SOURCE_DIR}/S target_link_libraries(RequestServer PRIVATE requestserverservice) target_link_libraries(requestserverservice PUBLIC LibCore LibDNS LibMain LibCrypto LibFileSystem LibIPC LibMain LibTLS LibWebView LibWebSocket LibURL LibTextCodec LibThreading CURL::libcurl) +target_link_libraries(requestserverservice PRIVATE OpenSSL::Crypto OpenSSL::SSL) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") # Solaris has socket and networking related functions in two extra libraries diff --git a/Services/WebContent/CMakeLists.txt b/Services/WebContent/CMakeLists.txt index 65c89ba49ff..9cc9806c1d5 100644 --- a/Services/WebContent/CMakeLists.txt +++ b/Services/WebContent/CMakeLists.txt @@ -29,6 +29,7 @@ target_include_directories(webcontentservice PUBLIC $) target_link_libraries(webcontentservice PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibMedia LibWeb LibWebSocket LibRequests LibWebView LibImageDecoderClient LibGC) +target_link_libraries(webcontentservice PRIVATE OpenSSL::Crypto OpenSSL::SSL) if (ENABLE_QT) qt_add_executable(WebContent main.cpp) diff --git a/Services/WebDriver/CMakeLists.txt b/Services/WebDriver/CMakeLists.txt index c95830db79c..d2862d8968d 100644 --- a/Services/WebDriver/CMakeLists.txt +++ b/Services/WebDriver/CMakeLists.txt @@ -13,3 +13,4 @@ target_include_directories(WebDriver PRIVATE ${LADYBIRD_SOURCE_DIR}) target_include_directories(WebDriver PRIVATE ${LADYBIRD_SOURCE_DIR}/Services) target_link_libraries(WebDriver PRIVATE LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket LibWebView) +target_link_libraries(WebDriver PRIVATE OpenSSL::Crypto OpenSSL::SSL) diff --git a/Services/WebWorker/CMakeLists.txt b/Services/WebWorker/CMakeLists.txt index 6b65d3a6be1..89f2c58ae07 100644 --- a/Services/WebWorker/CMakeLists.txt +++ b/Services/WebWorker/CMakeLists.txt @@ -14,6 +14,7 @@ target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR}) target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/) target_link_libraries(webworkerservice PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibRequests LibWeb LibWebView LibUnicode LibImageDecoderClient LibMain LibURL LibGC) +target_link_libraries(webworkerservice PRIVATE OpenSSL::Crypto OpenSSL::SSL) if (ENABLE_QT) qt_add_executable(WebWorker main.cpp) diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 97d2121139b..fd3e565b207 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -70,6 +70,7 @@ endif() set(LADYBIRD_LIBS AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibRequests LibURL) target_link_libraries(${LADYBIRD_TARGET} PRIVATE ${LADYBIRD_LIBS}) +target_link_libraries(${LADYBIRD_TARGET} PRIVATE OpenSSL::Crypto OpenSSL::SSL) target_include_directories(${LADYBIRD_TARGET} ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(${LADYBIRD_TARGET} ${LADYBIRD_SOURCE_DIR})