From f6e655396c98a0f5ad234a690a66704f653f8b95 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 23 Sep 2015 11:54:53 +0800 Subject: [PATCH 1/2] for #485, support cross build for arm --- trunk/auto/auto_headers.sh | 23 -------------- trunk/auto/setup_variables.sh | 30 +++++++++++++++++++ trunk/configure | 3 ++ .../srs_xcode.xcodeproj/project.pbxproj | 2 ++ 4 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 trunk/auto/setup_variables.sh diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 835e68683..1174ce9b9 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -43,29 +43,6 @@ echo "" >> $SRS_AUTO_HEADERS_H ##################################################################################### # generate auto headers file, depends on the finished of options.sh ##################################################################################### -if [ $SRS_ARM_UBUNTU12 = YES ]; then - __SrsArmCC="arm-linux-gnueabi-gcc"; - __SrsArmGCC="arm-linux-gnueabi-gcc"; - __SrsArmCXX="arm-linux-gnueabi-g++"; - __SrsArmAR="arm-linux-gnueabi-ar"; - __SrsArmLD="arm-linux-gnueabi-ld"; - __SrsArmRANDLIB="arm-linux-gnueabi-ranlib"; -fi -if [ $SRS_MIPS_UBUNTU12 = YES ]; then - __SrsArmCC="mipsel-openwrt-linux-gcc"; - __SrsArmGCC="mipsel-openwrt-linux-gcc"; - __SrsArmCXX="mipsel-openwrt-linux-g++"; - __SrsArmAR="mipsel-openwrt-linux-ar"; - __SrsArmLD="mipsel-openwrt-linux-ld"; - __SrsArmRANDLIB="mipsel-openwrt-linux-ranlib"; -fi -# the arm-ubuntu12 options for make for depends -if [[ -z $SrsArmCC ]]; then SrsArmCC=$__SrsArmCC; fi -if [[ -z $SrsArmGCC ]]; then SrsArmGCC=$__SrsArmGCC; fi -if [[ -z $SrsArmCXX ]]; then SrsArmCXX=$__SrsArmCXX; fi -if [[ -z $SrsArmAR ]]; then SrsArmAR=$__SrsArmAR; fi -if [[ -z $SrsArmLD ]]; then SrsArmLD=$__SrsArmLD; fi -if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=$__SrsArmRANDLIB; fi # write to source file if [ $SRS_CROSS_BUILD = YES ]; then echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB" diff --git a/trunk/auto/setup_variables.sh b/trunk/auto/setup_variables.sh new file mode 100644 index 000000000..d1d643b4f --- /dev/null +++ b/trunk/auto/setup_variables.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# when options parsed, setup some variables, then build the depends. + +# when arm specified, setup the cross build variables. +if [ $SRS_ARM_UBUNTU12 = YES ]; then + __SrsArmCC="arm-linux-gnueabi-gcc"; + __SrsArmGCC="arm-linux-gnueabi-gcc"; + __SrsArmCXX="arm-linux-gnueabi-g++"; + __SrsArmAR="arm-linux-gnueabi-ar"; + __SrsArmLD="arm-linux-gnueabi-ld"; + __SrsArmRANDLIB="arm-linux-gnueabi-ranlib"; +fi + +if [ $SRS_MIPS_UBUNTU12 = YES ]; then + __SrsArmCC="mipsel-openwrt-linux-gcc"; + __SrsArmGCC="mipsel-openwrt-linux-gcc"; + __SrsArmCXX="mipsel-openwrt-linux-g++"; + __SrsArmAR="mipsel-openwrt-linux-ar"; + __SrsArmLD="mipsel-openwrt-linux-ld"; + __SrsArmRANDLIB="mipsel-openwrt-linux-ranlib"; +fi + +# the arm-ubuntu12 options for make for depends +if [[ -z $SrsArmCC ]]; then SrsArmCC=$__SrsArmCC; fi +if [[ -z $SrsArmGCC ]]; then SrsArmGCC=$__SrsArmGCC; fi +if [[ -z $SrsArmCXX ]]; then SrsArmCXX=$__SrsArmCXX; fi +if [[ -z $SrsArmAR ]]; then SrsArmAR=$__SrsArmAR; fi +if [[ -z $SrsArmLD ]]; then SrsArmLD=$__SrsArmLD; fi +if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=$__SrsArmRANDLIB; fi diff --git a/trunk/configure b/trunk/configure index 9534a6cdc..4332b5d6b 100755 --- a/trunk/configure +++ b/trunk/configure @@ -23,6 +23,9 @@ BLACK="\\033[0m" # parse options, exit with error when parse options invalid. . auto/options.sh +# setup variables when options parsed. +. auto/setup_variables.sh + # clean the exists, when not export srs-librtmp. # do this only when the options is ok. if [[ -f Makefile ]]; then diff --git a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj index a9b9fd372..0e8733428 100644 --- a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj +++ b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj @@ -352,6 +352,7 @@ 3C689F9B1AB6AAC800C9CEEE /* sched.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sched.c; path = "../../objs/st-1.9/sched.c"; sourceTree = ""; }; 3C689F9C1AB6AAC800C9CEEE /* stk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stk.c; path = "../../objs/st-1.9/stk.c"; sourceTree = ""; }; 3C689F9D1AB6AAC800C9CEEE /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync.c; path = "../../objs/st-1.9/sync.c"; sourceTree = ""; }; + 3CB25C281BB2596300C97A63 /* setup_variables.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = setup_variables.sh; path = ../../../auto/setup_variables.sh; sourceTree = ""; }; 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_amf0.cpp; path = ../../src/utest/srs_utest_amf0.cpp; sourceTree = ""; }; 3CC52DCB1ACE4023006FEB01 /* srs_utest_amf0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_utest_amf0.hpp; path = ../../src/utest/srs_utest_amf0.hpp; sourceTree = ""; }; 3CC52DCC1ACE4023006FEB01 /* srs_utest_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_config.cpp; path = ../../src/utest/srs_utest_config.cpp; sourceTree = ""; }; @@ -632,6 +633,7 @@ 3C1232C31AAE827E00CE8F6C /* local_ip.sh */, 3C1232C41AAE827E00CE8F6C /* modules.sh */, 3C1232C51AAE827E00CE8F6C /* options.sh */, + 3CB25C281BB2596300C97A63 /* setup_variables.sh */, 3C1232C61AAE827E00CE8F6C /* summary.sh */, 3C1232C71AAE827E00CE8F6C /* utest.sh */, ); From cfe2082353d071567927293194814e13c561f2ec Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 23 Sep 2015 15:09:59 +0800 Subject: [PATCH 2/2] fix #485, error when arm glibc 2.15+ or not i386/x86_64/amd64. 2.0.192 --- README.md | 1 + trunk/auto/depends.sh | 12 ++++++---- .../srs_xcode.xcodeproj/project.pbxproj | 4 ++++ trunk/research/arm/jmp_sp.cpp | 24 +++---------------- trunk/src/core/srs_core.hpp | 14 ++++++++++- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index dd4952615..c352bc492 100755 --- a/README.md +++ b/README.md @@ -335,6 +335,7 @@ Remark: ## History +* v2.0, 2015-09-23, for [#485][bug #485] error when arm glibc 2.15+ or not i386/x86_64/amd64. 2.0.192 * v2.0, 2015-09-23, for [#485][bug #485] srs for respberrypi and cubieboard. 2.0.191 * v2.0, 2015-09-21, fix [#484][bug #484] hotfix the openssl build script 2.0.190 * v2.0, 2015-09-14, [2.0 alpha1(2.0.189)][r2.0a1] released. 89269 lines. diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index cf7feaa4a..8974c3d33 100644 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -38,7 +38,11 @@ function Ubuntu_prepare() else uname -v|grep Ubuntu >/dev/null 2>&1 ret=$?; if [[ 0 -ne $ret ]]; then - return 0; + # for debian, we think it's ubuntu also. + # for example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v. + if [[ ! -f /etc/debian_version ]]; then + return 0; + fi fi fi @@ -378,7 +382,7 @@ fi ##################################################################################### if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then # check the cross build flag file, if flag changed, need to rebuild the st. - _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="EXTRA_CFLAGS=-DMD_HAVE_EPOLL" + _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" # for osx, use darwin for st, donot use epoll. if [ $OS_IS_OSX = YES ]; then _ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="EXTRA_CFLAGS=-DMD_HAVE_KQUEUE" @@ -399,7 +403,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then patch -p0 < ../../3rdparty/patches/1.st.arm.patch && patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch && patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch && - make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} ${_ST_EXTRA_CFLAGS} && + make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" && cd .. && rm -rf st && ln -sf st-1.9/obj st && cd .. && touch ${SRS_OBJS}/_flag.st.cross.build.tmp ) @@ -416,7 +420,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then patch -p0 < ../../3rdparty/patches/1.st.arm.patch && patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch && patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch && - make ${_ST_MAKE} ${_ST_EXTRA_CFLAGS} && + make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" && cd .. && rm -rf st && ln -sf st-1.9/obj st && cd .. && rm -f ${SRS_OBJS}/_flag.st.cross.build.tmp ) diff --git a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj index 0e8733428..91f7be634 100644 --- a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj +++ b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ 3C689F9F1AB6AAC800C9CEEE /* sched.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9B1AB6AAC800C9CEEE /* sched.c */; }; 3C689FA01AB6AAC800C9CEEE /* stk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9C1AB6AAC800C9CEEE /* stk.c */; }; 3C689FA11AB6AAC800C9CEEE /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9D1AB6AAC800C9CEEE /* sync.c */; }; + 3CB25C2A1BB269FD00C97A63 /* jmp_sp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */; }; 3CC52DD81ACE4023006FEB01 /* srs_utest_amf0.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */; }; 3CC52DD91ACE4023006FEB01 /* srs_utest_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCC1ACE4023006FEB01 /* srs_utest_config.cpp */; }; 3CC52DDA1ACE4023006FEB01 /* srs_utest_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCE1ACE4023006FEB01 /* srs_utest_core.cpp */; }; @@ -353,6 +354,7 @@ 3C689F9C1AB6AAC800C9CEEE /* stk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stk.c; path = "../../objs/st-1.9/stk.c"; sourceTree = ""; }; 3C689F9D1AB6AAC800C9CEEE /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync.c; path = "../../objs/st-1.9/sync.c"; sourceTree = ""; }; 3CB25C281BB2596300C97A63 /* setup_variables.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = setup_variables.sh; path = ../../../auto/setup_variables.sh; sourceTree = ""; }; + 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jmp_sp.cpp; path = ../../../research/arm/jmp_sp.cpp; sourceTree = ""; }; 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_amf0.cpp; path = ../../src/utest/srs_utest_amf0.cpp; sourceTree = ""; }; 3CC52DCB1ACE4023006FEB01 /* srs_utest_amf0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_utest_amf0.hpp; path = ../../src/utest/srs_utest_amf0.hpp; sourceTree = ""; }; 3CC52DCC1ACE4023006FEB01 /* srs_utest_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_config.cpp; path = ../../src/utest/srs_utest_config.cpp; sourceTree = ""; }; @@ -738,6 +740,7 @@ 3C663F001AB014B500286D8B /* research */ = { isa = PBXGroup; children = ( + 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */, 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */, 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */, 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */, @@ -925,6 +928,7 @@ 3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */, 3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */, 3C036B561B2D0AC10078E2E0 /* srs_app_http_stream.cpp in Sources */, + 3CB25C2A1BB269FD00C97A63 /* jmp_sp.cpp in Sources */, 3C068D6D1B10175500AA722C /* srs_protocol_buffer.cpp in Sources */, 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */, 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */, diff --git a/trunk/research/arm/jmp_sp.cpp b/trunk/research/arm/jmp_sp.cpp index 4fa4bc83a..d3d9edd89 100644 --- a/trunk/research/arm/jmp_sp.cpp +++ b/trunk/research/arm/jmp_sp.cpp @@ -11,22 +11,7 @@ jmp_buf context; -void func1() -{ -#if defined(__amd64__) || defined(__x86_64__) - register long int rsp0 asm("rsp"); - - int ret = setjmp(context); - printf("setjmp func1 ret=%d, rsp=%#lx\n", ret, rsp0); - // enter by longjmp - if (ret != 0) { - printf("call by longjmp.\n"); - exit(0); - } -#endif -} - -void func0() +void do_longjmp() { /** the definition of jmp_buf: @@ -78,8 +63,6 @@ void func0() printf("env[%d]=%#x, ", i, (int)context[0].__jmpbuf[i]); } printf("\n"); - - func1(); #endif #if defined(__arm__) @@ -105,7 +88,7 @@ void func0() */ /** For example, on raspberry-pi, armv6 cpu: - (gdb) x /64 context[0].__jmpbuf + (gdb) x /64xb (char*)context[0].__jmpbuf v1, 0: 0x00 0x00 0x00 0x00 v2, 1: 0x00 0x00 0x00 0x00 v3, 2: 0x2c 0x84 0x00 0x00 @@ -147,8 +130,7 @@ int main(int argc, char** argv) (int)__GLIBC__, (int)__GLIBC_MINOR__); #endif - func0(); - longjmp(context, 1); + do_longjmp(); printf("terminated\n"); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 7e206d1c1..2ebbbf584 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 191 +#define VERSION_REVISION 192 // server info. #define RTMP_SIG_SRS_KEY "SRS" @@ -119,5 +119,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. className(const className&); \ className& operator= (const className&) +/** + * important check for st(state-threads), + * only support the following cpus: + * 1. i386/amd64/x86_64 + * 2. arm, glibc <= 2.15 + */ +#if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) + #error "only support i386/amd64/x86_64/arm cpu" +#endif +#if defined(__arm__) && __GLIBC__ != 2 || __GLIBC_MINOR__ > 15 + #error "for arm, only support glibc <= 2.15" #endif +#endif