pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2.02k stars 770 forks source link

Error "g++: error: unrecognized command line option '-mfma'" when building latest master on Yocto (Debian 10) linux #2758

Closed aleh4d closed 2 years ago

aleh4d commented 3 years ago

Describe the bug

I tried to compile latest master sours from repository on Yocto (Debian 10) Linux to get support for WebRTC AEC3 (as describe in https://github.com/pjsip/pjproject/pull/2722)

On 'make dep' step Got Error "g++: error: unrecognized command line option '-mfma'"

Steps to reproduce

steps to reproduce:

wget https://github.com/pjsip/pjproject/archive/refs/heads/master.zip
unzip -a master.zip cd pjproject-master cp pjlib/include/pj/config_site_sample.h pjlib/include/pj/config_site.h ./configure --disable-video --enable-libwebrtc-aec3 make dep

PJSIP version

latest sources from repositary

Context

Yocto (Debian 10) Linux

Log, call stack, etc

h_avx2.cc ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/vector_math_avx2.S; do \
   if test -f $F; then \
     echo "output/libwebrtc-aec3-aarch64-unknown-linux-gnu/" | tr -d '\n' >> .libwebrtc-aec3-aarch64-unknown-linux-gnu.depend; \
     if echo $F | grep -q "\.c[c|pp]"; then \
        dep="g++ -c -M -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1    -I. -I../../webrtc_aec3/src -I../../../pjlib/include                                     -fexceptions  -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX=1 -mfma  -DPJ_AUTOCONF=1 -g -O2 -std=c++17    -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0                                     -DPJ_IS_LITTLE_ENDIAN=1    -I. -I../../webrtc_aec3/src -I../../../pjlib/include $F"; \
     else \
        dep="gcc -c -M -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1    -I. -I../../webrtc_aec3/src -I../../../pjlib/include                                     -fexceptions  -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX=1 -mfma $F"; \
     fi; \
     if eval $dep | sed '/^#/d' >> .libwebrtc-aec3-aarch64-unknown-linux-gnu.depend; then \
        true; \
     else \
        echo 'err:' >> .libwebrtc-aec3-aarch64-unknown-linux-gnu.depend; \
        rm -f .libwebrtc-aec3-aarch64-unknown-linux-gnu.depend; \
        exit 1; \
     fi; \
   fi; \
done;
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
gcc: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
gcc: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
g++: error: unrecognized command line option '-mfma'
make[3]: Leaving directory '/home/compulab/pjsip_build_2/pjproject-master/third_party/build/webrtc_aec3'
make[2]: Leaving directory '/home/compulab/pjsip_build_2/pjproject-master/third_party/build/webrtc_aec3'
make[1]: Leaving directory '/home/compulab/pjsip_build_2/pjproject-master/third_party/build'
make[1]: Entering directory '/home/compulab/pjsip_build_2/pjproject-master/pjmedia/build'
make -f /home/compulab/pjsip_build_2/pjproject-master/build/rules.mak APP=PJMEDIA app=pjmedia depend
make[2]: Entering directory '/home/compulab/pjsip_build_2/pjproject-master/pjmedia/build'
rm -f .pjmedia-aarch64-unknown-linux-gnu.depend
for F in  ../src/pjmedia/echo_speex.m ../src/pjmedia/echo_speex.c ../src/pjmedia/echo_speex.cpp ../src/pjmedia/echo_speex.cc ../src/pjmedia/echo_spee                                    x.S  ../src/pjmedia/alaw_ulaw.m ../src/pjmedia/alaw_ulaw.c ../src/pjmedia/alaw_ulaw.cpp ../src/pjmedia/alaw_ulaw.cc ../src/pjmedia/alaw_ulaw.S  ../sr                                    c/pjmedia/alaw_ulaw_table.m ../src/pjmedia/alaw_ulaw_table.c ../src/pjmedia/alaw_ulaw_table.cpp ../src/pjmedia/alaw_ulaw_table.cc ../src/pjmedia/alaw                                    _ulaw_table.S  ../src/pjmedia/avi_player.m ../src/pjmedia/avi_player.c ../src/pjmedia/avi_player.cpp ../src/pjmedia/avi_player.cc ../src/pjmedia/avi_                                    player.S  ../src/pjmedia/bidirectional.m ../src/pjmedia/bidirectional.c ../src/pjmedia/bidirectional.cpp ../src/pjmedia/bidirectional.cc ../src/pjmed
sauwming commented 3 years ago

Your machine probably doesn't support avx2, so try removing/commenting this part in third_party/build/webrtc_aec3/os-auto.mak:

    export WEBRTC_AEC3_SRC += \
    common_audio/resampler/sinc_resampler_avx2.o \
    modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.o \
    modules/audio_processing/aec3/adaptive_fir_filter_avx2.o \
    modules/audio_processing/aec3/fft_data_avx2.o \
    modules/audio_processing/aec3/matched_filter_avx2.o \
    modules/audio_processing/aec3/vector_math_avx2.o \
    modules/audio_processing/agc2/rnn_vad/vector_math_avx2.o
    WEBRTC_AEC3_OTHER_CFLAGS += -mfma

If it works, then I can create a patch to automatically detect this.

aleh4d commented 3 years ago

Can not find file "third_party/build/webrtc_aec3/os-auto.mak" looks like the file does not exist:

ls -la third_party/build/webrtc_aec3/ total 28 drwxr-xr-x 2 compulab compulab 4096 Jul 15 08:05 . drwxr-xr-x 14 compulab compulab 4096 Jul 15 07:59 .. -rw-r--r-- 1 compulab compulab 7104 Jul 15 08:00 .libwebrtc-aec3-aarch64-unknown-linux-gnu.depend -rw-r--r-- 1 compulab compulab 9141 Jul 13 09:36 Makefile

It is Yocto linux that I am using - it is Debian 10 bases, but Arm64, cant that be the reason? What to try next?

sauwming commented 3 years ago

Sorry, it should be third_party/build/os-auto.mak

aleh4d commented 3 years ago

there is the file: "third_party/build/os-auto.mak.in" so it has "mak.in" extension, right?

aleh4d commented 3 years ago

Thank you for support, commented the lines that you specified in the file is the file: "third_party/build/os-auto.mak.in" now make dep worked only with 2 errors:

../../webrtc/src/webrtc//modules/audio_processing/aec/aec_core_sse2.c:15:10: fatal error: emmintrin.h: No such file or directory

include

      ^~~~~~~~~~~~~

compilation terminated. ../../webrtc/src/webrtc//modules/audio_processing/aec/aec_rdft_sse2.c:13:10: fatal error: emmintrin.h: No such file or directory

include

      ^~~~~~~~~~~~~

does that mean that WebRTC was not found? It will be without echo cancellation because of that?

sauwming commented 3 years ago

Just realised that your machine's architecture is aarch64. So please try the attached patch instead: aconfigure_patch.txt

aleh4d commented 3 years ago

unzipped clean version, applied the patch, then called configure: ./configure --disable-video --enable-libwebrtc-aec3 and still got the following errors on "make dep"

../../webrtc/src/webrtc//modules/audio_processing/aec/aec_core_sse2.c:15:10: fatal error: emmintrin.h: No such file or directory

include

      ^~~~~~~~~~~~~

compilation terminated. ../../webrtc/src/webrtc//modules/audio_processing/aec/aec_rdft_sse2.c:13:10: fatal error: emmintrin.h: No such file or directory

include

      ^~~~~~~~~~~~~

I am compiling with WebRTC for echo cancellation, does that mean that I should download and compile WebRTC first? Need instruction how compile with WebRTC, and whether it needs to download WebRTC separately, or part of it is already included in PJSip project?

sauwming commented 3 years ago

You can try this updated patch: aconfigure_patch2.txt

Alternatively, you can disable WebRTC as mentioned in the other issue #2752.

aleh4d commented 3 years ago

Downloaded fresh copy of master, When applying patch got following error: (so patch was partially applied) result of patch application:

//***** compulab@iot-gate-imx8:~/pjsip_build_3/pjproject-master$ patch < aconfigure_patch2.txt patching file aconfigure Hunk #1 succeeded at 9243 (offset 3 lines). Hunk #2 succeeded at 9357 (offset 3 lines). Hunk #3 FAILED at 9380. 1 out of 3 hunks FAILED -- saving rejects to file aconfigure.rej patching file aconfigure.ac Hunk #1 succeeded at 2206 (offset 3 lines). Hunk #2 succeeded at 2291 (offset 3 lines).

compulab@iot-gate-imx8:~/pjsip_build_3/pjproject-master$ cat aconfigure.rej --- aconfigure +++ aconfigure @@ -9380,7 +9380,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu $as_echo "Checking if libwebrtc-aec3 is enabled...no" >&6; } fi

- else ac_no_webrtc_aec3=1 $as_echo "#define PJMEDIA_HAS_LIBWEBRTC_AEC3 0" >>confdefs.h

//*****

then I run:

./configure --disable-video --enable-libwebrtc-aec3 make

make got error:

g++ -c -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I. -I../../webrtc_aec3/src -I../../../pjlib/include -fexceptions -DWEBRTC_ARCH_ARM64 -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX=1 -DWEBRTC_HAS_NEON -DPJ_AUTOCONF=1 -g -O2 -std=c++17 -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I. -I../../webrtc_aec3/src -I../../../pjlib/include \ -o output/libwebrtc-aec3-aarch64-unknown-linux-gnu/rtc_base/platform_thread_types.o \ ../../webrtc_aec3/src//rtc_base/platform_thread_types.cc ../../webrtc_aec3/src//rtc_base/platform_thread_types.cc: In function 'rtc::PlatformThreadId rtc::CurrentThreadId()': ../../webrtc_aec3/src//rtc_base/platform_thread_types.cc:46:59: error: invalid cast from type 'pthread_t' {aka 'long unsigned int'} to type 'rtc::PlatformThreadId' {aka 'int'} return reinterpret_cast(pthread_self()); ^ make[3]: *** [/home/compulab/pjsip_build_3/pjproject-master/build/rules.mak:183: output/libwebrtc-aec3-aarch64-unknown-linux-gnu/rtc_base/platform_thread_types.o] Error 1 make[3]: Leaving directory '/home/compulab/pjsip_build_3/pjproject-master/third_party/build/webrtc_aec3'

make had also some warnings:

../../webrtc_aec3/src//modules/audio_processing/agc2/adaptive_agc.cc: In function 'std::unique_ptr webrtc::{anonymous}::CreateNoiseLevelEstimator(webrtc::{anonymous}::NoiseEstimatorType, webrtc::ApmDataDumper*)': ../../webrtc_aec3/src//modules/audio_processing/agc2/adaptive_agc.cc:57:1: warning: control reaches end of non-void function [-Wreturn-type]

In file included from ../../webrtc_aec3/src/modules/audio_processing/agc2/rnn_vad/rnn_fc.h:19, from ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/rnn_fc.cc:14: ../../webrtc_aec3/src/api/function_view.h: In instantiation of 'rtc::FunctionView<RetT(ArgT ...)>::FunctionView(F&&) [with F = float (&)(float); typename std::enable_if<std::is_function<typename std::remove_pointer<typename std::remove_reference<_SrcTuple>::type>::type>::value>::type = 0; RetT = float; ArgT = {float}]': ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/rnn_fc.cc:58:25: required from here ../../webrtc_aec3/src/api/functionview.h:79:17: warning: the compiler can assume that the address of 'f' will never be NULL [-Waddress] : call(f ? CallFunPtr<typename std::remove_pointer::type> : nullptr) { ^~~~~~~~~~~~~~~ ../../webrtc_aec3/src/api/function_view.h:79:17: warning: the compiler can assume that the address of 'f' will never be NULL [-Waddress] ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/rnn_fc.cc: In function 'rtc::FunctionView<float(float)> webrtc::rnn_vad::{anonymous}::GetActivationFunction(webrtc::rnn_vad::ActivationFunction)': ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/rnn_fc.cc:64:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ In file included from ../../webrtc_aec3/src/modules/audio_processing/agc2/rnn_vad/rnn_fc.h:19, from ../../webrtc_aec3/src//modules/audio_processing/agc2/rnn_vad/rnn_fc.cc:14: ../../webrtc_aec3/src/api/function_view.h: In constructor 'rtc::FunctionView<RetT(ArgT ...)>::FunctionView(F&&) [with F = float (&)(float); typename std::enable_if<std::is_function<typename std::remove_pointer<typename std::remove_reference<_SrcTuple>::type>::type>::value>::type = 0; RetT = float; ArgT = {float}]': ../../webrtc_aec3/src/api/functionview.h:79:17: warning: nonnull argument 'f' compared to NULL [-Wnonnull-compare] : call(f ? CallFunPtr<typename std::remove_pointer::type> : nullptr) { ^~~~~~~~~~~~~~~

}

asesidaa commented 2 years ago

I can confirm that manually apply the patch (adding aarch64 checks) can fix the compilation issue on arm64 machines. (At least on mine) Maybe add this patch to master branch?