This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new afb84f8ca [build] Fix libevent-enabled cmake builds on ubuntu 20.04.
afb84f8ca is described below

commit afb84f8cac8ad6d9e4c3b2a02af053b5f12ba071
Author: Jason Zhou <[email protected]>
AuthorDate: Tue Jul 2 17:57:11 2024 -0400

    [build] Fix libevent-enabled cmake builds on ubuntu 20.04.
    
    Our current libevent-enabled cmake builds cannot complete on jenkins as it
    gets the 'incomplete definition of type 'struct bio_st'' error.
    
    This is because the upgrade to ubuntu 20.04 also upgraded our openSSL
    version from 1.0.2 to 1.1.1, which breaks compatibility with libevent 2.1.5
    that was previously used.
    
    A compatibility patch for openSSL 1.1+ was released with libevent 2.1.7, but
    the closest tarball that includes a CMakeLists.txt file is 2.1.9, which is
    what we will upgrade to.
    
    With the new libevent library, builds are able to complete using cmake and
    with libevents enabled. But it still sees the test failures we see on other
    builds (such as autotools) and operating system (CentOS 7).
    
    We also need to link libevent_pthread and libevent_openssl with libprocess,
    otherwise we will get errors like:
    
    ```
    ld: 3rdparty/libprocess/src/libprocess.so: undefined reference to 
bufferevent_openssl_get_ssl
    ```
    
    Review: https://reviews.apache.org/r/75070/
---
 3rdparty/CMakeLists.txt                | 53 +++++++++++++++++++++++++++++++---
 3rdparty/cmake/Versions.cmake          |  4 +--
 3rdparty/libprocess/src/CMakeLists.txt | 13 ++++++++-
 cmake/CompilationConfigure.cmake       |  5 ++++
 4 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index e1f71283e..bec004618 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -48,8 +48,7 @@ set(ZOOKEEPER_URL       
${FETCH_URL}/zookeeper-${ZOOKEEPER_VERSION}.tar.gz)
 
 # NOTE: libevent doesn't come rebundled, so this URL is always the same. But,
 # it's only downloaded if `ENABLE_LIBEVENT` is set.
-set(LIBEVENT_URL 
${3RDPARTY_DEPENDENCIES}/libevent-release-${LIBEVENT_VERSION}.tar.gz)
-
+set(LIBEVENT_URL 
${LIBEVENT_RELEASES}/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz)
 if (WIN32)
   # NOTE: These dependencies are only rebundled on Windows because they
   # are available as installable packages on Linux; so they live
@@ -700,6 +699,22 @@ if (ENABLE_LIBEVENT)
     add_library(libevent ${LIBRARY_LINKAGE} IMPORTED)
     add_dependencies(libevent ${LIBEVENT_TARGET})
 
+    if (ENABLE_SSL)
+      add_library(libevent_openssl ${LIBRARY_LINKAGE} IMPORTED)
+      set_target_properties(
+        libevent_openssl PROPERTIES
+        INTERFACE_INCLUDE_DIRECTORIES 
"${LIBEVENT_ROOT}/include;${LIBEVENT_ROOT}-build/include"
+      )
+    endif ()
+
+    if (BUILD_SHARED_LIBS)
+      add_library(libevent_pthreads ${LIBRARY_LINKAGE} IMPORTED)
+      set_target_properties(
+        libevent_pthreads PROPERTIES
+        INTERFACE_INCLUDE_DIRECTORIES 
"${LIBEVENT_ROOT}/include;${LIBEVENT_ROOT}-build/include"
+      )
+    endif ()
+
     set_target_properties(
       libevent PROPERTIES
       INTERFACE_INCLUDE_DIRECTORIES 
"${LIBEVENT_ROOT}/include;${LIBEVENT_ROOT}-build/include")
@@ -721,16 +736,32 @@ if (ENABLE_LIBEVENT)
         IMPORTED_LOCATION ${LIBEVENT_ROOT}-build/lib/libevent${LIBRARY_SUFFIX})
     endif ()
 
+    if (ENABLE_SSL)
+      set_target_properties(
+        libevent_openssl PROPERTIES
+        IMPORTED_LOCATION 
${LIBEVENT_ROOT}-build/lib/libevent_openssl${LIBRARY_SUFFIX})
+    endif ()
+
+    if (BUILD_SHARED_LIBS)
+      set_target_properties(
+        libevent_pthreads PROPERTIES
+        IMPORTED_LOCATION 
${LIBEVENT_ROOT}-build/lib/libevent_pthreads${LIBRARY_SUFFIX})
+      set(EVENT__LIBRARY_TYPE SHARED)
+    else ()
+      set(EVENT__LIBRARY_TYPE STATIC)
+    endif ()
+
     set(LIBEVENT_CMAKE_FORWARD_ARGS
       ${CMAKE_C_FORWARD_ARGS}
       ${CMAKE_SSL_FORWARD_ARGS}
       # NOTE: Libevent does not respect the BUILD_SHARED_LIBS global flag.
-      -DEVENT__BUILD_SHARED_LIBRARIES=${BUILD_SHARED_LIBS}
+      -DEVENT__LIBRARY_TYPE=${EVENT__LIBRARY_TYPE}
       -DEVENT__DISABLE_OPENSSL=$<NOT:$<BOOL:${ENABLE_SSL}>>
       -DEVENT__DISABLE_BENCHMARK=ON
       -DEVENT__DISABLE_REGRESS=ON
       -DEVENT__DISABLE_SAMPLES=ON
-      -DEVENT__DISABLE_TESTS=ON)
+      -DEVENT__DISABLE_TESTS=ON
+      -DEVENT__DISABLE_THREAD_SUPPORT=OFF)
 
     if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
       list(APPEND LIBEVENT_CMAKE_FORWARD_ARGS -DCMAKE_C_FLAGS=-fPIC)
@@ -752,6 +783,20 @@ if (ENABLE_LIBEVENT)
       FILES $<TARGET_FILE:libevent>
       DESTINATION ${3RDPARTY_LIBS_INSTALL_DIR})
 
+    if (ENABLE_SSL)
+      install(
+        FILES $<TARGET_FILE:libevent_openssl>
+        DESTINATION ${3RDPARTY_LIBS_INSTALL_DIR}
+      )
+    endif ()
+
+    if (BUILD_SHARED_LIBS)
+      install(
+        FILES $<TARGET_FILE:libevent_pthreads>
+        DESTINATION ${3RDPARTY_LIBS_INSTALL_DIR}
+      )
+    endif ()
+
   else ()
     find_package(LIBEVENT REQUIRED)
     add_library(libevent INTERFACE)
diff --git a/3rdparty/cmake/Versions.cmake b/3rdparty/cmake/Versions.cmake
index acb240eef..aca4296aa 100644
--- a/3rdparty/cmake/Versions.cmake
+++ b/3rdparty/cmake/Versions.cmake
@@ -25,8 +25,8 @@ set(LIBAPR_HASH             
"SHA256=C173DE748F85A76B5EA7E5C77F3D9F1EECC9C0A6AB91
 set(LIBEV_VERSION           "4.22")
 set(LIBEV_HASH              
"SHA256=736079E8AC543C74D59AF73F9C52737B3BFEC9601F020BF25A87A4F4D0F01BD6")
 # TODO(hausdorff): (MESOS-3529) transition this back to a non-beta version.
-set(LIBEVENT_VERSION        "2.1.5-beta")
-set(LIBEVENT_HASH           
"SHA256=9A410E24921F59F0AB2009E5E31B3B20932E4AA5A1CBAC6A53190DC86DADE806")
+set(LIBEVENT_VERSION        "2.1.9-beta")
+set(LIBEVENT_HASH           
"SHA256=eeb4c6eb2c4021e22d6278cdcd02815470243ed81077be0cbd0f233fa6fc07e8")
 set(LIBSECCOMP_VERSION      "2.3.3")
 set(LIBSECCOMP_HASH         
"SHA256=7FC28F4294CC72E61C529BEDF97E705C3ACF9C479A8F1A3028D4CD2CA9F3B155")
 set(NVML_VERSION            "352.79")
diff --git a/3rdparty/libprocess/src/CMakeLists.txt 
b/3rdparty/libprocess/src/CMakeLists.txt
index d1ad7c191..ba881d408 100644
--- a/3rdparty/libprocess/src/CMakeLists.txt
+++ b/3rdparty/libprocess/src/CMakeLists.txt
@@ -114,10 +114,21 @@ target_link_libraries(
   $<$<BOOL:${ENABLE_SSL}>:OpenSSL::SSL>
   $<$<BOOL:${ENABLE_SSL}>:OpenSSL::Crypto>)
 
+  # We need openssl and pthreads if we have ENABLE_LIBEVENT
+  # Otherwise libprocess will not link properly and we get undefined reference
+if (ENABLE_LIBEVENT)
+  set(LIBEVENT_DEPENDENCIES libevent libevent_openssl libevent_pthreads)
+else ()
+  if (NOT PLATFORM_ID STREQUAL "Windows")
+    set(LIBEVENT_DEPENDENCIES libev)
+  endif ()
+endif ()
+
+# Link libraries
 target_link_libraries(
   process PRIVATE
   concurrentqueue
-  
$<IF:$<BOOL:${ENABLE_LIBEVENT}>,libevent,$<$<NOT:$<PLATFORM_ID:Windows>>:libev>>)
+  ${LIBEVENT_DEPENDENCIES})
 
 target_compile_definitions(
   process PRIVATE
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index 813b255d2..b83e55035 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -276,6 +276,11 @@ set(
   CACHE STRING
     "URL or filesystem path with a fork of the canonical 3rdparty repository")
 
+set(
+  LIBEVENT_RELEASES "https://github.com/libevent/libevent/releases/download";
+  CACHE STRING
+    "URL to download the desired version of libevent release tarball")
+
 if (WIN32 AND REBUNDLED)
   message(
     WARNING

Reply via email to