Skip to content

Commit 9651480

Browse files
edmundlodjustsmth
andauthored
Fix: Apply COHABITANT_HEADERS logic to location of tool binaries (#3116)
### Problem: `aws-lc` installs binaries in the BINDIR. The binaries that are installed are: `bssl`, `c_rehash`, and `openssl`. On a system with OpenSSL installed, this will cause an error, or it will cause existing OpenSSL binaries to be overwritten by `aws-lc` ones. Since aws-lc version 1.71.0 COHABITANT_HEADERS is used to rewrite the installation location of library and header files. This should be extended to the binaries. ### Solution: Use the same COHABITANT_HEADERS logic from #3042 to potentially change the binary destination. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. --------- Co-authored-by: Justin Smith <justsmth@amazon.com> Co-authored-by: Justin W Smith <103147162+justsmth@users.noreply.github.com>
1 parent 3f7f9a5 commit 9651480

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ if(ENABLE_DIST_PKG)
8686
else()
8787
set(SET_LIB_SONAME 1)
8888
set(COHABITANT_HEADERS 1)
89+
set(COHABITANT_BINARIES 1)
8990
if(ENABLE_DIST_PKG_OPENSSL_SHIM)
9091
set(INSTALL_OPENSSL_SHIM 1)
9192
else()
@@ -95,15 +96,18 @@ if(ENABLE_DIST_PKG)
9596
elseif(NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
9697
set(SET_LIB_SONAME 1)
9798
set(COHABITANT_HEADERS 0)
99+
set(COHABITANT_BINARIES 0)
98100
set(INSTALL_OPENSSL_SHIM 1)
99101
else()
100102
set(SET_LIB_SONAME 0)
101103
set(COHABITANT_HEADERS 0)
104+
set(COHABITANT_BINARIES 0)
102105
set(INSTALL_OPENSSL_SHIM 1)
103106
endif()
104107

105108
message(STATUS "SET_LIB_SONAME: ${SET_LIB_SONAME}")
106109
message(STATUS "COHABITANT_HEADERS: ${COHABITANT_HEADERS}")
110+
message(STATUS "COHABITANT_BINARIES: ${COHABITANT_BINARIES}")
107111
message(STATUS "INSTALL_OPENSSL_SHIM: ${INSTALL_OPENSSL_SHIM}")
108112

109113
if(SET_LIB_SONAME)
@@ -134,6 +138,13 @@ else()
134138
set(AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
135139
endif()
136140

141+
# Set the install bin prefix based on whether cohabitation is desired
142+
if(COHABITANT_BINARIES)
143+
set(AWSLC_BIN_PREFIX "aws-lc-")
144+
else()
145+
set(AWSLC_BIN_PREFIX "")
146+
endif()
147+
137148
function(target_add_awslc_include_paths)
138149
set(options EXCLUDE_PREFIX_HEADERS)
139150
set(oneValueArgs TARGET SCOPE)

tool-openssl/CMakeLists.txt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ endif()
5858

5959
target_add_awslc_include_paths(TARGET openssl SCOPE PRIVATE)
6060

61+
if(COHABITANT_BINARIES)
62+
set_target_properties(openssl PROPERTIES OUTPUT_NAME "${AWSLC_BIN_PREFIX}openssl")
63+
endif()
64+
6165
install(TARGETS openssl
6266
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
6367
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -76,10 +80,16 @@ file(INSTALL
7680
c_rehash
7781
)
7882

83+
set(C_REHASH_INSTALL_NAME "c_rehash")
84+
85+
if(COHABITANT_BINARIES)
86+
set(C_REHASH_INSTALL_NAME "${AWSLC_BIN_PREFIX}c_rehash")
87+
endif()
88+
7989
install(
80-
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/c_rehash.sh
81-
RENAME c_rehash
82-
DESTINATION ${CMAKE_INSTALL_BINDIR}
90+
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/c_rehash.sh
91+
RENAME ${C_REHASH_INSTALL_NAME}
92+
DESTINATION ${CMAKE_INSTALL_BINDIR}
8393
)
8494

8595
if(MSVC AND CMAKE_BUILD_TYPE_LOWER MATCHES "relwithdebinfo" AND FIPS)
@@ -165,3 +175,13 @@ if(BUILD_TESTING)
165175
add_dependencies(tool_openssl_test openssl)
166176
set_test_location(tool_openssl_test)
167177
endif()
178+
179+
# Create binary symlinks for OpenSSL compatibility
180+
if(INSTALL_OPENSSL_SHIM AND COHABITANT_BINARIES)
181+
install(CODE "
182+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
183+
\"${AWSLC_BIN_PREFIX}openssl\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/openssl\")
184+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
185+
\"${AWSLC_BIN_PREFIX}c_rehash\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/c_rehash\")
186+
")
187+
endif()

tool/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ else()
4141
endif()
4242
endif()
4343

44+
if(COHABITANT_BINARIES)
45+
set_target_properties(bssl PROPERTIES OUTPUT_NAME "${AWSLC_BIN_PREFIX}bssl")
46+
endif()
47+
4448
install(TARGETS bssl
4549
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
4650
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}

0 commit comments

Comments
 (0)