Skip to content

Commit

Permalink
apacheGH-36329: [C++][CI] Use OpenSSL 3 on macOS
Browse files Browse the repository at this point in the history
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/[email protected]/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.

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.
  • Loading branch information
kou authored and laurentgo committed Jun 28, 2023
1 parent 5cd1c3f commit c0a63e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cpp/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 15 additions & 8 deletions cpp/cmake_modules/FindOpenSSLAlt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,24 @@ 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
execute_process(COMMAND ${BREW} --prefix "openssl"
OUTPUT_VARIABLE OPENSSL_BREW_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(OPENSSL11_BREW_PREFIX)
set(OPENSSL_ROOT_DIR ${OPENSSL11_BREW_PREFIX})
if(OPENSSL_BREW_PREFIX)
set(OPENSSL_ROOT_DIR ${OPENSSL_BREW_PREFIX})
else()
execute_process(COMMAND ${BREW} --prefix "openssl"
OUTPUT_VARIABLE OPENSSL_BREW_PREFIX
execute_process(COMMAND ${BREW} --prefix "openssl@3.0"
OUTPUT_VARIABLE OPENSSL3_BREW_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(OPENSSL_BREW_PREFIX)
set(OPENSSL_ROOT_DIR ${OPENSSL_BREW_PREFIX})
if(OPENSSL11_BREW_PREFIX)
set(OPENSSL_ROOT_DIR ${OPENSSL3_BREW_PREFIX})
else()
execute_process(COMMAND ${BREW} --prefix "[email protected]"
OUTPUT_VARIABLE OPENSSL11_BREW_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(OPENSSL11_BREW_PREFIX)
set(OPENSSL_ROOT_DIR ${OPENSSL11_BREW_PREFIX})
endif()
endif()
endif()
endif()
Expand Down

0 comments on commit c0a63e9

Please sign in to comment.