Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 864929 - media-video/ffmpeg does not build on arm64 Darwin prefix, because cpu_flags_arm_neon is not enabled
Summary: media-video/ffmpeg does not build on arm64 Darwin prefix, because cpu_flags_a...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: ARM64 OS X
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-11 18:13 UTC by ZongyuZ
Modified: 2023-06-23 19:09 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
a patch to remove neon related lines in the ebuild (disable_neon_brutal.patch,749 bytes, patch)
2022-08-11 18:14 UTC, ZongyuZ
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ZongyuZ 2022-08-11 18:13:16 UTC
media-video/ffmpeg does not compile on (arm64) Darwin prefix.


The ebuild of ffmpeg will explicitly set `--disable-neon` option to disable neon support if `cpu_flags_arm_neon` is not enabled.
And unfortunately, `gentoo_prefix:prefix/darwin/macos/12.0/arm64/gcc` profile does not have `CPU_FLAGS_ARM` enabled.


As a result, the ebuild will not compile some objects related to neon, which causes
```
Undefined symbols for architecture arm64:
  "_ff_nv12_to_abgr_neon", referenced from:
      _nv12_to_abgr_neon_wrapper in swscale_unscaled.o
  "_ff_nv12_to_argb_neon", referenced from:
      _nv12_to_argb_neon_wrapper in swscale_unscaled.o

  ...

ld: symbol(s) not found for architecture arm64
```
and makes ffmpeg fail to build.


I was able to build the ffmpeg package by stripping out all the neon-related lines (shown in `disable_neon_brutal.patch`) in the ebuild of ffmpeg,
but the problem obviously needs a more elegant way to get fixed :)
Maybe enable `CPU_FLAGS_ARM` on arm64 Darwin prefix?
Comment 1 ZongyuZ 2022-08-11 18:14:26 UTC
Created attachment 799317 [details, diff]
a patch to remove neon related lines in the ebuild
Comment 2 ZongyuZ 2022-08-11 18:15:34 UTC
output of emerge --info:

Portage 3.0.34 (python 3.10.4-final-0, prefix/darwin/macos/12.0/arm64/gcc, gcc-12.1.0, unavailable, 21.6.0 arm64)
=================================================================
                         System Settings
=================================================================
System uname: macOS-12.5-arm64-64bit
Timestamp of repository gentoo_prefix: Thu, 11 Aug 2022 14:56:51 +0000
Head commit of repository gentoo_prefix: 012de8a8c30852e9d4f6c6292642629530b5d55d
sh bash 5.1_p16-r1
app-misc/pax-utils:        1.3.5::gentoo_prefix
app-shells/bash:           5.1_p16-r1::gentoo_prefix
dev-lang/perl:             5.36.0::gentoo_prefix
dev-lang/python:           3.10.4::gentoo_prefix
dev-util/cmake:            3.24.0::gentoo_prefix
dev-util/meson:            0.63.0::gentoo_prefix
sys-apps/baselayout:       2.8-r2::gentoo_prefix
sys-devel/autoconf:        2.71-r1::gentoo_prefix
sys-devel/automake:        1.16.5::gentoo_prefix
sys-devel/binutils-config: 5.1-r4::gentoo_prefix
sys-devel/clang:           14.0.6-r1::gentoo_prefix
sys-devel/gcc:             12.1.0::gentoo_prefix
sys-devel/gcc-config:      1.9.1::gentoo_prefix
sys-devel/libtool:         2.4.7::gentoo_prefix
sys-devel/llvm:            14.0.6-r2::gentoo_prefix
sys-devel/make:            4.3::gentoo_prefix
Repositories:

gentoo_prefix
    location: /Volumes/Meteora/gentoo/repos/portage
    sync-type: rsync
    sync-uri: rsync://mirrors.bfsu.edu.cn/gentoo-portage-prefix/
    priority: -1000
    sync-rsync-verify-metamanifest: no
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1

Inanna
    location: /Volumes/Meteora/gentoo/repos/Inanna

Triton
    location: /Volumes/Meteora/gentoo/repos/Triton
    masters: gentoo_prefix

ACCEPT_KEYWORDS="~x64-macos"
ACCEPT_LICENSE="@FREE"
CBUILD="arm64-apple-darwin21"
CFLAGS=""
CHOST="arm64-apple-darwin21"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CONFIG_SHELL="/opt/gentoo/bin/bash"
CXXFLAGS=""
DISTDIR="/Volumes/Meteora/gentoo/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS=" -march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live candy case-insensitive-fs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news nostrip parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sfperms strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged"
FFLAGS=" -march=native -O2 -pipe"
GENTOO_MIRRORS="https://mirrors.cernet.edu.cn/gentoo"
LANG="zh_CN.UTF-8"
LDFLAGS="-Wl,-dead_strip_dylibs"
MAKEOPTS="-j2"
PKGDIR="/Volumes/Meteora/gentoo/packages"
PORTAGE_CONFIGROOT="/opt/gentoo/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/Volumes/Meteora/gentoo/build"
SHELL="/bin/zsh"
USE="aqua arm64-macos clang coreaudio ipv6 libglvnd lto ncurses nls objc objc++ pgo prefix prefix-guest readline ssl unicode x64-macos zlib" ADA_TARGET="gnat_2020" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="Darwin" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 3 ZongyuZ 2022-08-11 18:17:08 UTC
emerge -pqv media-video/ffmpeg:gentoo_prefix:

[ebuild     UD] media-video/ffmpeg-4.4.2 [5.0.1] USE="bzip2 dav1d encode gnutls gpl iconv network postproc threads zlib -X (-alsa) -amf -amr -amrenc -appkit -bluray -bs2b -cdio -chromaprint -chromium -codec2 -cpudetection (-cuda) -debug -doc -fdk -flite -fontconfig -frei0r -fribidi -gcrypt -gme -gmp -gsm -hardcoded-tables -iec61883 -ieee1394 -jack -jpeg2k -kvazaar -ladspa -libaom -libaribb24 -libass -libcaca -libdrm -libilbc -librtmp -libsoxr -libtesseract -libv4l -libxml2 -lv2 -lzma (-mipsdspr1) (-mipsdspr2) (-mipsfpu) (-mmal) -modplug -mp3 (-nvenc) -openal -opencl -opengl -openh264 -openssl -opus (-oss) -pic -pulseaudio (-rav1e) -rubberband -samba -sdl -snappy -sndio -speex -srt -ssh -static-libs -svg -svt-av1 -test -theora -truetype -twolame (-v4l) -vaapi (-vdpau) -verify-sig -vidstab -vmaf -vorbis -vpx -vulkan -webp -x264 -x265 -xvid -zeromq -zimg -zvbi" FFTOOLS="aviocat cws2fws ffescape ffeval ffhash fourcc2pixfmt graph2dot ismindex pktdumper qt-faststart sidxindex trasher" 



tail of the build.log:

arm64-apple-darwin21-gcc -dynamiclib -Wl,-single_module -Wl,-install_name,/opt/gentoo/usr/lib/libswresample.3.dylib,-current_version,3.9.100,-compatibility_version,3 -Wl,-exported_symbols_list,libswresample/libswresample.ver -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,-dead_strip_dylibs  -Wl,-dynamic,-search_paths_first  -o libswresample/libswresample.3.dylib libswresample/aarch64/audio_convert_init.o libswresample/aarch64/resample_init.o libswresample/audioconvert.o libswresample/dither.o libswresample/log2_tab.o libswresample/options.o libswresample/rematrix.o libswresample/resample.o libswresample/resample_dsp.o libswresample/swresample.o libswresample/swresample_frame.o -lavutil -lavutil -lm -pthread -lm -framework CoreFoundation -pthread -lm -framework CoreFoundation 
make: *** [/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/work/ffmpeg-4.4.2/ffbuild/library.mak:103: libswscale/libswscale.5.dylib] Error 1
make: *** Waiting for unfinished jobs....
Undefined symbols for architecture arm64:
  "_ff_resample_common_apply_filter_x4_float_neon", referenced from:
      _ff_resample_common_float_neon in resample_init.o
  "_ff_resample_common_apply_filter_x4_s16_neon", referenced from:
      _ff_resample_common_s16_neon in resample_init.o
  "_ff_resample_common_apply_filter_x8_float_neon", referenced from:
      _ff_resample_common_float_neon in resample_init.o
  "_ff_resample_common_apply_filter_x8_s16_neon", referenced from:
      _ff_resample_common_s16_neon in resample_init.o
  "_swri_oldapi_conv_flt_to_s16_neon", referenced from:
      _conv_flt_to_s16_neon in audio_convert_init.o
  "_swri_oldapi_conv_fltp_to_s16_2ch_neon", referenced from:
      _conv_fltp_to_s16_2ch_neon in audio_convert_init.o
  "_swri_oldapi_conv_fltp_to_s16_nch_neon", referenced from:
      _conv_fltp_to_s16_nch_neon in audio_convert_init.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make: *** [/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/work/ffmpeg-4.4.2/ffbuild/library.mak:103: libswresample/libswresample.3.dylib] Error 1
 [31;01m*[0m ERROR: media-video/ffmpeg-4.4.2::gentoo_prefix failed (compile phase):
 [31;01m*[0m   emake failed
 [31;01m*[0m 
 [31;01m*[0m If you need support, post the output of `emerge --info '=media-video/ffmpeg-4.4.2::gentoo_prefix'`,
 [31;01m*[0m the complete build log and the output of `emerge -pqv '=media-video/ffmpeg-4.4.2::gentoo_prefix'`.
 [31;01m*[0m The complete build log is located at '/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/temp/build.log'.
 [31;01m*[0m The ebuild environment file is located at '/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/temp/environment'.
 [31;01m*[0m Working directory: '/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/work/ffmpeg-4.4.2-.arm64'
 [31;01m*[0m S: '/Volumes/Meteora/gentoo/build/portage/media-video/ffmpeg-4.4.2/work/ffmpeg-4.4.2'
Comment 4 Fabian Groffen gentoo-dev 2023-06-23 19:09:01 UTC
I fixed this by setting the appropriate cpu_flags_arm_* in profiles, after a sync you should be able to compile ffmpeg.