From 44a93a1d35c318ba80b5b582adfe6f0c03cd0ccb Mon Sep 17 00:00:00 2001 From: Divya Sampath Kumar Date: Mon, 9 Oct 2023 08:24:12 -0700 Subject: [PATCH] Fix mbedtls build failure for 22.04 (#1823) * Fix mbedtls build failure for 22.04 * Fix CI gcc 11 mbedtls * Dont install gcc4.4 * Use the c flags in mbedtls object * Move string op error elsewhere --- .github/workflows/ci.yml | 34 ++++++++++++++++++++ CMake/Dependencies/libmbedtls-CMakeLists.txt | 2 ++ CMakeLists.txt | 15 ++++++--- src/source/PeerConnection/Rtcp.h | 4 +-- src/source/Rtp/RtpPacket.h | 2 +- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce297b5aa0..69e38c27c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -350,6 +350,40 @@ jobs: run: | cd build timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + + mbedtls-ubuntu-gcc-11: + runs-on: ubuntu-latest + env: + AWS_KVS_LOG_LEVEL: 2 + permissions: + id-token: write + contents: read + steps: + - name: Clone repository + uses: actions/checkout@v3 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Install deps + run: | + sudo apt clean && sudo apt update + sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy main' + sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy universe' + sudo apt-get -q update + - name: Build repository + run: | + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON + make + ulimit -c unlimited -S + - name: Run tests + run: | + cd build + timeout --signal=SIGABRT 60m ./tst/webrtc_client_test mbedtls-ubuntu-clang: runs-on: ubuntu-20.04 env: diff --git a/CMake/Dependencies/libmbedtls-CMakeLists.txt b/CMake/Dependencies/libmbedtls-CMakeLists.txt index 66ae44d0e0..aad9516994 100644 --- a/CMake/Dependencies/libmbedtls-CMakeLists.txt +++ b/CMake/Dependencies/libmbedtls-CMakeLists.txt @@ -16,6 +16,8 @@ else() set(CMAKE_MACOSX_RPATH 0) endif() +message(STATUS "C flags here are ${CMAKE_C_FLAGS}") + ExternalProject_Add( project_libmbedtls GIT_REPOSITORY https://github.com/ARMmbed/mbedtls.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 5da2ec0b0f..7a4943fd89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,8 +108,15 @@ if(USE_OPENSSL) elseif(USE_MBEDTLS) add_definitions(-DKVS_USE_MBEDTLS) # FIXME: there's probably a better way to inject MBEDTLS_USER_CONFIG_FILE flag without mutating the global CMAKE_C_FLAGS and CMAKE_CXX_FLAGS - set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_CXX_FLAGS}") + if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") + message(STATUS "Detected clang") + set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_CXX_FLAGS}") + else() + message(STATUS "Detected gcc") + set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_CXX_FLAGS}") + endif() endif() if(BUILD_DEPENDENCIES) @@ -137,8 +144,8 @@ if(BUILD_DEPENDENCIES) set(OPENSSL_ROOT_DIR ${OPEN_SRC_INSTALL_PREFIX}) elseif(USE_MBEDTLS) set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} - "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -std=c99") - build_dependency(mbedtls ${BUILD_ARGS}) + "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -std=c99") + build_dependency(mbedtls ${BUILD_ARGS}) endif() diff --git a/src/source/PeerConnection/Rtcp.h b/src/source/PeerConnection/Rtcp.h index 513d29f0b8..229cebbe3f 100644 --- a/src/source/PeerConnection/Rtcp.h +++ b/src/source/PeerConnection/Rtcp.h @@ -31,7 +31,7 @@ typedef enum { #define TWCC_FB_PACKETCHUNK_SIZE 2 #define IS_TWCC_RUNLEN(packetChunk) ((((packetChunk) >> 15u) & 1u) == 0) #define TWCC_RUNLEN_STATUS_SYMBOL(packetChunk) (((packetChunk) >> 13u) & 3u) -#define TWCC_RUNLEN_GET(packetChunk) ((packetChunk) &0x1fffu) +#define TWCC_RUNLEN_GET(packetChunk) ((packetChunk) & 0x1fffu) #define TWCC_IS_NOTRECEIVED(statusSymbol) ((statusSymbol) == TWCC_STATUS_SYMBOL_NOTRECEIVED) #define TWCC_ISRECEIVED(statusSymbol) ((statusSymbol) == TWCC_STATUS_SYMBOL_SMALLDELTA || (statusSymbol) == TWCC_STATUS_SYMBOL_LARGEDELTA) #define TWCC_RUNLEN_ISRECEIVED(packetChunk) TWCC_ISRECEIVED(TWCC_RUNLEN_STATUS_SYMBOL(packetChunk)) @@ -39,7 +39,7 @@ typedef enum { #define TWCC_STATUSVECTOR_SSIZE(packetChunk) (TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 2u : 1u) #define TWCC_STATUSVECTOR_SMASK(packetChunk) (TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 2u : 1u) #define TWCC_STATUSVECTOR_STATUS(packetChunk, i) \ - (((packetChunk) >> (14u - (i) *TWCC_STATUSVECTOR_SSIZE(packetChunk))) & TWCC_STATUSVECTOR_SMASK(packetChunk)) + (((packetChunk) >> (14u - (i) * TWCC_STATUSVECTOR_SSIZE(packetChunk))) & TWCC_STATUSVECTOR_SMASK(packetChunk)) #define TWCC_STATUSVECTOR_COUNT(packetChunk) (TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 7 : 14) #define TWCC_PACKET_STATUS_COUNT(payload) (getUnalignedInt16BigEndian((payload) + 10)) diff --git a/src/source/Rtp/RtpPacket.h b/src/source/Rtp/RtpPacket.h index 68025c7e4a..c8dc874d22 100644 --- a/src/source/Rtp/RtpPacket.h +++ b/src/source/Rtp/RtpPacket.h @@ -46,7 +46,7 @@ extern "C" { */ // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01 #define TWCC_EXT_PROFILE 0xBEDE -#define TWCC_PAYLOAD(extId, sequenceNum) htonl((((extId) &0xfu) << 28u) | (1u << 24u) | ((UINT32) (sequenceNum) << 8u)) +#define TWCC_PAYLOAD(extId, sequenceNum) htonl((((extId) & 0xfu) << 28u) | (1u << 24u) | ((UINT32) (sequenceNum) << 8u)) #define TWCC_SEQNUM(extPayload) ((UINT16) getUnalignedInt16BigEndian(extPayload + 1)) typedef STATUS (*DepayRtpPayloadFunc)(PBYTE, UINT32, PBYTE, PUINT32, PBOOL);