Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 782811

Summary: media-video/ffmpeg-4.4 fails to link to libatomic on ARM
Product: Gentoo Linux Reporter: Gordon Bos <bugzilla>
Component: Current packagesAssignee: Gentoo Media-video project <media-video>
Status: RESOLVED FIXED    
Severity: normal CC: sam
Priority: Normal    
Version: unspecified   
Hardware: ARM   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=820095
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 790590    
Bug Blocks: 721344    

Description Gordon Bos 2021-04-14 09:31:09 UTC
Building media-video/ffmpeg-4.4 on ARM ends with the following error message:

```
armv5tel-softfloat-linux-gnueabi-gcc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,-O1 -Wl,--as-needed  -march=armv5te -Wl,--as-needed -Wl,-z,noexecstack -Wl,--warn-common -Wl,-rpath-link=:libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample   -o ffmpeg_g fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o fftools/cmdutils.o fftools/ffmpeg.o  -lavdevice -lavfilter -lavformat -lavcodec -lavresample -lpostproc -lswresample -lswscale -lavutil  -lm -pthread -lm -lm -lbz2 -lz -lgnutls -pthread -lm -ldav1d -lz -lm -lm -lm -lm -pthread -lm  
/usr/libexec/gcc/armv5tel-softfloat-linux-gnueabi/ld: libavformat/libavformat.so: undefined reference to `__atomic_fetch_sub_8'
/usr/libexec/gcc/armv5tel-softfloat-linux-gnueabi/ld: libavformat/libavformat.so: undefined reference to `__atomic_store_8'
/usr/libexec/gcc/armv5tel-softfloat-linux-gnueabi/ld: libavformat/libavformat.so: undefined reference to `__atomic_load_8'
/usr/libexec/gcc/armv5tel-softfloat-linux-gnueabi/ld: libavformat/libavformat.so: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
```


Reproducible: Always




Expanding the link command with `-latomic` (needs to be done several times if manually executed) allows the ebuild to finish successfully.

Suggested fix: pass `--extra-ldflags="-latomic"` to the `configure` command.
Comment 1 Gordon Bos 2021-04-14 11:35:48 UTC
Testing the (external) suggested fix, it appears to place libatomic before the objects and the build still fails. It does work with:

`--extra-libs=-latomic`
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-05-09 07:22:32 UTC
In general, the full build.log and emerge --info helps us debug this stuff.

Where was the fix suggested?
Comment 3 Gordon Bos 2021-05-09 11:21:27 UTC
Ooff, a month ago... I think it was on StackOverflow. I also found multiple other issues referencing libatomic link failures on ARM and it was hinted that if you use an older version of GCC the failing jobs will complete correctly.

As far as I understand the issue is restricted to ARM only and with GCC >= 10.2
Comment 4 Larry the Git Cow gentoo-dev 2021-05-30 10:13:20 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31e3918f3db9351651fd8d4b787097c08a0ccafc

commit 31e3918f3db9351651fd8d4b787097c08a0ccafc
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-05-30 10:12:28 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-05-30 10:12:36 +0000

    media-video/ffmpeg: fix libatomic on arm/ppc
    
    Closes: https://bugs.gentoo.org/790590
    Closes: https://bugs.gentoo.org/782811
    Signed-off-by: Sam James <sam@gentoo.org>

 media-video/ffmpeg/ffmpeg-4.4.ebuild | 8 ++++++++
 1 file changed, 8 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2022-10-09 23:10:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f499582f7119a0485f60e1f2cd741eacc58c0fba

commit f499582f7119a0485f60e1f2cd741eacc58c0fba
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-10-09 23:04:21 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-10-09 23:10:34 +0000

    media-video/ffmpeg: add 4.4.3
    
    * Drop -latomic workaround added for bug 782811, bug 790590. Fixed
      upstream in https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/78062c6d71324fa89708211213b4267d2a57b806.
    
    * Fix UB in ff_seek_frame_binary-crash causing a crash with >= Clang 14.
      Might be the issue hit in bug 858806 (seems very likely).
    
    Bug: https://bugs.gentoo.org/782811
    Bug: https://bugs.gentoo.org/790590
    Closes: https://bugs.gentoo.org/858806
    Signed-off-by: Sam James <sam@gentoo.org>

 media-video/ffmpeg/Manifest                        |   2 +
 media-video/ffmpeg/ffmpeg-4.4.3.ebuild             | 598 +++++++++++++++++++++
 ...4.4.3-clang-14-ff_seek_frame_binary-crash.patch |  46 ++
 3 files changed, 646 insertions(+)