Support direct compilation: ARM and other platforms, for ARM, armv8, aarch64, etc.
zhanglibo007 opened this issue · 12 comments
Build on ARM Server
You can compile directly, just like an x86 server.
./configure && make
Build in aarch64 Docker
If you want to compile ARM binaries and run them on an ARM server, you can use ARM Docker for compilation. Please refer to aarch64 for more information.
docker run -it --rm -v `pwd`:/srs -w /srs/trunk ossrs/srs:aarch64 \
bash -c "./configure && make"
For aarch64
If the system does not define __aarch64__
, you can use the following command for compilation:
./configure --extra-flags='-D__aarch64__' && make
For general ARM servers, specific macros such as __arm__
or __aarch64__
are usually defined, so you can directly use ./configure && make
.
Note: In general, you can compile directly and should not use cross-compilation. If you need to cross-compile, please refer to #1547.
TRANS_BY_GPT3
I think the core dump is caused by setjmp incompability between state-threads and the modern glibc, which encrypts some pointers in jmp_buf, especially SP. The solution is to provide built-in setjmp. I have written some code to solve this problem on arm and arm64 and will upload it later.
i used cpu is arm64, instruction is v8.
the follow is debug log :
root@NanoPC-T4:/home/pi/workspace/srs/trunk# gdb objs/srs core
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from objs/srs...done.
warning: exec file is newer than core file.
[New LWP 9596]
Core was generated by `./objs/srs -c conf/rtmp.conf'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x001631a0 in SrsTcpListener::listen (this=<error reading variable: Cannot access memory at address 0xffffffc7>) at src/app/srs_app_listener.cpp:263
Backtrace stopped: Cannot access memory at address 0xffffffff
(gdb)
Here is the patch. Replace the file trunk/3rdparty/patches/1.st.arm.patch with the attachment. Just try it.
1.st.arm.patch.txt
very good!
TRANS_BY_GPT3
Awesome !!
Thank you so much! It worked flawless!!
Please pull to main code this fix
https://github.com/ossrs/state-threads/tree/srs#branch-srs
Merge from michaeltalyansky and xzh3836598, support ARM.
Here is the patch. Replace the file trunk/3rdparty/patches/1.st.arm.patch with the attachment. Just try it.
1.st.arm.patch.txt
Thank you for your great work, and could you please merge your patch to https://github.com/ossrs/state-threads/tree/srs#branch-srs ?
Just in case other folks get stuck here like I did!
# srs - https://github.com/ossrs/srs
# Start with an official arm32v7 image for Raspberry Pi 3 B+
docker run --name srs -it -p 1935:1935 -p 8085:8085 arm32v7/python:3.7.3-slim-stretch bash
# Update and install requirements
apt-get update && apt-get upgrade -y
apt-get install -y apt-utils build-essential cmake gcc git net-tools pkg-config sudo unzip wget
# Clone srs repo
cd /opt && git clone https://github.com/ossrs/srs && cd srs/trunk
# Fix: Raspberry Pi 3 B+ "Segmentation fault (core dumped)" - Issue: https://github.com/ossrs/srs/issues/1282
wget https://github.com/ossrs/srs/files/2660564/1.st.arm.patch.txt
rm 3rdparty/patches/1.st.arm.patch
mv 1.st.arm.patch.txt 3rdparty/patches/1.st.arm.patch
# Configure, make and install srs
./configure && make
make install
# Review the srs version
/usr/local/srs/objs/srs -v
# Command line start srs server
/usr/local/srs/objs/srs -c /usr/local/srs/conf/rtmp.conf
srs runs now
root@69d3ebfa8bd4:/opt/srs/trunk# /usr/local/srs/objs/srs -v
2.0.263
root@69d3ebfa8bd4:/opt/srs/trunk# /usr/local/srs/objs/srs -c /usr/local/srs/conf/rtmp.conf
[2019-05-19 13:49:35.628][trace][28137][0] XCORE-SRS/2.0.263(ZhouGuowen)
[2019-05-19 13:49:35.630][trace][28137][0] config parse complete
[2019-05-19 13:49:35.630][trace][28137][0] write log to console
[2019-05-19 13:49:35.630][trace][28137][0] srs checking config...
[2019-05-19 13:49:35.631][trace][28137][0] detect intranet address: 127.0.0.1, ifname=lo
[2019-05-19 13:49:35.632][trace][28137][0] retrieve local ipv4 ip=172.17.0.2, index=0
[2019-05-19 13:49:35.632][trace][28137][0] detect intranet address: 172.17.0.2, ifname=eth0
[2019-05-19 13:49:35.632][warn][28137][0][0] stats network use index=0, ip=172.17.0.2
[2019-05-19 13:49:35.632][warn][28137][0][0] stats disk not configed, disk iops disabled.
[2019-05-19 13:49:35.632][trace][28137][0] write log to console
[2019-05-19 13:49:35.632][trace][28137][0] SRS/2.0.263(ZhouGuowen), stable is SRS/2.0release
[2019-05-19 13:49:35.632][trace][28137][0] license: The MIT License (MIT), Copyright (c) 2013-2015 SRS(ossrs)
[2019-05-19 13:49:35.633][trace][28137][0] primary/master: SRS/2.0release
[2019-05-19 13:49:35.633][trace][28137][0] authors: winlin,wenjie.zhao
[2019-05-19 13:49:35.633][trace][28137][0] contributors: winlin<winlin@vip.126.com> wenjie.zhao<740936897@qq.com> xiangcheng.liu<liuxc0116@foxmail.com> naijia.liu<youngcow@youngcow.net> alcoholyi<alcoholyi@qq.com> byteman<wangchen2011@gmail.com> chad.wang<chad.wang.cn@gmail.com> suhetao<suhetao@gmail.com> Johnny<fengjihu@163.com> karthikeyan<keyanmca@gmail.com> StevenLiu<lq@chinaffmpeg.org> zhengfl<zhengfl_1989@126.com> tufang14<breadbean1449@gmail.com> allspace<allspace@gmail.com> niesongsong<nie950@gmail.com> rudeb0t<nimrod@themanxgroup.tw> CallMeNP<np.liamg@gmail.com> synote<synote@qq.com> lovecat<littlefawn@163.com> panda1986<542638787@qq.com> YueHonghui<hongf.yue@hotmail.com> JuntaoLiu<juntliu@gmail.com>
[2019-05-19 13:49:35.633][trace][28137][0] uname: Linux 69d3ebfa8bd4 4.19.34-v7+ #1211 SMP Mon Apr 8 22:56:37 BST 2019 armv7l GNU/Linux
[2019-05-19 13:49:35.633][trace][28137][0] build: 2019-05-19 13:40:47, little-endian
[2019-05-19 13:49:35.633][trace][28137][0] configure: --x86-x64
[2019-05-19 13:49:35.633][trace][28137][0] features: --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --without-nginx --with-ssl --without-ffmpeg --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --without-stream-caster --with-http-api --with-librtmp --without-research --with-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace
[2019-05-19 13:49:35.633][trace][28137][0] conf: /usr/local/srs/conf/rtmp.conf, limit: 1000
[2019-05-19 13:49:35.633][trace][28137][0] writev limits write 1024 iovs a time
[2019-05-19 13:49:35.634][trace][28137][0] cpu is arm, glibc 2.24
[2019-05-19 13:49:35.634][trace][28137][0] check feature rtmp handshake: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature hls: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature hds: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature http callback: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature http api: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature http server: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature http parser: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature dvr: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature transcode: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature ingest: on
[2019-05-19 13:49:35.634][trace][28137][0] check feature system stat: on
[2019-05-19 13:49:35.634][warn][28137][0][0] check feature compile nginx: off
[2019-05-19 13:49:35.634][warn][28137][0][0] check feature compile ffmpeg: off
[2019-05-19 13:49:35.635][warn][28137][0][0] stream caster: off
[2019-05-19 13:49:35.635][trace][28137][0] MR(merged-read): on, @see https://github.com/ossrs/srs/issues/241
[2019-05-19 13:49:35.635][trace][28137][0] MR(merged-read) default 0 sleep 350
[2019-05-19 13:49:35.635][trace][28137][0] MW(merged-write) default sleep 350
[2019-05-19 13:49:35.635][trace][28137][0] read chunk stream cache cid [0, 16)
[2019-05-19 13:49:35.635][trace][28137][0] default gop cache 1, play queue 30s
[2019-05-19 13:49:35.635][trace][28137][0] complex send algorithm enabled.
[2019-05-19 13:49:35.635][warn][28137][0][0] TCP_NODELAY enabled, may hurts performance.
[2019-05-19 13:49:35.635][trace][28137][0] auto guess socket send buffer by merged write
[2019-05-19 13:49:35.635][trace][28137][0] system default latency in ms: mw(0-350) + mr(0-350) + play-queue(0-30000)
[2019-05-19 13:49:35.636][trace][28137][0] http: root mount to ./objs/nginx/html
[2019-05-19 13:49:35.636][trace][28137][0] st_set_eventsys to epoll
[2019-05-19 13:49:35.637][trace][28137][0] st_init success, use epoll
[2019-05-19 13:49:35.637][trace][28137][100] server main cid=100, pid=28137, ppid=1, asprocess=0
[2019-05-19 13:49:35.637][trace][28137][100] write pid=28137 to ./objs/srs.pid success!
[2019-05-19 13:49:35.648][trace][28137][100] RTMP listen at tcp://0.0.0.0:1935, fd=7
[2019-05-19 13:49:35.649][trace][28137][100] signal installed
[2019-05-19 13:49:35.660][trace][28137][100] http: api mount /console to ./objs/nginx/html/console
[2019-05-19 13:49:35.670][trace][28137][100] ingest thread cid=103, current_cid=100
It seems aarch64 is not the same thing as arm
@neonxin Thank you very much, I have merged this patch to ST ossrs/state-threads#9 and patched SRS3 by ea8111c and 84f6f3d
Also fixed in #1537