openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

fdk-aac does not compile with MIPS16 #14295

Open avbohemen opened 3 years ago

avbohemen commented 3 years ago

Maintainer: @thess Environment: ath79, TP-Link Archer C7 v2, OpenWrt trunk r15252

Description:

fdk-aac does not compile with MIPS16. At least with GCC 9.3. Adding "PKG_USE_MIPS16:=0" to Makefile fixes it.

Compile log:

OpenWrt-libtool: compile:  mips-openwrt-linux-musl-g++ -DPACKAGE_NAME=\"fdk-aac\" -DPACKAGE_TARNAME=\"fdk-aac\" -DPACKAGE_VERSION=\"2.0.1\" "-DPACKAGE_STRING=\"fdk-aac 2.0.1\"" -DPACKAGE_BUGREPORT=\"http://sourceforge.net/projects/opencore-amr/\" -DPACKAGE_URL=\"\" -DPACKAGE=\"fdk-aac\" -DVERSION=\"2.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I./libAACdec/include -I./libAACenc/include -I./libArithCoding/include -I./libDRCdec/include -I./libSACdec/include -I./libSACenc/include -I./libSBRdec/include -I./libSBRenc/include -I./libMpegTPDec/include -I./libMpegTPEnc/include -I./libSYS/include -I./libFDK/include -I./libPCMutils/include -I/home/anton/openwrt/archerc7/source/staging_dir/toolchain-mips_24kc_gcc-9.3.0_musl/usr/include -I/home/anton/openwrt/archerc7/source/staging_dir/toolchain-mips_24kc_gcc-9.3.0_musl/include/fortify -I/home/anton/openwrt/archerc7/source/staging_dir/toolchain-mips_24kc_gcc-9.3.0_musl/include -fno-exceptions -fno-rtti -Os -pipe -mno-branch-likely -march=74kc -mtune=74kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -fmacro-prefix-map=/home/anton/openwrt/archerc7/source/build_dir/target-mips_24kc_musl/fdk-aac-2.0.1=fdk-aac-2.0.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -MT libAACdec/src/aacdec_hcr.lo -MD -MP -MF libAACdec/src/.deps/aacdec_hcr.Tpo -c libAACdec/src/aacdec_hcr.cpp  -fPIC -DPIC -o libAACdec/src/.libs/aacdec_hcr.o
In file included from ./libFDK/include/abs.h:107,
                 from ./libFDK/include/common_fix.h:273,
                 from libAACdec/src/channelinfo.h:106,
                 from libAACdec/src/aacdec_hcr.h:108,
                 from libAACdec/src/aacdec_hcr.cpp:104:
./libFDK/include/mips/abs_mips.h: In function 'void HcrReorderQuantizedSpectralCoefficients(H_HCR_INFO, CAacDecoderChannelInfo*, const SamplingRateInfo*)':
./libFDK/include/mips/abs_mips.h:118:60: error: built-in function '__builtin_mips_absq_s_w' not supported for MIPS16
  118 | inline INT fixabs_I(INT x) { return __builtin_mips_absq_s_w(x); }
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~^~~
./libFDK/include/mips/abs_mips.h:114:70: error: built-in function '__builtin_mips_absq_s_w' not supported for MIPS16
  114 | inline FIXP_DBL fixabs_D(FIXP_DBL x) { return __builtin_mips_absq_s_w(x); }
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~
./libFDK/include/mips/abs_mips.h: In function 'UINT HcrDecoder(H_HCR_INFO, CAacDecoderChannelInfo*, const SamplingRateInfo*, HANDLE_FDK_BITSTREAM)':
./libFDK/include/mips/abs_mips.h:114:70: error: built-in function '__builtin_mips_absq_s_w' not supported for MIPS16
  114 | inline FIXP_DBL fixabs_D(FIXP_DBL x) { return __builtin_mips_absq_s_w(x); }
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~
./libFDK/include/mips/abs_mips.h:114:70: error: built-in function '__builtin_mips_absq_s_w' not supported for MIPS16
  114 | inline FIXP_DBL fixabs_D(FIXP_DBL x) { return __builtin_mips_absq_s_w(x); }
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~
make[4]: *** [Makefile:1573: libAACdec/src/aacdec_hcr.lo] Error 1
make[4]: Leaving directory '/home/anton/openwrt/archerc7/source/build_dir/target-mips_24kc_musl/fdk-aac-2.0.1'
make[3]: *** [Makefile:72: /home/anton/openwrt/archerc7/source/build_dir/target-mips_24kc_musl/fdk-aac-2.0.1/.built] Error 2
make[3]: Leaving directory '/home/anton/openwrt/archerc7/source/feeds/packages/sound/fdk-aac'
neheb commented 3 years ago

The reason you're hitting this error is because of https://github.com/mstorsjo/fdk-aac/blob/master/libFDK/include/mips/abs_mips.h#L110

__mips_dsp is not enabled on the build bots and under any standard toolchain. If you're going to be modifying your toolchain, there's no point in putting an issue here.

A somewhat proper fix would be:

--- a/libFDK/include/mips/abs_mips.h
+++ b/libFDK/include/mips/abs_mips.h
@@ -107,7 +107,7 @@ amm-info@iis.fraunhofer.de

 #if defined(__GNUC__) && defined(__mips__)

-#if defined(__mips_dsp)
+#if defined(__mips_dsp) && !defined(__mips16)
 #define FUNCTION_fixabs_D
 #define FUNCTION_fixabs_I
 #define FUNCTION_fixabs_S

edit2: actually can you run benchmarks? I'm very curious how much of a speedup PKG_USE_MIPS16:=0 brings.