Skip to content

Commit

Permalink
Loongson/mips64: Support FFmpeg and openssl.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 9, 2022
1 parent 0a025fc commit 1ab584b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,12 @@ function OSX_prepare()
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi

#####################################################################################
# Whether CPU is loongarch
# Detect CPU archs.
#####################################################################################
OS_IS_LOONGARCH=$(uname -p|grep -q loongarch && echo YES)
OS_IS_LOONGARCH64=$(g++ -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
OS_IS_MIPS64=$(g++ -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)
echo "OS_IS_LOONGARCH64:$OS_IS_LOONGARCH64, OS_IS_MIPS64:$OS_IS_MIPS64, OS_IS_LOONGSON:$OS_IS_LOONGSON"

#####################################################################################
# for Centos, auto install tools by yum
Expand Down Expand Up @@ -553,8 +556,8 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then
fi
# Patch for loongarch mips64, disable ASM for build failed message as bellow:
# Error: opcode not supported on this processor: mips3 (mips3)
g++ -dM -E - </dev/null |grep '#define __mips64 1' -q && OPENSSL_CONFIG="./Configure linux64-mips64"
uname -r |grep -q "loongson" && OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"
if [[ $OS_IS_MIPS64 == YES ]]; then OPENSSL_CONFIG="./Configure linux64-mips64"; fi
if [[ $OS_IS_LOONGSON == YES ]]; then OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"; fi
# For RTC, we should use ASM to improve performance, not a little improving.
if [[ $SRS_RTC == NO || $SRS_NASM == NO ]]; then
OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"
Expand Down Expand Up @@ -627,7 +630,7 @@ if [[ $SRS_RTC == YES ]]; then
if [[ $SRS_CROSS_BUILD == YES ]]; then
SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST"
fi
if [[ $OS_IS_LOONGARCH = YES ]]; then
if [[ $OS_IS_LOONGARCH64 = YES ]]; then
SRTP_OPTIONS="$SRTP_OPTIONS --build=loongarch64-unknown-linux-gnu"
fi
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
Expand Down Expand Up @@ -662,7 +665,7 @@ if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD == NO ]]; then
if [[ $SRS_SHARED_FFMPEG == NO ]]; then
OPUS_OPTIONS="--disable-shared --disable-doc"
fi
if [[ $OS_IS_LOONGARCH = YES ]]; then
if [[ $OS_IS_LOONGARCH64 = YES ]]; then
OPUS_OPTIONS="$OPUS_OPTIONS --build=loongarch64-unknown-linux-gnu"
fi
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1/_release/lib/libopus.a ]]; then
Expand Down Expand Up @@ -702,6 +705,8 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
if [[ $SRS_SHARED_FFMPEG == YES ]]; then
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-shared"
fi
# For loongson/mips64, disable mips64r6, or build failed.
if [[ $OS_IS_MIPS64 == YES && $OS_IS_LOONGSON == YES ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-mips64r6"; fi
# For cross-build.
if [[ $SRS_CROSS_BUILD == YES ]]; then
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-cross-compile --target-os=linux --disable-pthreads"
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
(void)0

// Check CPU for ST(state-threads), please read https://github.com/ossrs/state-threads/issues/22
#if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__loongarch__) && !defined(__riscv)
#error "Only support i386/amd64/x86_64/arm/aarch64/mips/loongarch/riscv cpu"
#if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__mips64) && !defined(__loongarch64) && !defined(__riscv)
#error "Only support i386/amd64/x86_64/arm/aarch64/mips/mips64/loongarch64/riscv cpu"
#endif

// Error predefined for all modules.
Expand Down

1 comment on commit 1ab584b

@winlinvip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2689

Please sign in to comment.