Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support direct compilation: ARM and other platforms, for ARM, armv8, aarch64, etc. #1282

Closed
zhanglibo007 opened this issue Nov 30, 2018 · 12 comments
Assignees
Labels
Duplicated Duplicated bug. Feature It's a new feature. TransByAI Translated by AI/GPT.
Milestone

Comments

@zhanglibo007
Copy link

zhanglibo007 commented Nov 30, 2018

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

@neonxin
Copy link

neonxin commented Dec 6, 2018

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.

@zhanglibo007
Copy link
Author

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)

@neonxin
Copy link

neonxin commented Dec 9, 2018

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

@zhanglibo007
Copy link
Author

zhanglibo007 commented Dec 10, 2018

very good!

TRANS_BY_GPT3

@jinzequn
Copy link

Awesome !!

@Bit0git
Copy link

Bit0git commented Feb 1, 2019

Thank you so much! It worked flawless!!
Please pull to main code this fix

@winlinvip
Copy link
Member

winlinvip commented May 6, 2019

https://github.com/ossrs/state-threads/tree/srs#branch-srs

Merge from michaeltalyansky and xzh3836598, support ARM.

@neonxin

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 ?

@ernestgwilsonii
Copy link

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

@winlinvip
Copy link
Member

It seems aarch64 is not the same thing as arm

@winlinvip
Copy link
Member

winlinvip commented Dec 25, 2019

#1282 (comment)

@winlinvip
Copy link
Member

@neonxin Thank you very much, I have merged this patch to ST ossrs/state-threads#9 and patched SRS3 by ea8111c and 84f6f3d

@winlinvip winlinvip changed the title RTMP Segmentation fault FOR ARM RTMP Segmentation fault FOR ARM, armv8, aarch64, 龙芯等嵌入式平台 Jan 20, 2020
@winlinvip
Copy link
Member

Also fixed in #1537

@winlinvip winlinvip changed the title RTMP Segmentation fault FOR ARM, armv8, aarch64, 龙芯等嵌入式平台 支持ARM和龙芯等平台,For ARM, armv8, aarch64, etc. Jun 18, 2021
@winlinvip winlinvip added Feature It's a new feature. Duplicated Duplicated bug. labels Jun 18, 2021
@winlinvip winlinvip changed the title 支持ARM和龙芯等平台,For ARM, armv8, aarch64, etc. 支持直接编译:ARM和龙芯等平台,For ARM, armv8, aarch64, etc. Jun 18, 2021
@ossrs ossrs locked as too heated and limited conversation to collaborators Jun 18, 2021
@winlinvip winlinvip self-assigned this Sep 5, 2021
@winlinvip winlinvip added this to the 3.0 milestone Sep 6, 2021
@winlinvip winlinvip changed the title 支持直接编译:ARM和龙芯等平台,For ARM, armv8, aarch64, etc. 支持直接编译:ARM等平台,For ARM, armv8, aarch64, etc. Oct 20, 2021
@winlinvip winlinvip changed the title 支持直接编译:ARM等平台,For ARM, armv8, aarch64, etc. Support direct compilation: ARM and other platforms, for ARM, armv8, aarch64, etc. Jul 27, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicated Duplicated bug. Feature It's a new feature. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

6 participants