Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 764863 - media-libs/x264-0.0.20231114-r1 - illegal instruction (4) at 3fffa0c9163c nip 3fffa0c9163c lr 3fffa0c91938 code 1 in libx264.so.164[3fffa0c00000+16d000] on <POWER7
Summary: media-libs/x264-0.0.20231114-r1 - illegal instruction (4) at 3fffa0c9163c nip...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: PPC64 Linux
: Normal normal
Assignee: Gentoo Media-video project
URL: https://code.videolan.org/videolan/x2...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-10 18:52 UTC by Adam Stylinski
Modified: 2024-10-10 09:42 UTC (History)
5 users (show)

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


Attachments
build.log (ppc64, 0.0.20231114-r1) (x264-0.0.20231114-r1:20240728-204227.log,73.11 KB, text/plain)
2024-07-28 21:00 UTC, ernsteiswuerfel
Details
emerge --info (file_764863.txt,6.47 KB, text/plain)
2024-07-28 21:01 UTC, ernsteiswuerfel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Stylinski 2021-01-10 18:52:37 UTC
It appears media-libs/x264's configure script simply checks for vsx support with the compiler rather than with the CPU.  This results in a libx264 binary being built with VSX extensions, which aren't valid for older PPC chips.  

Reproducible: Always

Steps to Reproduce:
1. emerge x264
Actual Results:  
Illegal instruction

Expected Results:  
Properly running encoder/decoder

It might just be a matter of passing --disable-vsx to the configure script my default and switching on this flag.  However, there may need to be additional patches to this code, as I don't think they've sufficiently tested a vanilla altivec machine with this in a while (it's still trying to use xxpermdi instructions in spite of vsx=no).  

I may end up submitting a patch upstream for this.
Comment 1 ernsteiswuerfel archtester 2024-07-28 20:58:49 UTC
Still a problem with current media-libs/x264-0.0.20231114-r1.

When encoding a video on my PowerMac G5 11,2 with "ffmpeg -i input.mkv -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv" ffmpeg crashes with following dmesg:

ffmpeg[64720]: illegal instruction (4) at 3fffa0c9163c nip 3fffa0c9163c lr 3fffa0c91938 code 1 in libx264.so.164[3fffa0c00000+16d000]
ffmpeg[64720]: code: 811f0290 28080002 41811fbc 83bf00a8 2f9d0000 419e000c 39200001 913f03ac 
ffmpeg[64720]: code: 837f008c 2f9b0000 409e1fb0 c19f02a8 <f00004d0> dbc10100 dbe10108 ff8c0000

Nowadays there is a CPU_FLAGS_PPC but that does not seem to help.
[ebuild   R    ] media-libs/x264-0.0.20231114-r1:0/164::gentoo  USE="interlaced threads (-opencl) -static-libs" CPU_FLAGS_PPC="altivec" 0 KiB
Comment 2 ernsteiswuerfel archtester 2024-07-28 21:00:25 UTC
Created attachment 898474 [details]
build.log (ppc64, 0.0.20231114-r1)
Comment 3 ernsteiswuerfel archtester 2024-07-28 21:01:06 UTC
Created attachment 898475 [details]
emerge --info
Comment 4 ernsteiswuerfel archtester 2024-07-29 21:47:09 UTC
The issue has already been reported upstream by Adam: https://code.videolan.org/videolan/x264/-/issues/26

The patch attached in the upstream issue applies but unfortunately does not work out. Running x264 still crashes with illegal instruction on my G5.
Comment 5 Adam Stylinski 2024-07-30 03:37:58 UTC
(In reply to ernsteiswuerfel from comment #4)
> The issue has already been reported upstream by Adam:
> https://code.videolan.org/videolan/x264/-/issues/26
> 
> The patch attached in the upstream issue applies but unfortunately does not
> work out. Running x264 still crashes with illegal instruction on my G5.

I'm fairly certain the fix had worked 3 years ago as I managed to encode an h264 video on the G5. It's possible with ffmpeg you are using x264 features I wasn't or more vsx code is getting compiled in. I might boot up the G5 this weekend and try to troubleshoot.
Comment 6 ernsteiswuerfel archtester 2024-07-30 21:27:47 UTC
(In reply to Adam Stylinski from comment #5)
> I'm fairly certain the fix had worked 3 years ago as I managed to encode an
> h264 video on the G5. It's possible with ffmpeg you are using x264 features
> I wasn't or more vsx code is getting compiled in. I might boot up the G5
> this weekend and try to troubleshoot.
This would be very welcomed!

I din't use much parameters, only "ffmpeg -i input.mkv -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv"

But I can try tomorrow without parameters and see whether that makes a difference.
Comment 7 Nick Bowler 2024-10-10 04:04:11 UTC
This problem affects PPC32 as well (testing on PowerMac G4).

The issue is that the x264 build system adds -mvsx to the compiler
flags by default, which enables GCC to emit VSX instructions for
ordinary C code.  This obviously ends badly on these machines.
The damage is clearly visible in the earlier attached build log.

So in addition to the patch from the upstream bugtracker, it is also
essential to pass --disable-vsx to configure, but unfortunately the
x264 ebuild does not respect EXTRA_ECONF so you have to patch it (or
the configure script) to achieve this.