Skip to content

Commit de29a8d

Browse files
committed
Distribution Packaging Improvements
1 parent 7b2a86c commit de29a8d

File tree

10 files changed

+583
-107
lines changed

10 files changed

+583
-107
lines changed

.github/workflows/linux_x86_omnibus.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ jobs:
112112
source /opt/compiler-env/setup-clang-9.sh
113113
./tests/ci/run_install_shared_and_static.sh
114114
115+
dist_pkg_tests:
116+
runs-on:
117+
- codebuild-aws-lc-ci-github-actions-${{ github.run_id }}-${{ github.run_attempt }}
118+
image:linux-5.0
119+
instance-size:small
120+
steps:
121+
- uses: actions/checkout@v5
122+
- name: Login to Amazon ECR
123+
id: login-ecr
124+
uses: aws-actions/amazon-ecr-login@v2
125+
- uses: ./.github/actions/codebuild-docker-run
126+
name: Run Container
127+
with:
128+
image: ${{ steps.login-ecr.outputs.registry }}/aws-lc/ubuntu:20.04
129+
run: |
130+
source /opt/compiler-env/setup-clang-9.sh
131+
./tests/ci/run_dist_pkg_tests.sh
132+
115133
# Build and test aws-lc without Perl/Go.
116134
minimal_tests:
117135
name: minimal-${{ matrix.image }}-${{ matrix.compiler }}-x86_64

CMakeLists.txt

Lines changed: 122 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ set(REPORTED_PKGCONFIG_VERSION "1.1.1")
1919
# Defer enabling C and CXX languages.
2020
project(AWSLC VERSION "${SOFTWARE_VERSION}" LANGUAGES NONE)
2121

22+
option(BUILD_TESTING "Build all test targets for AWS-LC" ON)
23+
option(BUILD_LIBSSL "Build libssl for AWS-LC" ON)
24+
option(BUILD_TOOL "Build bssl tool for AWS-LC" ON)
25+
option(DISABLE_PERL "Disable Perl for AWS-LC" OFF)
26+
option(DISABLE_GO "Disable Go for AWS-LC" OFF)
27+
# Keeping this flag for now, for compatibility with existing build configs.
28+
option(ENABLE_FIPS_ENTROPY_CPU_JITTER "Enable FIPS entropy source: CPU Jitter" OFF)
29+
option(ENABLE_DATA_INDEPENDENT_TIMING "Enable automatic setting/resetting Data-Independent Timing
30+
(DIT) flag in cryptographic functions. Currently only applicable to Arm64 (except on Windows)" OFF)
31+
option(ENABLE_PRE_SONAME_BUILD "Build AWS-LC without SONAME configuration for shared library builds" ON)
32+
option(ENABLE_SOURCE_MODIFICATION "Allow the build to update files in the source directory. This is typically done to update versioning." ON)
33+
option(DISABLE_CPU_JITTER_ENTROPY "Disable usage of CPU Jitter Entropy as an entropy source. This option cannot be used with the FIPS build. With this configuration, randomness generation might not use two independent entropy sources." OFF)
34+
option(GENERATE_RUST_BINDINGS "Generate Rust bindings using bindgen-cli" OFF)
35+
option(ENABLE_DIST_PKG "Enables a set of packaging that take highest presedence to any other packaging configuration i.e. ENABLE_PRE_SONAME_BUILD" OFF)
36+
option(ENABLE_DIST_PKG_OPENSSL_SHIM "Controls whether the OpenSSL shim componenets are installed when ENABLE_DIST_PKG is enabled" OFF)
37+
2238
if(MSVC)
2339
# On Windows, prefer cl over gcc if both are available. By default most of
2440
# the CMake generators prefer gcc, even on Windows.
@@ -52,6 +68,52 @@ if(POLICY CMP0077)
5268
cmake_policy(SET CMP0077 NEW) #option does nothing when a normal variable of the same name exists.
5369
endif()
5470

71+
set(RUST_BINDINGS_TARGET_VERSION "1.70" CACHE STRING "Minimum Rust version for generated bindings")
72+
73+
include(cmake/go.cmake)
74+
75+
if(ENABLE_DIST_PKG AND UNIX AND NOT APPLE)
76+
set(SET_LIB_SONAME 1)
77+
set(COHABITANT_HEADERS 1)
78+
if(ENABLE_DIST_PKG_OPENSSL_SHIM)
79+
set(INSTALL_OPENSSL_SHIM 1)
80+
else()
81+
set(INSTALL_OPENSSL_SHIM 0)
82+
endif()
83+
elseif(NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
84+
set(SET_LIB_SONAME 1)
85+
set(COHABITANT_HEADERS 0)
86+
set(INSTALL_OPENSSL_SHIM 1)
87+
else()
88+
set(SET_LIB_SONAME 0)
89+
set(COHABITANT_HEADERS 0)
90+
set(INSTALL_OPENSSL_SHIM 1)
91+
endif()
92+
93+
if(SET_LIB_SONAME)
94+
set(CRYPTO_LIB_NAME "${CRYPTO_LIB_NAME}-${SOFTWARE_NAME}")
95+
set(SSL_LIB_NAME "${SSL_LIB_NAME}-${SOFTWARE_NAME}")
96+
endif()
97+
98+
if (NOT WIN32 AND NOT APPLE)
99+
include(GNUInstallDirs)
100+
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
101+
set(CMAKE_INSTALL_LIBDIR "lib")
102+
set(CMAKE_INSTALL_INCLUDEDIR "include")
103+
set(CMAKE_INSTALL_BINDIR "bin")
104+
endif()
105+
106+
# Set the install include directory based on whether a prefix subdirectory is desired
107+
if(COHABITANT_HEADERS)
108+
set(AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/aws-lc")
109+
else()
110+
set(AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
111+
endif()
112+
113+
if(NOT ENABLE_PRE_SONAME_BUILD)
114+
message(WARNING "ENABLE_PRE_SONAME_BUILD option will be deprecated in a future release. Please see ENABLE_DIST_PKG and ENABLE_DIST_PKG_OPENSSL_SHIM")
115+
endif()
116+
55117
function(target_add_awslc_include_paths)
56118
set(options EXCLUDE_PREFIX_HEADERS)
57119
set(oneValueArgs TARGET SCOPE)
@@ -81,37 +143,9 @@ function(target_add_awslc_include_paths)
81143
target_include_directories(${arg_TARGET} BEFORE ${arg_SCOPE}
82144
$<$<BOOL:${INCLUDE_PREFIX_HEADERS}>:$<BUILD_INTERFACE:${AWSLC_BINARY_DIR}/symbol_prefix_include>>
83145
$<BUILD_INTERFACE:${AWSLC_SOURCE_DIR}/include>
84-
$<INSTALL_INTERFACE:include>)
146+
$<INSTALL_INTERFACE:${AWSLC_INSTALL_INCLUDEDIR}>)
85147
endfunction()
86148

87-
option(BUILD_TESTING "Build all test targets for AWS-LC" ON)
88-
option(BUILD_LIBSSL "Build libssl for AWS-LC" ON)
89-
option(BUILD_TOOL "Build bssl tool for AWS-LC" ON)
90-
option(DISABLE_PERL "Disable Perl for AWS-LC" OFF)
91-
option(DISABLE_GO "Disable Go for AWS-LC" OFF)
92-
# Keeping this flag for now, for compatibility with existing build configs.
93-
option(ENABLE_FIPS_ENTROPY_CPU_JITTER "Enable FIPS entropy source: CPU Jitter" OFF)
94-
option(ENABLE_DATA_INDEPENDENT_TIMING "Enable automatic setting/resetting Data-Independent Timing
95-
(DIT) flag in cryptographic functions. Currently only applicable to Arm64 (except on Windows)" OFF)
96-
option(ENABLE_PRE_SONAME_BUILD "Build AWS-LC without SONAME configuration for shared library builds" ON)
97-
option(ENABLE_SOURCE_MODIFICATION "Allow the build to update files in the source directory. This is typically done to update versioning." ON)
98-
option(DISABLE_CPU_JITTER_ENTROPY "Disable usage of CPU Jitter Entropy as an entropy source. This option cannot be used with the FIPS build. With this configuration, randomness generation might not use two independent entropy sources." OFF)
99-
option(GENERATE_RUST_BINDINGS "Generate Rust bindings using bindgen-cli" OFF)
100-
set(RUST_BINDINGS_TARGET_VERSION "1.70" CACHE STRING "Minimum Rust version for generated bindings")
101-
102-
include(cmake/go.cmake)
103-
104-
if(NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
105-
set(PERFORM_SONAME_BUILD 1)
106-
set(CRYPTO_LIB_NAME "${CRYPTO_LIB_NAME}-${SOFTWARE_NAME}")
107-
set(SSL_LIB_NAME "${SSL_LIB_NAME}-${SOFTWARE_NAME}")
108-
else()
109-
set(PERFORM_SONAME_BUILD 0)
110-
endif()
111-
112-
message(STATUS "ENABLE_PRE_SONAME_BUILD: ${ENABLE_PRE_SONAME_BUILD}")
113-
message(STATUS "PERFORM_SONAME_BUILD: ${PERFORM_SONAME_BUILD}")
114-
115149
enable_language(C)
116150

117151
# Validate Rust bindings prerequisites
@@ -168,8 +202,6 @@ else()
168202
message(STATUS "Entropy source configured: Dynamic (default: CPU Jitter)")
169203
endif()
170204

171-
172-
173205
if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
174206
# OpenBSD by defaults links with --execute-only this is problematic for two reasons:
175207
# 1. The FIPS shared and static builds need to compute the module signature hash by reading the .text section
@@ -254,16 +286,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
254286
set(GCC 1)
255287
endif()
256288

257-
if (NOT WIN32 AND NOT APPLE)
258-
include(GNUInstallDirs)
259-
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
260-
set(CMAKE_INSTALL_LIBDIR "lib")
261-
set(CMAKE_INSTALL_INCLUDEDIR "include")
262-
set(CMAKE_INSTALL_BINDIR "bin")
263-
endif()
264-
265289
install(DIRECTORY include/openssl
266-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
290+
DESTINATION ${AWSLC_INSTALL_INCLUDEDIR}
267291
COMPONENT Development
268292
PATTERN boringssl_prefix_symbols.h EXCLUDE
269293
PATTERN boringssl_prefix_symbols_asm.h EXCLUDE
@@ -364,7 +388,7 @@ if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND GO_EXECUTABLE)
364388
symbol_prefix_include/openssl/boringssl_prefix_symbols_nasm.inc)
365389

366390
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl
367-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
391+
DESTINATION ${AWSLC_INSTALL_INCLUDEDIR}
368392
COMPONENT Development
369393
)
370394
elseif(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
@@ -384,7 +408,7 @@ elseif(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
384408
add_custom_target(boringssl_prefix_symbols)
385409

386410
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl
387-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
411+
DESTINATION ${AWSLC_INSTALL_INCLUDEDIR}
388412
COMPONENT Development
389413
)
390414
elseif(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND NOT GO_EXECUTABLE)
@@ -398,7 +422,7 @@ else()
398422
add_custom_target(boringssl_prefix_symbols)
399423

400424
install(DIRECTORY include/openssl
401-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
425+
DESTINATION ${AWSLC_INSTALL_INCLUDEDIR}
402426
COMPONENT Development
403427
FILES_MATCHING
404428
PATTERN boringssl_prefix_symbols.h
@@ -1466,15 +1490,22 @@ endif()
14661490
file(GLOB OPENSSL_PKGCONFIGS "pkgconfig/*.pc.in")
14671491

14681492
include(cmake/JoinPaths.cmake)
1469-
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
1470-
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
1471-
1472-
foreach(in_file ${OPENSSL_PKGCONFIGS})
1473-
file(RELATIVE_PATH in_file ${AWSLC_SOURCE_DIR} ${in_file})
1474-
string(REPLACE ".in" "" pc_file ${in_file})
1475-
configure_file(${in_file} ${CMAKE_CURRENT_BINARY_DIR}/${pc_file} @ONLY)
1476-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_file} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
1477-
endforeach()
1493+
join_paths(LIBDIR_FOR_PC_FILE "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
1494+
join_paths(INCLUDEDIR_FOR_PC_FILE "\${prefix}" "${AWSLC_INSTALL_INCLUDEDIR}")
1495+
1496+
function(install_pkgconfig_file)
1497+
set(options "")
1498+
set(oneValueArgs TEMPLATE DEST)
1499+
set(multiValueArgs)
1500+
if(CMAKE_VERSION VERSION_LESS "3.7")
1501+
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
1502+
else()
1503+
cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${oneValueArgs}" "${multiValueArgs}")
1504+
endif()
1505+
1506+
configure_file(pkgconfig/${arg_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${arg_DEST} @ONLY)
1507+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${arg_DEST} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
1508+
endfunction()
14781509

14791510
if(ENABLE_SOURCE_MODIFICATION)
14801511
configure_file(include/openssl/base.h.in ${AWSLC_SOURCE_DIR}/include/openssl/base.h @ONLY)
@@ -1483,3 +1514,42 @@ if(ENABLE_SOURCE_MODIFICATION)
14831514
configure_file(util/check-linkage.sh.in check-linkage.sh @ONLY)
14841515
endif()
14851516
endif()
1517+
1518+
install_pkgconfig_file(TEMPLATE product.pc.in DEST aws-lc.pc)
1519+
install_pkgconfig_file(TEMPLATE libcrypto.pc.in DEST lib${CRYPTO_LIB_NAME}.pc)
1520+
install_pkgconfig_file(TEMPLATE libssl.pc.in DEST lib${SSL_LIB_NAME}.pc)
1521+
1522+
if(INSTALL_OPENSSL_SHIM)
1523+
install_pkgconfig_file(TEMPLATE product.pc.in DEST openssl.pc)
1524+
1525+
# Create OpenSSL compatibility symlinks
1526+
if(BUILD_SHARED_LIBS)
1527+
if(SET_LIB_SONAME)
1528+
# When SONAME build is enabled, libraries have -awslc suffix
1529+
install(CODE "
1530+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
1531+
lib${CRYPTO_LIB_NAME}.so \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcrypto.so\")
1532+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
1533+
lib${SSL_LIB_NAME}.so \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libssl.so\")
1534+
")
1535+
endif()
1536+
else()
1537+
if(SET_LIB_SONAME)
1538+
# When SONAME build is enabled, libraries have -awslc suffix
1539+
install(CODE "
1540+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
1541+
lib${CRYPTO_LIB_NAME}.a \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcrypto.a\")
1542+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
1543+
lib${SSL_LIB_NAME}.a \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libssl.a\")
1544+
" COMPONENT Development)
1545+
endif()
1546+
endif()
1547+
1548+
if(COHABITANT_HEADERS)
1549+
# Always create the include directory symlink for OpenSSL compatibility
1550+
install(CODE "
1551+
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
1552+
aws-lc/openssl \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/openssl\")
1553+
" COMPONENT Development)
1554+
endif()
1555+
endif()

crypto/CMakeLists.txt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ function(build_libcrypto)
618618
set_target_properties(${arg_NAME} PROPERTIES OUTPUT_NAME "${CRYPTO_LIB_NAME}")
619619
endif()
620620

621-
if(PERFORM_SONAME_BUILD)
621+
if(SET_LIB_SONAME)
622622
set_target_properties(${arg_NAME} PROPERTIES
623623
VERSION "${SOFTWARE_VERSION}"
624624
SOVERSION "${ABI_VERSION}")
@@ -918,12 +918,19 @@ if(BUILD_TESTING)
918918

919919
endif()
920920

921-
install(TARGETS crypto
922-
EXPORT crypto-targets
923-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
924-
LIBRARY
925-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
926-
NAMELINK_SKIP)
921+
if(NOT CMAKE_VERSION VERSION_LESS "3.12")
922+
install(TARGETS crypto
923+
EXPORT crypto-targets
924+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
925+
LIBRARY
926+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
927+
NAMELINK_COMPONENT Development)
928+
else()
929+
install(TARGETS crypto
930+
EXPORT crypto-targets
931+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
932+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
933+
endif()
927934

928935
if(MSVC AND CMAKE_BUILD_TYPE_LOWER MATCHES "relwithdebinfo" AND FIPS)
929936
install (FILES $<TARGET_FILE_DIR:crypto>/crypto.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -947,13 +954,3 @@ install(EXPORT crypto-targets
947954
DESTINATION "${CMAKE_INSTALL_LIBDIR}/crypto/cmake/${TARGET_DIR}"
948955
NAMESPACE AWS::
949956
COMPONENT Development)
950-
951-
if(PERFORM_SONAME_BUILD)
952-
install(CODE "
953-
set(TGT lib${CRYPTO_LIB_NAME}.so.${ABI_VERSION})
954-
set(LNK \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcrypto.so)
955-
message(STATUS \"Creating symlink: \${LNK} → \${TGT}\")
956-
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \${TGT} \${LNK})
957-
"
958-
COMPONENT Development)
959-
endif()

pkgconfig/libcrypto.pc.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
libdir=@libdir_for_pc_file@
3-
includedir=@includedir_for_pc_file@
2+
libdir=@LIBDIR_FOR_PC_FILE@
3+
includedir=@INCLUDEDIR_FOR_PC_FILE@
44

5-
Name: AWS-LC-libcrypto
6-
Description: AWS-LC cryptography library
5+
Name: lib@CRYPTO_LIB_NAME@
6+
Description: AWS-LC Cryptographic Library (@SOFTWARE_VERSION@)
77
Version: @REPORTED_PKGCONFIG_VERSION@
8-
Libs: -L${libdir} -lcrypto
8+
Libs: -L${libdir} -l@CRYPTO_LIB_NAME@
99
Cflags: -I${includedir}

pkgconfig/libssl.pc.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
libdir=@libdir_for_pc_file@
3-
includedir=@includedir_for_pc_file@
2+
libdir=@LIBDIR_FOR_PC_FILE@
3+
includedir=@INCLUDEDIR_FOR_PC_FILE@
44

5-
Name: AWS-LC-libssl
6-
Description: AWS-LC (OpenSSL SHIM)
5+
Name: lib@SSL_LIB_NAME@
6+
Description: AWS-LC TLS Library (@SOFTWARE_VERSION@)
77
Version: @REPORTED_PKGCONFIG_VERSION@
8-
Requires.private: libcrypto
9-
Libs: -L${libdir} -lssl
8+
Requires.private: lib@CRYPTO_LIB_NAME@
9+
Libs: -L${libdir} -l@SSL_LIB_NAME@
1010
Cflags: -I${includedir}

pkgconfig/openssl.pc.in

Lines changed: 0 additions & 8 deletions
This file was deleted.

pkgconfig/product.pc.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
libdir=@LIBDIR_FOR_PC_FILE@
3+
includedir=@INCLUDEDIR_FOR_PC_FILE@
4+
5+
Name: AWS-LC
6+
Description: AWS-LC (@SOFTWARE_VERSION@)
7+
Version: @REPORTED_PKGCONFIG_VERSION@
8+
Requires: lib@CRYPTO_LIB_NAME@ lib@SSL_LIB_NAME@

0 commit comments

Comments
 (0)