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

Build: Support cross build toolchain with clang/clang++ #3713

Open
terrencetang2023 opened this issue Jul 26, 2023 · 2 comments
Open

Build: Support cross build toolchain with clang/clang++ #3713

terrencetang2023 opened this issue Jul 26, 2023 · 2 comments
Assignees
Labels
good first issue Easy to fix issues, good for newcomers help wanted Extra attention is needed TransByAI Translated by AI/GPT.

Comments

@terrencetang2023
Copy link
Contributor

terrencetang2023 commented Jul 26, 2023

Note: Please read FAQ before file an issue, see #2716

Description

When the cross-compilation tool uses clang/clang++, gcc/g++ is forcibly appended, please add the judgment condition of the clang tool

  1. SRS Version: v6.0-d0

  2. SRS Log:

For cross build, host: /data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang, prefix: /data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-, arch: arm, cpu:  gcc: /data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-gcc
Enable FFmpeg native opus for cross building
Enable asan by auto options.
User config: --prefix=/home/tangshaoteng/codes/gitee_priv/lycium_back/usr/srs/armeabi-v7a --cross-build --cc=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang --cxx=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang++ --ar=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ar --ld=/data/local/ohos-sdk/linux/native/llvm/bin/ld.lld --randlib=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ranlib --backtrace=off
Detail config: --prefix=/home/tangshaoteng/codes/gitee_priv/lycium_back/usr/srs/armeabi-v7a --config=conf/srs.conf --osx=off --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-converter=on --http-api=on --utest=off --srt=on --rtc=on --h265=off --gb28181=off --simulator=off --cxx11=on --cxx14=off --backtrace=off --ffmpeg-fit=on --ffmpeg-opus=on --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --shared-st=off --shared-srt=off --shared-ffmpeg=off --log-verbose=off --log-info=off --log-trace=on --log-level_v2=on --gcov=off --apm=off --debug=off --debug-stats=off --cross-build=on --sanitizer=on --sanitizer-static=off --sanitizer-log=off --cygwin64=off --single-thread=off --generic-linux=off --arch=arm --host=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang --cross-prefix=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang- --cc=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-gcc --cxx=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-g++ --ar=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-ar --ld=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-ld --randlib=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-randlib
Discover SRS version=6.0.59, major=6
SRS_WORKDIR: ., SRS_OBJS: ./objs, SRS_PLATFORM: Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux
All outputs to: ./objs/Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux
Alias python2 as python
SRS_JOBS: --jobs=8, SRS_DEPENDS_LIBS: /home/tangshaoteng/codes/gitee_priv/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs, OS_IS_LINUX: YES, OS_IS_UBUNTU: YES, SRS_CROSS_BUILD: YES, OS_IS_X86_64: YES
link static-libasan
libasan api found ok!
Building state-threads.
make: Entering directory '/home/tangshaoteng/codes/gitee_priv/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs/Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux/st-srs
make OS="LINUX" BUILD="DBG"
make[1]: Entering directory '/home/tangshaoteng/codes/gitee_priv/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs/Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux/st-srs
if [ ! -d LINUX_5.15.0-76-generic_DBG ]; then mkdir LINUX_5.15.0-76-generic_DBG; fi
/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-gcc  -DLINUX -DMD_HAVE_EPOLL -DMD_HAVE_SELECT -DDEBUG -Wall -g -O0 -DMALLOC_STACK -DMD_HAVE_EPOLL  -c sched.c -o LINUX_5.15.0-76-generic_DBG/sched.o
make[1]: /data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-gcc: command not found
make[1]: *** [Makefile:283: LINUX_5.15.0-76-generic_DBG/sched.o] Error 127
make[1]: Leaving directory '/home/tangshaoteng/codes/gitee_priv/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs/Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux/st-srs'
make: *** [Makefile:310: linux-debug] Error 2
make: Leaving directory '/home/tangshaoteng/codes/gitee_priv/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs/Platform-SRS6-Linux-5.15.0-GCC9.4.0-x86_64-crossbuild-arm-linux/st-srs
Build state-threads failed, ret=2
make: *** No target specified and no makefile found. Stop.
  1. SRS Config:

Replay

Please describe how to replay the bug?

Step 1: run configure

./configure --cross-build --cc=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang --cxx=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang++ --ar=${OHOS_SDK}/native/llvm/bin/llvm-ar --ld=${OHOS_SDK}/native/llvm/bin/ld.lld --randlib=${OHOS_SDK}/native/llvm/bin/llvm-ranlib

Step 2: make

make

Expect

It is expected to add clang/clang++ support in cross-compilation environments

TRANS_BY_GPT3

@terrencetang2023
Copy link
Contributor Author

error: /data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang-gcc not found

@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
@winlinvip winlinvip self-assigned this Apr 3, 2024
@winlinvip winlinvip changed the title Please add the cross-compilation tool's judgment condition for clang/clang++ Build: Support cross build toolchain with clang/clang++ Apr 3, 2024
@winlinvip
Copy link
Member

To support cross build, SRS extract the --cross-prefix from --cc, which only support gcc right now:

        if [[ $SRS_CROSS_BUILD_PREFIX != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
            SRS_CROSS_BUILD_HOST=$(echo $SRS_CROSS_BUILD_PREFIX| sed 's/-$//g')
        fi
        if [[ $SRS_TOOL_CC != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
            SRS_CROSS_BUILD_HOST=$(echo $SRS_TOOL_CC| sed 's/-gcc$//g')
        fi
        if [[ $SRS_CROSS_BUILD_PREFIX == "" ]]; then
            SRS_CROSS_BUILD_PREFIX="${SRS_CROSS_BUILD_HOST}-"
        fi
        SRS_TOOL_CC=${SRS_CROSS_BUILD_PREFIX}gcc

So there is a workaround, to specify the prefix and cc, for example:

--cross-prefix=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos- \
--cc=clang

Welcome to help to improve the auto/options.sh script to support clang.

@winlinvip winlinvip added good first issue Easy to fix issues, good for newcomers help wanted Extra attention is needed labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Easy to fix issues, good for newcomers help wanted Extra attention is needed TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants