From 5675a8947d2cac8e17a77aa22a37c431f988a7ab Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Sun, 15 Sep 2024 00:04:11 -0700 Subject: [PATCH 1/3] support building on illumos systems --- CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30e1117fae..d2b7d7320a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,28 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") endif() endif() +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + # Determine if the host is running an illumos distribution: + execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (UNAME_O STREQUAL "illumos") + set(ILLUMOS 1) + endif() + + if (ILLUMOS) + # + # illumos systems require linking libsocket and libnsl to get various + # networking routines sometimes found in libc on other platforms: + # + if(NOT BUILD_SHARED_LIBS) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lsocket -lnsl") + else() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lsocket -lnsl") + endif() + endif() +endif() + # Tests and libssl both require the CXX language to be enabled. If a consumer # chooses to disable building the tests and libssl, do not enable CXX if(BUILD_TESTING OR BUILD_LIBSSL) @@ -789,9 +811,20 @@ if(OPENSSL_NO_SSE2_FOR_TESTING) add_definitions(-DOPENSSL_NO_SSE2_FOR_TESTING) endif() -# Some consumers might use upper-case (e.g.) "X86" or "X86_64". -# Matching below is based on lower-case. -string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER) +if(ILLUMOS) + # + # CMAKE_SYSTEM_PROCESSOR unfortunately comes from the output of "uname -p", + # which on illumos systems emits "i386". Instead, use the value from + # "isainfo -n", which prints "the name of the native instruction set used by + # portable applications"; e.g., "amd64". + # + execute_process(COMMAND /usr/bin/isainfo -n OUTPUT_VARIABLE + CMAKE_SYSTEM_PROCESSOR_LOWER OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + # Some consumers might use upper-case (e.g.) "X86" or "X86_64". + # Matching below is based on lower-case. + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER) +endif() if(OPENSSL_NO_ASM) add_definitions(-DOPENSSL_NO_ASM) From 855a4dea8eebeb6c6b0398fd7c7c8411df1be6fe Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Tue, 17 Sep 2024 17:19:07 +0000 Subject: [PATCH 2/3] only attempt to detect illumos on plausible hosts --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2b7d7320a..ac9e530823 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,16 +61,16 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") endif() endif() -if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "SunOS") # Determine if the host is running an illumos distribution: execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O OUTPUT_STRIP_TRAILING_WHITESPACE) if (UNAME_O STREQUAL "illumos") - set(ILLUMOS 1) + set(HOST_ILLUMOS 1) endif() - if (ILLUMOS) + if (HOST_ILLUMOS) # # illumos systems require linking libsocket and libnsl to get various # networking routines sometimes found in libc on other platforms: @@ -811,7 +811,7 @@ if(OPENSSL_NO_SSE2_FOR_TESTING) add_definitions(-DOPENSSL_NO_SSE2_FOR_TESTING) endif() -if(ILLUMOS) +if(HOST_ILLUMOS) # # CMAKE_SYSTEM_PROCESSOR unfortunately comes from the output of "uname -p", # which on illumos systems emits "i386". Instead, use the value from From 5f213d383f18d8e01437e2dc810508475b6dc55a Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Tue, 17 Sep 2024 17:50:47 +0000 Subject: [PATCH 3/3] also check CMAKE_CROSSCOMPILING --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac9e530823..2b472c7c14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") endif() endif() -if(CMAKE_HOST_SYSTEM_NAME STREQUAL "SunOS") +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "SunOS" AND NOT CMAKE_CROSSCOMPILING) # Determine if the host is running an illumos distribution: execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O OUTPUT_STRIP_TRAILING_WHITESPACE)