Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static mbedtls x86_64 build #974

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/build-linux-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ jobs:
tag: "22.04"
cflags: ""

- arch: "x86_64"
build_name: "linux-x86_64-static-mbedtls"
docker_image: "ubuntu"
platform: "amd64"
tag: "18.04"
cflags: ""
cmake_opts: "-DAVM_STATIC_MBEDTLS=ON"
install_deps: |
apt update &&
apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev wget tzdata &&
apt purge -y cmake &&
wget https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.tar.gz &&
tar xf cmake-3.13.5-Linux-x86_64.tar.gz &&
mv cmake-3.13.5-Linux-x86_64 /opt/cmake-3.13.5 &&
ln -sf /opt/cmake-3.13.5/bin/* /usr/bin/

- arch: "x86_64"
build_name: "linux-x86_64"
docker_image: "ubuntu"
Expand Down
26 changes: 23 additions & 3 deletions CMakeModules/MbedTLS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@
# If it doesn't work, search for MBEDTLS_VERSION_NUMBER symbol as well as
# the three libraries we need with check_symbol_exists and find_library

option(AVM_STATIC_MBEDTLS "Static link Mbed-TLS." OFF)

if (MBEDTLS_ROOT_DIR)
set(MbedTLS_FOUND TRUE)
if (NOT MBEDTLS_LIBRARIES_DIR)
set(MBEDTLS_LIBRARIES_DIR ${MBEDTLS_ROOT_DIR}/lib)
endif()
message(STATUS "Will use MbedTLS from ${MBEDTLS_ROOT_DIR} and ${MBEDTLS_LIBRARIES_DIR}")

if (AVM_STATIC_MBEDTLS)
message(FATAL_ERROR "AVM_STATIC_MBEDTLS not supported with MbedTLS root dir option")
endif()

add_library(MbedTLS::mbedcrypto SHARED IMPORTED)
set_target_properties(MbedTLS::mbedcrypto PROPERTIES
IMPORTED_LOCATION "${MBEDTLS_LIBRARIES_DIR}/libmbedcrypto${CMAKE_SHARED_LIBRARY_SUFFIX}"
Expand All @@ -64,12 +70,26 @@ else()
find_package(MbedTLS QUIET)
if (MbedTLS_FOUND)
message(STATUS "Found MbedTLS package ${MbedTLS_FOUND}")

if (AVM_STATIC_MBEDTLS)
message(FATAL_ERROR "AVM_STATIC_MBEDTLS not supported with MbedTLS cmake package")
endif()
else()
if (AVM_STATIC_MBEDTLS)
set(MBEDCRYPTO_LIB_NAME "libmbedcrypto.a")
set(MBEDX509_LIB "libmbedx509.a")
set(MBEDTLS_LIB "libmbedtls.a")
else()
set(MBEDCRYPTO_LIB_NAME "mbedcrypto")
set(MBEDX509_LIB "mbedx509")
set(MBEDTLS_LIB "mbedtls")
endif()

include(CheckSymbolExists)
check_symbol_exists(MBEDTLS_VERSION_NUMBER "mbedtls/version.h" HAVE_MBEDTLS_VERSION_NUMBER)
find_library(MBEDCRYPTO mbedcrypto)
find_library(MBEDX509 mbedx509)
find_library(MBEDTLS mbedtls)
find_library(MBEDCRYPTO NAMES ${MBEDCRYPTO_LIB_NAME})
find_library(MBEDX509 NAMES ${MBEDX509_LIB})
find_library(MBEDTLS NAMES ${MBEDTLS_LIB})
if (HAVE_MBEDTLS_VERSION_NUMBER
AND NOT ${MBEDCRYPTO} STREQUAL "MBEDCRYPTO-NOTFOUND"
AND NOT ${MBEDX509} STREQUAL "MBEDX509-NOTFOUND"
Expand Down