You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/06/30 00:41:59 UTC

[arrow] branch main updated: GH-36329: [C++][CI] Use OpenSSL 3 on macOS (#36336)

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

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d92ed4dc4 GH-36329: [C++][CI] Use OpenSSL 3 on macOS (#36336)
9d92ed4dc4 is described below

commit 9d92ed4dc4d6d691668609641043561137e91401
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Fri Jun 30 09:41:52 2023 +0900

    GH-36329: [C++][CI] Use OpenSSL 3 on macOS (#36336)
    
    ### Rationale for this change
    
    GitHub Actions self-hosted runner for macOS has
    /usr/local/include/openssl/ provided by OpenSSL 3 (`openssl@ 3`). Our include paths have `... -isystem /usr/local/include -isystem /usr/local/opt/openssl@ 1.1/include ...`. It means that `/usr/local/include/openssl/...` is used for `#include <openssl/...>`.
    
    If we mix OpenSSL 3 headers and OpenSSL 1.1 libraries, we may get some problems such as a link error.
    
    ### What changes are included in this PR?
    
    This uses OpenSSL 3 instead of OpenSSL 1.1 because GitHub Actions self-hosted runner for macOS provides OpenSSL 3 by /usr/local/include/openssl/. Note that `$(brew --prefix openssl@ 3)/include` isn't linked as /usr/local/include/openssl` by default. So I think that Homebrew GitHub Actions self-hosted runner for macOS does it explicitly.
    
    Other solution: Unlinking `/usr/local/include/openssl` by `brew unlink openssl@ 3`. But there is no reason to use OpenSSL 1.1 for us. So this PR doesn't use this solution.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    Yes.
    * Closes: #36329
    
    Authored-by: Sutou Kouhei <ko...@clear-code.com>
    Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
 cpp/Brewfile                           |  2 +-
 cpp/cmake_modules/FindOpenSSLAlt.cmake | 22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cpp/Brewfile b/cpp/Brewfile
index 66f1bd332b..580e8d3f11 100644
--- a/cpp/Brewfile
+++ b/cpp/Brewfile
@@ -30,7 +30,7 @@ brew "grpc"
 brew "llvm@14"
 brew "lz4"
 brew "ninja"
-brew "openssl@1.1"
+brew "openssl@3"
 brew "protobuf"
 brew "python"
 brew "rapidjson"
diff --git a/cpp/cmake_modules/FindOpenSSLAlt.cmake b/cpp/cmake_modules/FindOpenSSLAlt.cmake
index f027eb1026..03c61e6ea2 100644
--- a/cpp/cmake_modules/FindOpenSSLAlt.cmake
+++ b/cpp/cmake_modules/FindOpenSSLAlt.cmake
@@ -22,19 +22,19 @@ endif()
 if(APPLE AND NOT OPENSSL_ROOT_DIR)
   find_program(BREW brew)
   if(BREW)
-    execute_process(COMMAND ${BREW} --prefix "openssl@1.1"
-                    OUTPUT_VARIABLE OPENSSL11_BREW_PREFIX
-                    OUTPUT_STRIP_TRAILING_WHITESPACE)
-    if(OPENSSL11_BREW_PREFIX)
-      set(OPENSSL_ROOT_DIR ${OPENSSL11_BREW_PREFIX})
-    else()
-      execute_process(COMMAND ${BREW} --prefix "openssl"
-                      OUTPUT_VARIABLE OPENSSL_BREW_PREFIX
+    foreach(BREW_OPENSSL_VERSION "" "3" "3.0" "1.1")
+      set(BREW_OPENSSL_PACKAGE "openssl")
+      if(BREW_OPENSSL_VERSION)
+        string(APPEND BREW_OPENSSL_PACKAGE "@${BREW_OPENSSL_VERSION}")
+      endif()
+      execute_process(COMMAND ${BREW} --prefix --installed ${BREW_OPENSSL_PACKAGE}
+                      OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-      if(OPENSSL_BREW_PREFIX)
-        set(OPENSSL_ROOT_DIR ${OPENSSL_BREW_PREFIX})
+      if(BREW_OPENSSL_PREFIX)
+        set(OPENSSL_ROOT_DIR ${BREW_OPENSSL_PREFIX})
+        break()
       endif()
-    endif()
+    endforeach()
   endif()
 endif()