Skip to content

Commit

Permalink
Fix #1685, support RTC cross-build for armv7/armv8(aarch64). 4.0.128
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jun 20, 2021
1 parent 1e9de0e commit 229578c
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 119 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The changelog for SRS.

## SRS 4.0 Changelog

* v4.0, 2021-06-20, Fix [#1685](https://github.com/ossrs/srs/issues/1685), support RTC cross-build for armv7/armv8(aarch64). 4.0.128
* v4.0, 2021-06-17, Fix [#2214](https://github.com/ossrs/srs/issues/2214), remove detection for gmc and gmp.
* v4.0, 2021-06-16, Change [GB28181](https://github.com/ossrs/srs/issues/1500) to [feature/gb28181](https://github.com/ossrs/srs/tree/feature/gb28181). 4.0.127
* v4.0, 2021-06-01, Support --shared-ffmpeg to link with *.so for LGPL license. 4.0.126
Expand Down
3 changes: 0 additions & 3 deletions trunk/3rdparty/libsrtp-2-fit/config_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@
/* Define this to use OpenSSL crypto. */
#undef OPENSSL

/* Define this if OPENSSL_cleanse is broken. */
#undef OPENSSL_CLEANSE_BROKEN

/* Define this to use OpenSSL KDF for SRTP. */
#undef OPENSSL_KDF

Expand Down
54 changes: 0 additions & 54 deletions trunk/3rdparty/libsrtp-2-fit/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5897,60 +5897,6 @@ $as_echo "#define OPENSSL 1" >>confdefs.h
USE_EXTERNAL_CRYPTO=1


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if OPENSSL_cleanse is broken" >&5
$as_echo_n "checking if OPENSSL_cleanse is broken... " >&6; }
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run test program while cross compiling
See \`config.log' for more details" "$LINENO" 5; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <openssl/crypto.h>
int
main ()
{
#define BUFFER_SIZE (16)
char buffer[BUFFER_SIZE];
int i;
for (i = 0; i < BUFFER_SIZE; i++) {
buffer[i] = i & 0xff;
}
OPENSSL_cleanse(buffer, BUFFER_SIZE);
for (i = 0; i < BUFFER_SIZE; i++) {
if (buffer[i]) {
printf("Buffer contents not zero at position %d (is %d)\n", i,
buffer[i]);
return 1;
}
}
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
openssl_cleanse_broken=no
else

openssl_cleanse_broken=yes

$as_echo "#define OPENSSL_CLEANSE_BROKEN 1" >>confdefs.h


fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $openssl_cleanse_broken" >&5
$as_echo "$openssl_cleanse_broken" >&6; }

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to leverage OpenSSL KDF algorithm" >&5
$as_echo_n "checking whether to leverage OpenSSL KDF algorithm... " >&6; }
# Check whether --enable-openssl-kdf was given.
Expand Down
25 changes: 0 additions & 25 deletions trunk/3rdparty/libsrtp-2-fit/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -263,31 +263,6 @@ if test "$enable_openssl" = "yes"; then
HMAC_OBJS=crypto/hash/hmac_ossl.o
AC_SUBST([USE_EXTERNAL_CRYPTO], [1])

AC_MSG_CHECKING([if OPENSSL_cleanse is broken])
AC_RUN_IFELSE([AC_LANG_PROGRAM([
#include <stdio.h>
#include <openssl/crypto.h>
], [
#define BUFFER_SIZE (16)
char buffer[[BUFFER_SIZE]];
int i;
for (i = 0; i < BUFFER_SIZE; i++) {
buffer[[i]] = i & 0xff;
}
OPENSSL_cleanse(buffer, BUFFER_SIZE);
for (i = 0; i < BUFFER_SIZE; i++) {
if (buffer[[i]]) {
printf("Buffer contents not zero at position %d (is %d)\n", i,
buffer[[i]]);
return 1;
}
}
])], [openssl_cleanse_broken=no], [
openssl_cleanse_broken=yes
AC_DEFINE([OPENSSL_CLEANSE_BROKEN], [1], [Define this if OPENSSL_cleanse is broken.])
])
AC_MSG_RESULT([$openssl_cleanse_broken])

AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm])
AC_ARG_ENABLE([openssl-kdf],
[AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])],
Expand Down
2 changes: 1 addition & 1 deletion trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void srtp_cleanse(void *s, size_t len)

void octet_string_set_to_zero(void *s, size_t len)
{
#if defined(OPENSSL) && !defined(OPENSSL_CLEANSE_BROKEN)
#ifdef OPENSSL
OPENSSL_cleanse(s, len);
#else
srtp_cleanse(s, len);
Expand Down
26 changes: 0 additions & 26 deletions trunk/3rdparty/libsrtp-2-fit/crypto/test/datatypes_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ void print_string(char *s);

void test_bswap(void);

void test_set_to_zero(void);

int main(void)
{
/*
Expand Down Expand Up @@ -137,7 +135,6 @@ int main(void)
printf(" } \n");

test_bswap();
test_set_to_zero();

return 0;
}
Expand Down Expand Up @@ -231,26 +228,3 @@ void test_bswap(void)
printf("bswapped octet string: %s\n",
octet_string_hex_string((uint8_t *)&y, 8));
}

void test_set_to_zero(void)
{
#define BUFFER_SIZE (16)
uint8_t buffer[BUFFER_SIZE];
size_t i;

for (i = 0; i < BUFFER_SIZE; i++) {
buffer[i] = i & 0xff;
}
printf("Buffer before: %s\n", octet_string_hex_string(buffer, BUFFER_SIZE));
octet_string_set_to_zero(buffer, BUFFER_SIZE);
printf("Buffer after: %s\n", octet_string_hex_string(buffer, BUFFER_SIZE));
for (i = 0; i < BUFFER_SIZE; i++) {
if (buffer[i]) {
fprintf(stderr,
"Buffer contents not zero at position %zu (is %d)\n", i,
buffer[i]);
abort();
}
}
#undef BUFFER_SIZE
}
23 changes: 15 additions & 8 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then
OPENSSL_CONFIG="./config"
# https://stackoverflow.com/questions/15539062/cross-compiling-of-openssl-for-linux-arm-v5te-linux-gnueabi-toolchain
if [[ $SRS_CROSS_BUILD == YES ]]; then
OPENSSL_CONFIG="./Configure linux-armv4"
OPENSSL_CONFIG="./Configure linux-generic32"
if [[ $SRS_CROSS_BUILD_ARMV7 == YES ]]; then OPENSSL_CONFIG="./Configure linux-armv4"; fi
if [[ $SRS_CROSS_BUILD_AARCH64 == YES ]]; then OPENSSL_CONFIG="./Configure linux-aarch64"; fi
elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then
# Try to use exists libraries.
if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then
Expand Down Expand Up @@ -598,14 +600,16 @@ fi
#####################################################################################
# srtp
#####################################################################################
SRTP_CONFIG="echo SRTP without openssl(ASM) optimization" && SRTP_OPTIONS=""
SRTP_OPTIONS=""
# If use ASM for SRTP, we enable openssl(with ASM).
if [[ $SRS_SRTP_ASM == YES ]]; then
echo "SRTP with openssl(ASM) optimization" &&
SRTP_CONFIG="export PKG_CONFIG_PATH=../openssl/lib/pkgconfig" && SRTP_OPTIONS="--enable-openssl"
SRTP_OPTIONS="--enable-openssl"
SRTP_CONFIGURE="env PKG_CONFIG_PATH=$(cd ${SRS_OBJS}/${SRS_PLATFORM} && pwd)/openssl/lib/pkgconfig ./configure"
else
SRTP_CONFIGURE="./configure"
fi
if [[ $SRS_CROSS_BUILD == YES ]]; then
SRTP_OPTIONS="$SRTP_OPTIONS --host=$(echo $SRS_TOOL_CC|awk -F '-gcc' '{print $1}')"
SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST"
fi
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/_release/lib/libsrtp2.a ]]; then
Expand All @@ -615,7 +619,7 @@ else
(
rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit &&
${SRTP_CONFIG} && ./configure ${SRTP_OPTIONS} --prefix=`pwd`/_release &&
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=`pwd`/_release &&
make ${SRS_JOBS} && make install &&
cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2
)
Expand All @@ -630,6 +634,7 @@ if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build libsrtp-2-fit sta
#####################################################################################
# libopus, for WebRTC to transcode AAC with Opus.
#####################################################################################
# For cross build, we use opus of FFmpeg, so we don't build the libopus.
if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD == NO ]]; then
# Only build static libraries if no shared FFmpeg.
if [[ $SRS_SHARED_FFMPEG == NO ]]; then
Expand Down Expand Up @@ -677,8 +682,10 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
fi
# For cross-build.
if [[ $SRS_CROSS_BUILD == YES ]]; then
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-cross-compile --arch=arm --target-os=linux"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cross-prefix=$(echo $SRS_TOOL_CC|awk -F 'gcc' '{print $1}')"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-cross-compile --target-os=linux"
if [[ $SRS_CROSS_BUILD_ARMV7 ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --arch=arm"; fi
if [[ $SRS_CROSS_BUILD_AARCH64 ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --arch=aarch64"; fi
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cross-prefix=$SRS_CROSS_BUILD_PREFIX"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cc=${SRS_TOOL_CC} --cxx=${SRS_TOOL_CXX} --ar=${SRS_TOOL_AR} --ld=${_ST_LD}"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=opus --enable-encoder=opus"
else
Expand Down
15 changes: 15 additions & 0 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ SRS_GPROF=NO # Performance test: gprof
SRS_X86_X64=NO # For x86_64 servers
SRS_OSX=NO #For osx/macOS PC.
SRS_CROSS_BUILD=NO #For cross build, for example, on Ubuntu.
# For cross build, whether armv7 or armv8(aarch64).
SRS_CROSS_BUILD_ARMV7=NO
SRS_CROSS_BUILD_AARCH64=NO
# For cross build, the host, for example(libsrtp), --host=aarch64-linux-gnu
SRS_CROSS_BUILD_HOST=
# For cross build, the cross prefix, for example(FFmpeg), --cross-prefix=aarch64-linux-gnu-
SRS_CROSS_BUILD_PREFIX=
#
#####################################################################################
# Toolchain for cross-build on Ubuntu for ARM or MIPS.
Expand Down Expand Up @@ -383,6 +390,14 @@ function apply_auto_options() {
SRS_X86_X64=YES; opt="--x86-x64 $opt";
fi

if [[ $SRS_CROSS_BUILD == YES ]]; then
SRS_CROSS_BUILD_HOST=$(echo $SRS_TOOL_CC|awk -F '-gcc' '{print $1}')
SRS_CROSS_BUILD_PREFIX="${SRS_CROSS_BUILD_HOST}-"
echo $SRS_TOOL_CC| grep arm >/dev/null 2>&1 && SRS_CROSS_BUILD_ARMV7=YES
echo $SRS_TOOL_CC| grep aarch64 >/dev/null 2>&1 && SRS_CROSS_BUILD_AARCH64=YES
echo "For cross build, host: $SRS_CROSS_BUILD_HOST, prefix: $SRS_CROSS_BUILD_PREFIX, armv7: $SRS_CROSS_BUILD_ARMV7, aarch64: $SRS_CROSS_BUILD_AARCH64"
fi

# The SRT code in SRS requires c++11, although we build libsrt without c++11.
# TODO: FIXME: Remove c++11 code in SRT of SRS.
if [[ $SRS_SRT == YES ]]; then
Expand Down
2 changes: 1 addition & 1 deletion trunk/auto/setup_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
SRS_PLATFORM="${SRS_PLATFORM}-SRS4"

if [[ $SRS_CROSS_BUILD == YES ]]; then
SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD"
SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD-$(echo $SRS_TOOL_CC|awk -F - '{print $1}')"
fi

echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}"
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 127
#define VERSION_REVISION 128

#endif

0 comments on commit 229578c

Please sign in to comment.