state-threads icon indicating copy to clipboard operation
state-threads copied to clipboard

aosp中编译srs-server及libst报错

Open sunplusApp opened this issue 4 years ago • 2 comments

目前我在做的是将srs及libst源码放入android源码中交叉编译,然后集成进安卓手机中(手机CPU架构aarch64)。 android源码现在是用clang 编译。 在编译libst时,这个MD_GET_SP宏报错

#elif defined(__aarch64__)
            /* https://github.com/ossrs/state-threads/issues/9 */
            #define MD_STACK_GROWS_DOWN
            #define MD_USE_BUILTIN_SETJMP
            #define MD_GET_SP(_t) ((_t)->context[0].__jmpbuf[13])

报错内容:

system/core/libst/sched.c:616:9: error: member reference base type 'long' is not a structure or union
        _ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
system/core/libst/common.h:442:30: note: expanded from macro '_ST_INIT_CONTEXT'
    #define _ST_INIT_CONTEXT MD_INIT_CONTEXT
                             ^
system/core/libst/md.h:472:13: note: expanded from macro 'MD_INIT_CONTEXT'
            MD_GET_SP(_thread) = (long) (_sp);         \
            ^~~~~~~~~~~~~~~~~~
system/core/libst/md.h:429:52: note: expanded from macro 'MD_GET_SP'
            #define MD_GET_SP(_t) ((_t)->context[0].__jmpbuf[13])
                                   ~~~~~~~~~~~~~~~~^~~~~~~~~

请问这个是什么原因啊?是clang的问题吗?

sunplusApp avatar Dec 23 '21 09:12 sunplusApp

嵌入式环境差别比较大,这个就是setmpjmpbuf定义不太一样,需要你处理下。

可以参考 https://github.com/ossrs/state-threads/blob/srs/tools/porting/porting.c 看看具体怎么写才是对的。

欢迎Patch下。

winlinvip avatar Dec 23 '21 10:12 winlinvip

#define MD_GET_SP(_t) ((_t)->context[0].__jmpbuf[13]) 看了下这行大概的意思是获取获取SP指针?编译报错是context[0]是个long类型变量,遂将上面代码改成 #define MD_GET_SP(_t) ((_t)->context[JB_RSP] 这样就编过了,而且测试好用。

sunplusApp avatar Mar 11 '22 00:03 sunplusApp